This script is used to generate toc.yml file for every folder in documentation project.
First you should install powershell-yaml
Install-Module powershell-yamlβ THIS MODULE DOES NOT WORK WITH WINDOWS POWERSHELL
β MAKE SURE YOU HAVE POWERSHELL CORE INSTALLED.
Install-Module -Name docfx-toc-generator Install the module, then run Build-TocHereRecursive function in the root of the docfx project, besides docfx.json
This module doesn't generate the root TOC (root of folder besides docfx.json), you should create that file yourself.
Simply create an empty .nodoc file in the root of the folder.
The href and items property of item in yaml file is created automatically.
For naming and order use Front Matter style yaml meta data in markdown file:
---
name: Sample Page
order: 100 # higher has more priority
---
# Sample Page
This module puts every non-index file(non-index.md) in the toc, then it includes every index.md files in subfolder in the toc, and other files in subfolders in the items subchild of index file. For example if you have such hierarchy:
|-- root-doc.md
|-- some-other-root-doc.md
>-- MyTopic
|---- somefile.md
|---- index.md
|
>-- OtherTopic
|-- index.md
|-- hello.md
This toc will be generated:
- name: Root Doc
href: root-doc.md
- name: Some Other Root Doc
href: some-other-root-doc.md
- name: My Topic
href: MyTopic/index.md
items:
- name: Some File
href: MyTopic/somefile.md
- name: Other Topic
href: OtherTopic/index.md
items:
- name: Hello World!
href: OtherTopic/hello.mdIf you want to ignore content of an index and remove its href attribute from toc file, simply add nocontent: true to the front matter:
| Attribute | Description | Type |
|---|---|---|
| name | Gives document a name in toc | string |
| order | Gives order of rendering to the document in toc (higher number has more priority and comes top of others) | int |
| nocontent | Ignores content and remove the href attribute in toc |
boolean |