sphinx-toctree-level-up
Standalone Sphinx extension that backports toctree :level-up: from sphinx-doc/sphinx#8287.
Use the same markup on your current Sphinx; delete the extension after you upgrade to a release that includes the native implementation.
Install
pip install sphinx-toctree-level-up
In conf.py:
extensions = [
'sphinx_toctree_level_up',
]
Usage
:level-up: N is relative: promote N section levels from the section that contains the toctree. The visible HTML in-page list stays where the directive is written. Only the TOC hierarchy (sidebar / env.tocs / section numbering) and single-file builders (LaTeX, singlehtml, texinfo, man) change structure.
Promote listed pages to siblings of the current section:
My title
========
My header
---------
.. toctree::
:level-up: 1
page1
This produces a TOC hierarchy of:
My title
├── My header
└── page1
rather than nesting page1 under My header.
Set a per-document default for later toctree directives (like highlight). An explicit :level-up: on a toctree overrides it, including :level-up: 0 to opt out:
.. toc-level-up:: 1
My header
---------
.. toctree::
page1
Requesting more levels than there are ancestor sections emits a warning (type='toc', subtype='level_up') and promotes as far as possible.
This extension does not add :target-level: or :level:.
Remove after upgrading Sphinx
This extension is meant as a stop gap. When Sphinx provides native :level-up:, this extension does not register its directives, so the feature is not applied twice. At startup it warns:
sphinx_toctree_level_up is no longer needed; Sphinx already provides toctree :level-up:.
Remove this extension from conf.py.
Then delete 'sphinx_toctree_level_up' from extensions and uninstall the package.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_toctree_level_up-0.1.0.tar.gz.
File metadata
- Download URL: sphinx_toctree_level_up-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fd84057bbd151dc69193a524d22444f1dac357aacdf674e9314fdbd099c84df
|
|
| MD5 |
af6c6fdcef35d9fbc36aadd37b20e813
|
|
| BLAKE2b-256 |
a3c6ae886dfe66f47dc48da51e42ddf0ee9943c28e9839f3771d9e76ec984372
|
File details
Details for the file sphinx_toctree_level_up-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_toctree_level_up-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cc3a668dffd20c7519b98e81a441dec1c91c06a4be5a4ca00cbcdde0e72771b
|
|
| MD5 |
dca44912f0ec0887a7cd4710e91715b4
|
|
| BLAKE2b-256 |
e2dc5fddc5e39f43aa8df5decc3ba69b5aa81d791c8115f805186d8f6897d68d
|