mkdocs-toc-md


Namemkdocs-toc-md JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/try0/mkdocs-toc-md
SummaryGenerate a table of contents markdown file
upload_time2023-11-23 11:51:59
maintainer
docs_urlNone
authorRyo Tsunoda
requires_python>=3.6
licenseMIT
keywords mkdocs plugin toc generator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# mkdocs-toc-md

[mkdocs-toc-md](https://pypi.org/project/mkdocs-toc-md/) is a plugin for mkdocs that generates a table of contents in markdown format. To render the table of contents as HTML, the markdown file must be generated before running `mkdocs build`.

![](https://user-images.githubusercontent.com/17096601/199638378-892ddec9-b7af-4eb8-8ca8-a57c02980f53.png)



## Sample

[File](https://github.com/try0/mkdocs-toc-md/blob/main/sample/docs/index.en.md?plain=1)  
[Site](https://try0.github.io/mkdocs-toc-md/sample/site/)




## Usage

### Generates toc markdown file.

1. Install plugin. 
    ```
    pip install mkdocs-toc-md
    ```
1. Add plugin config to mkdocs.yml.

    ```yml
    plugins:
      - toc-md
    ```

1. Run `mkdocs serve` to output the toc md file.

1. Check docs/index.md.


### Adds description.
If you use metadata (front matter), set the value with toc_md_description as a key.
```
---
toc_md_description: pickup target value
---
```

or use options `pickup_description_meta` `pickup_description_class`.



## Options

Minimum
```yml
plugins:
  - toc-md:
```

Full
```yml
plugins:
  - toc-md:
      toc_page_title: Contents
      toc_page_description: Usage mkdocs-toc-md
      header_level: 3
      pickup_description_meta: false
      pickup_description_class: false
      output_path: index.md
      output_log: false
      ignore_page_pattern: index.*.md$
      remove_navigation_page_pattern: index.*.md$
      template_dir_path: custom_template
      integrate_mkdocs_static_i18n: true
      languages:
        en:
          toc_page_title: Contents
          toc_page_description: Usage mkdocs-toc-md
        ja:
          toc_page_title: 目次
          toc_page_description: mkdocs-toc-mdプラグインの使い方
      shift_header: after_h1_of_index
      extend_module: true
      output_comment: html
```

### toc_page_title: str  
h1 text in the table of contents markdown file.

default: Contents

### toc_page_description: str
The description will be rendered below the h1 tag in the table of contents.

default: None

### header_level: int  
Header level (depth) to render.  
h1→1, h2→2, ...

default: 3

### pickup_description_meta: bool  
The plugin renders the description after the h2 header in the table of contents markdown file. If you use metadata (front matter), there is no need to set this option.
```html
<mata name="description" content="pickup target value" />
```

default: False

### pickup_description_class: bool  
The plugin renders the description after the h2 header in the table of contents markdown file. If you use metadata (front matter), there is no need to set this option.

```md
# mkdocs-toc-md

<div class="toc-md-description">
pickup target value
</div>
```
default: False

### output_path: str  
Path to save rendered toc md file.  
index.md → docs/index.md

default: index.md

### output_log: bool  
Output contents of markdown file to console.

default: False

### ignore_page_pattern: str  
Regular expression pattern of markdown file names to be excluded from toc markdown file.  
To prevent the table of contents page from listing itself, set the same value as the output file name (output_path).

default: ''

### remove_navigation_page_pattern: str  
Regular expression pattern of markdown file names to remove navigation items.  
To hide the navigation on the table of contents page, set the same value as the output file name (output_path).

default: ''

### template_dir_path: str
Path of template dir.
Put `toc.md.j2` in your custom template dir.

default: ''

### beautiful_soup_parser: str
Parser used in BeautifulSoup. Default is html.parser.  
If using html5lib or lxml, you need to install additional dependencies.

default: html.parser

### integrate_mkdocs_static_i18n: bool
With [mkdocs-static-i18n](https://github.com/ultrabug/mkdocs-static-i18n)

default: False

### languages: dict
Use with integrate_mkdocs_static_i18n option.
Set toc_page_title, toc_page_description for each language.

```yml
languages:
    en:
        toc_page_title: Contents
        toc_page_description: Usage mkdocs-toc-md
    ja:
        toc_page_title: 目次
        toc_page_description: mkdocs-toc-mdプラグインの使い方
```

default: dict()

### shift_header: str (after_index, after_h1_of_index, none)
`after_index`  
    Shifts the header level(+1) except for the index file in the directory.

`after_h1_of_index`  
    Shifts the header level(+1) after h1 in index file and except for the index file in the directory.

`none` (default)

### extend_module: bool
Some processes can be extended by placing the toc_extend_module.py file in the docs folder.

```
├─ docs
│  ├─ mkdocs.yml
│  ├─ toc_extend_module.py
```

[Sample/toc_extend_module.py](./sample/toc_extend_module.py)


`find_src_elements` -> list[bs4.element.Tag]  
args

1. `bs_page_soup`: bs4.BeautifulSoup
1. `page`: mkdocs.structure.pages.Page
1. `toc_config`: mkdocs_toc_md.objects.TocConfig

`create_toc_items` -> list[mkdocs_toc_md.objects.TocItem]  
args

1. `page`: mkdocs.structure.pages.Page
1. `page_description`: str
1. `src_elements`: list[bs4.element.Tag]
1. `toc_config`: mkdocs_toc_md.objects.TocConfig

`on_create_toc_item`  
args

1. `toc_item`: mkdocs_toc_md.objects.TocItem
1. `src_element`: bs4.element.Tag
1. `page`: mkdocs.structure.pages.Page
1. `toc_config`: mkdocs_toc_md.objects.TocConfig

`on_before_output`  
args

1. `nav`: mkdocs.structure.nav.Navigation
1. `toc_items`: list[mkdocs_toc_md.objects.TocItem]
1. `toc_config`: mkdocs_toc_md.objects.TocConfig

### output_comment: str (html, metadata, none)

`html` (default)
```html
<!-- ====================== TOC ====================== -->
<!-- Generated by mkdocs-toc-md plugin -->
<!-- ================================================= -->
```

`metadata`
```
---
toc_output_comment: Generated by mkdocs-toc-md plugin
---
```
 
`none`


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/try0/mkdocs-toc-md",
    "name": "mkdocs-toc-md",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "mkdocs plugin toc generator",
    "author": "Ryo Tsunoda",
    "author_email": "try0.development@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b1/4f/27dfa123019f56a5381c2bf5a261b13593778cb48dc6a9a1e51a3aad0cee/mkdocs-toc-md-0.0.9.tar.gz",
    "platform": null,
    "description": "\n# mkdocs-toc-md\n\n[mkdocs-toc-md](https://pypi.org/project/mkdocs-toc-md/) is a plugin for mkdocs that generates a table of contents in markdown format. To render the table of contents as HTML, the markdown file must be generated before running `mkdocs build`.\n\n![](https://user-images.githubusercontent.com/17096601/199638378-892ddec9-b7af-4eb8-8ca8-a57c02980f53.png)\n\n\n\n## Sample\n\n[File](https://github.com/try0/mkdocs-toc-md/blob/main/sample/docs/index.en.md?plain=1)  \n[Site](https://try0.github.io/mkdocs-toc-md/sample/site/)\n\n\n\n\n## Usage\n\n### Generates toc markdown file.\n\n1. Install plugin. \n    ```\n    pip install mkdocs-toc-md\n    ```\n1. Add plugin config to mkdocs.yml.\n\n    ```yml\n    plugins:\n      - toc-md\n    ```\n\n1. Run `mkdocs serve` to output the toc md file.\n\n1. Check docs/index.md.\n\n\n### Adds description.\nIf you use metadata (front matter), set the value with toc_md_description as a key.\n```\n---\ntoc_md_description: pickup target value\n---\n```\n\nor use options `pickup_description_meta` `pickup_description_class`.\n\n\n\n## Options\n\nMinimum\n```yml\nplugins:\n  - toc-md:\n```\n\nFull\n```yml\nplugins:\n  - toc-md:\n      toc_page_title: Contents\n      toc_page_description: Usage mkdocs-toc-md\n      header_level: 3\n      pickup_description_meta: false\n      pickup_description_class: false\n      output_path: index.md\n      output_log: false\n      ignore_page_pattern: index.*.md$\n      remove_navigation_page_pattern: index.*.md$\n      template_dir_path: custom_template\n      integrate_mkdocs_static_i18n: true\n      languages:\n        en:\n          toc_page_title: Contents\n          toc_page_description: Usage mkdocs-toc-md\n        ja:\n          toc_page_title: \u76ee\u6b21\n          toc_page_description: mkdocs-toc-md\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f7f\u3044\u65b9\n      shift_header: after_h1_of_index\n      extend_module: true\n      output_comment: html\n```\n\n### toc_page_title: str  \nh1 text in the table of contents markdown file.\n\ndefault: Contents\n\n### toc_page_description: str\nThe description will be rendered below the h1 tag in the table of contents.\n\ndefault: None\n\n### header_level: int  \nHeader level (depth) to render.  \nh1\u21921, h2\u21922, ...\n\ndefault: 3\n\n### pickup_description_meta: bool  \nThe plugin renders the description after the h2 header in the table of contents markdown file. If you use metadata (front matter), there is no need to set this option.\n```html\n<mata name=\"description\" content=\"pickup target value\" />\n```\n\ndefault: False\n\n### pickup_description_class: bool  \nThe plugin renders the description after the h2 header in the table of contents markdown file. If you use metadata (front matter), there is no need to set this option.\n\n```md\n# mkdocs-toc-md\n\n<div class=\"toc-md-description\">\npickup target value\n</div>\n```\ndefault: False\n\n### output_path: str  \nPath to save rendered toc md file.  \nindex.md \u2192 docs/index.md\n\ndefault: index.md\n\n### output_log: bool  \nOutput contents of markdown file to console.\n\ndefault: False\n\n### ignore_page_pattern: str  \nRegular expression pattern of markdown file names to be excluded from toc markdown file.  \nTo prevent the table of contents page from listing itself, set the same value as the output file name (output_path).\n\ndefault: ''\n\n### remove_navigation_page_pattern: str  \nRegular expression pattern of markdown file names to remove navigation items.  \nTo hide the navigation on the table of contents page, set the same value as the output file name (output_path).\n\ndefault: ''\n\n### template_dir_path: str\nPath of template dir.\nPut `toc.md.j2` in your custom template dir.\n\ndefault: ''\n\n### beautiful_soup_parser: str\nParser used in BeautifulSoup. Default is html.parser.  \nIf using html5lib or lxml, you need to install additional dependencies.\n\ndefault: html.parser\n\n### integrate_mkdocs_static_i18n: bool\nWith [mkdocs-static-i18n](https://github.com/ultrabug/mkdocs-static-i18n)\n\ndefault: False\n\n### languages: dict\nUse with integrate_mkdocs_static_i18n option.\nSet toc_page_title, toc_page_description for each language.\n\n```yml\nlanguages:\n    en:\n        toc_page_title: Contents\n        toc_page_description: Usage mkdocs-toc-md\n    ja:\n        toc_page_title: \u76ee\u6b21\n        toc_page_description: mkdocs-toc-md\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f7f\u3044\u65b9\n```\n\ndefault: dict()\n\n### shift_header: str (after_index, after_h1_of_index, none)\n`after_index`  \n    Shifts the header level(+1) except for the index file in the directory.\n\n`after_h1_of_index`  \n    Shifts the header level(+1) after h1 in index file and except for the index file in the directory.\n\n`none` (default)\n\n### extend_module: bool\nSome processes can be extended by placing the toc_extend_module.py file in the docs folder.\n\n```\n\u251c\u2500 docs\n\u2502  \u251c\u2500 mkdocs.yml\n\u2502  \u251c\u2500 toc_extend_module.py\n```\n\n[Sample/toc_extend_module.py](./sample/toc_extend_module.py)\n\n\n`find_src_elements` -> list[bs4.element.Tag]  \nargs\n\n1. `bs_page_soup`: bs4.BeautifulSoup\n1. `page`: mkdocs.structure.pages.Page\n1. `toc_config`: mkdocs_toc_md.objects.TocConfig\n\n`create_toc_items` -> list[mkdocs_toc_md.objects.TocItem]  \nargs\n\n1. `page`: mkdocs.structure.pages.Page\n1. `page_description`: str\n1. `src_elements`: list[bs4.element.Tag]\n1. `toc_config`: mkdocs_toc_md.objects.TocConfig\n\n`on_create_toc_item`  \nargs\n\n1. `toc_item`: mkdocs_toc_md.objects.TocItem\n1. `src_element`: bs4.element.Tag\n1. `page`: mkdocs.structure.pages.Page\n1. `toc_config`: mkdocs_toc_md.objects.TocConfig\n\n`on_before_output`  \nargs\n\n1. `nav`: mkdocs.structure.nav.Navigation\n1. `toc_items`: list[mkdocs_toc_md.objects.TocItem]\n1. `toc_config`: mkdocs_toc_md.objects.TocConfig\n\n### output_comment: str (html, metadata, none)\n\n`html` (default)\n```html\n<!-- ====================== TOC ====================== -->\n<!-- Generated by mkdocs-toc-md plugin -->\n<!-- ================================================= -->\n```\n\n`metadata`\n```\n---\ntoc_output_comment: Generated by mkdocs-toc-md plugin\n---\n```\n \n`none`\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate a table of contents markdown file",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/try0/mkdocs-toc-md"
    },
    "split_keywords": [
        "mkdocs",
        "plugin",
        "toc",
        "generator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cdbb41ee7616b03f9937f94605c203fb21c88ed5420da650ce344ede3d481fd1",
                "md5": "8b5ab021f1eebcc799e69b2adaf27f1f",
                "sha256": "f2b25ef71efba40d8ba0f5034533c39e2dc00319051e9a037c439dc467fe250e"
            },
            "downloads": -1,
            "filename": "mkdocs_toc_md-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b5ab021f1eebcc799e69b2adaf27f1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10037,
            "upload_time": "2023-11-23T11:51:56",
            "upload_time_iso_8601": "2023-11-23T11:51:56.977674Z",
            "url": "https://files.pythonhosted.org/packages/cd/bb/41ee7616b03f9937f94605c203fb21c88ed5420da650ce344ede3d481fd1/mkdocs_toc_md-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b14f27dfa123019f56a5381c2bf5a261b13593778cb48dc6a9a1e51a3aad0cee",
                "md5": "121634a072c776252abac633d243c675",
                "sha256": "907fa1ed9bc0ddfc3ebb8881acbf8c4bf98ef442964c57906a6cb37f6fd179ef"
            },
            "downloads": -1,
            "filename": "mkdocs-toc-md-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "121634a072c776252abac633d243c675",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11227,
            "upload_time": "2023-11-23T11:51:59",
            "upload_time_iso_8601": "2023-11-23T11:51:59.098518Z",
            "url": "https://files.pythonhosted.org/packages/b1/4f/27dfa123019f56a5381c2bf5a261b13593778cb48dc6a9a1e51a3aad0cee/mkdocs-toc-md-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-23 11:51:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "try0",
    "github_project": "mkdocs-toc-md",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mkdocs-toc-md"
}
        
Elapsed time: 2.01538s