All Projects → oprypin → mkdocs-section-index

oprypin / mkdocs-section-index

Licence: MIT License
MkDocs plugin to allow clickable sections that lead to an index page

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to mkdocs-section-index

mkdocs-static-i18n
MkDocs i18n plugin using static translation markdown files
Stars: ✭ 78 (+116.67%)
Mutual labels:  mkdocs, mkdocs-material, mkdocs-plugin
mkdocs-literate-nav
MkDocs plugin to specify the navigation in Markdown instead of YAML
Stars: ✭ 19 (-47.22%)
Mutual labels:  mkdocs, nav, mkdocs-plugin
mkdocs-git-revision-date-localized-plugin
MkDocs plugin to add a last updated date to your site pages
Stars: ✭ 73 (+102.78%)
Mutual labels:  mkdocs, mkdocs-material, mkdocs-plugin
mkdocs-exclude-search
🔎 A mkdocs plugin that lets you exclude selected chapters from the search index.
Stars: ✭ 16 (-55.56%)
Mutual labels:  mkdocs, mkdocs-material, mkdocs-plugin
mkdocs-table-reader-plugin
MkDocs plugin that adds a {{ read_csv('table.csv') }} markdown tag to directly insert CSV files as a table into a page.
Stars: ✭ 60 (+66.67%)
Mutual labels:  mkdocs, mkdocs-plugin
mkdocs-htmlproofer-plugin
A MkDocs plugin that validates URL in rendered html files
Stars: ✭ 17 (-52.78%)
Mutual labels:  mkdocs, mkdocs-plugin
privacyguides.org
Protect your data against global mass surveillance programs.
Stars: ✭ 1,316 (+3555.56%)
Mutual labels:  mkdocs, mkdocs-material
mkdocs-jekyll
The Material theme from MkDocs provided as a Jekyll template, optimized for GitHub Pages
Stars: ✭ 55 (+52.78%)
Mutual labels:  mkdocs, mkdocs-material
tutorials
Collection of tutorials for various libraries and technologies
Stars: ✭ 98 (+172.22%)
Mutual labels:  mkdocs, mkdocs-material
docs
📖 TomoChain documentation
Stars: ✭ 19 (-47.22%)
Mutual labels:  mkdocs, mkdocs-material
mkdocs-git-authors-plugin
MkDocs plugin to display git authors of a page.
Stars: ✭ 27 (-25%)
Mutual labels:  mkdocs, mkdocs-plugin
mkdocs-rss-plugin
MkDocs plugin to generate a RSS feeds for created and updated pages, using git log and YAML frontmatter (page.meta).
Stars: ✭ 43 (+19.44%)
Mutual labels:  mkdocs, mkdocs-plugin
lavalink-list
A list of free and available public lavalink. Feel free to make a pull request!
Stars: ✭ 43 (+19.44%)
Mutual labels:  mkdocs, mkdocs-material
obsidian-publish-mkdocs
A Template to Publish Obsidian/Foam Notes on Github Pages (uses MkDocs)
Stars: ✭ 219 (+508.33%)
Mutual labels:  mkdocs, mkdocs-material
mkdocs-markdownextradata-plugin
A MkDocs plugin that injects the mkdocs.yml extra variables into the markdown template
Stars: ✭ 48 (+33.33%)
Mutual labels:  mkdocs, mkdocs-plugin
ImageModels
ImageNet model implemented using the Keras Functional API
Stars: ✭ 63 (+75%)
Mutual labels:  mkdocs, mkdocs-material
fosscord-docs
Docs for Fosscord
Stars: ✭ 23 (-36.11%)
Mutual labels:  mkdocs, mkdocs-material
taller-de-git
Documentación del taller de git
Stars: ✭ 18 (-50%)
Mutual labels:  mkdocs, mkdocs-material
mkdocs-print-site-plugin
MkDocs Plugin that adds an additional page that combines all pages, allowing easy exports to PDF and standalone HTML.
Stars: ✭ 38 (+5.56%)
Mutual labels:  mkdocs, mkdocs-plugin
docutools
Dev Centric Tools for Mkdocs Based Documentation
Stars: ✭ 13 (-63.89%)
Mutual labels:  mkdocs, mkdocs-material

mkdocs-section-index

Plugin for MkDocs to allow clickable sections that lead to an index page

PyPI GitHub GitHub Workflow Status

pip install mkdocs-section-index

Example

Screencast with comparison

With this nav in mkdocs.yml (or without nav but with an equivalent directory structure):

nav:
  - Frob: index.md
  - Baz: baz.md
  - Borgs:
    - borgs/index.md
    - Bar: borgs/bar.md
    - Foo: borgs/foo.md

plugins:
  - section-index

The borgs/index.md page is merged as the index of the "Borgs" section. Normally sections in MkDocs cannot be clickable as pages themselves, but this plugin makes that possible.

See also: a realistic demo site.

Theme support

This plugin requires per-theme overrides (implemented within the plugin), or support from themes themselves.

Currently supported themes are:

Usage notes

The kind of nav as shown above also happens to be what MkDocs produces when nav is omitted; it detects index.md and README.md pages and automatically puts them as the first item.

To make writing this kind of nav more natural (in YAML there's no better option), consider using the literate-nav plugin along with this; then the above nav might be written like this:

* [Frob](index.md)
* [Baz](baz.md)
* [Borgs](borgs/index.md)
    * [Bar](borgs/bar.md)
    * [Foo](borgs/foo.md)

Implementation

"Protocol"

Normally in MkDocs nav, the items can be one of:

  • a Section, which has a title and children.
    • (url is always None)
  • a Page, which has a title and url.
    • (title can be omitted, and later deduced from the page content)
    • (children is always None)
  • a Link (inconsequential for our purposes).

This plugin introduces a hybrid kind of Page, which has all of these properties:

  • title: str
  • url: str
  • children: list
  • is_page = True
  • is_section = True

Such a special item gets put into a nav in the place of a Section which has a Page with an intentionally omitted title as its first child. Those two are naturally combined into a special section-page that's a hybrid of the two.

Implementation within themes

Then all that a theme's template needs to do is to meaningfully support such nav items -- ones that have both a url and children. The item should be directly clickable to go to the corresponding page, and also be able to house sub-items.

Of course, currently templates don't expect such a case; or if they did, it would be purely by chance. So currently this plugin "hacks into" templates of supported themes, patching their source on the fly to fit its needs. The hope is that, once this plugin gains enough traction, theme authors will be happy to directly support this scenario (which is totally non-intrusive and backwards-compatible), and then the patches could be dropped.

"Alternatives considered"

Even if all the template patches are gone, this plugin will still remain as the implementation of this special nav "protocol", and as the opt-in mechanism. In the author's view, such an approach is advantageous, because:

  • This is too controversial to be enabled by default, or even be part of MkDocs at all. This has been discussed in the past and dropped. The main reason is that in MkDocs there's no requirement for a nav's structure to follow the actual directory structure of the doc files. Consequently, there's no natural way to deduce that a document should become the index page of a section just from its location, even if it's named index.md. Although if the nav is omitted & generated, then yes, such an assumption works. It also works in the vast majority of actual usages with a nav, but that doesn't help.

  • Themes themselves also probably shouldn't directly try to detect logic such as "first child of a section if it has no title" and manually collapse the child within Jinja template code, as that's too messy. This also shouldn't be enabled by default. And even though templates could also make this opt-in, a centralized approach like this one ensures that accessing this feature is done uniformly. Not to mention that templates might never implement this themselves.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].