Ellerbach / docfx-companion-tools

A suite of tools, pipelines templates to take the very best of DocFX
MIT License
66 stars 19 forks source link

TocGenerator doesn't link to generated index.md the first run, and contains index while parent item links to it #27

Closed CodeCasterNL closed 1 month ago

CodeCasterNL commented 1 year ago

Given this directory structure:

Running DocFxTocGenerator.exe --docfolder DocFxIndex --index, the toc.yml contains:

items:
- name: DocFxIndex
  href: index.md
- name: A
  href: A/B.md # links to B.md instead of index.md
  items:
  - name: A
    href: A/index.md # generated
  - name: B
    href: A/B.md

Issue 1:

The root-level item "A" links to A/B.md, because at generation-time the A/index.md didn't exist yet.

Running the TOC generator a second time fixes that:

items:
- name: DocFxIndex
  href: index.md
- name: A
  href: A/index.md # now links to A/index.md
  items:
  - name: A
    href: A/index.md # there's A/index.md again!
  - name: B
    href: A/B.md

Issue 2:

Now the TOC contains "A/index.md" twice, resulting in weird nesting in the menu, mentioning "A" twice:

A-A

Expectations

I would expect:

So:

items:
- name: DocFxIndex
  href: index.md
- name: A
  href: A/index.md # immediately links to the generated index
  items:
  # doesn't mention it again as child item
  - name: B
    href: A/B.md

A-B

mtirionMSFT commented 1 month ago

@CodeCasterNL After another investigation of this problem I found that your scenario still results in the wrong output where the index.md is ignored. I have fixed it in #57 and it will be released soon. Sorry for the delay.