-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Relates: #32
The {toctree} directive is not a Myst native directive it comes from Sphinx.
Currently this repository includes the sample documentation from https://github.com/elastic/markitpy-samples/tree/main/docs/source which were heavily geared to Sphinx.
Pending discussion #38 we'll most likely don't want to support {toctree} but instead use the Myst native way through myst.yml
See: https://mystmd.org/guide/table-of-contents
This has several advantages:
- Building the navigation does not require us parsing the whole file for a
{toctree}- We don't have to enforce a
{toctree}is always provided at the beginning/end of anindex.md
- We don't have to enforce a
myst.ymlallows grouping of related files in the same folder throughchildrenwithout them needing to be in a folder
Disadvantages
- Myst only uses a single toc
myst.ymlfile so it's aone way doorin the sense either everything needs to be in the TOC or nothing. - It will flatten urls of nested files: https://mystmd.org/guide/table-of-contents#nested-files-will-have-flattened-urls
- Although this has been addressed very recently: Support folder hierarchies and nested files in URLs without flattening them jupyter-book/mystmd#670
Proposal
Since myst.toc is very much geared towards smaller documentation sites or single Jupiter notebook html export I propose we follow its TOC in spirt:
- Allow a single
tocdefinition control any nested children - Allow nested
tocdefinitions to isolate if needed - Not a one way door, we can still include
folder's without having to explicitly specify all its children - Subfolders can define their own
tocconfiguration- Unless a parent folder's
tocdefines its content explicitly this will result in a build error.
- Unless a parent folder's
Example configuration
exclude:
- notes.md
- '**/ignore.md'
toc:
- file: index.md
- file: config.md
- file: search.md
children:
- file: search-part2.md
- folder: search
- folder: my-folder1
exclude:
- '_*.md'
- folder: my-folder2
children:
- file: subpath/file.md
- file: file.md
- pattern: *.md
- folder: sub/folderGoing over the bits in isolation:
exclude:
- notes.md
- '**/ignore.md'Globally ignores any files matching the configured glob patterns.
toc:
- file: index.md
- file: config.mdOrdered list so index.md and config.md appear first.
- file: search.md
children:
- file: search-part2.md
- folder: search Creates a collapsable section in the navigation with search.md being the root and search-part2.md and the contents of the search folder as its children.
- folder: my-folder1
exclude:
- '_*.md'Auto include my-folder1 if that folder contains a toc it will use that otherwise use the default rules for folder inclusion.
- folder: my-folder2
children:
- file: subpath/file.md
- file: file.md
- pattern: *.md
- folder: sub/folderAn inline toc declaration for my-folder2. If that my-folder2 holds its own toc file too it will result in a build error.
The inline declaration automatically prefixes my-folder2 to children so that it can be renamed with ease.
future expansions ideas
We can expand this later with more options e.g:
- folder: new-feature
aliases: ['featureA', 'featureB']To emit the folder as new-feature/* and featureA/* and featureB/*` as a means to safely rename a folder while links and rewrite rules get updated.