Skip to main content

sphinx-toctree-level-up

PyPI version Parallel safe CI

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.

Metadata

Release files for sphinx-toctree-level-up 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-toctree-level-up 0.1.1
File Size Uploaded
sphinx_toctree_level_up-0.1.1.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-toctree-level-up 0.1.1
File Interpreter ABI Platform
sphinx_toctree_level_up-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / sphinx_toctree_level_up-0.1.1.tar.gz

Download URL sphinx_toctree_level_up-0.1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fe3209486b7e6d837d9b7ae0c9a01110993c33ee5be649065dfc12e946b59fd5
BLAKE2b-256 checksum
How to use checksums
83e6ef4426ac70a0995e71e40da6374bed7b03419e34fe2a00082ce57d8df374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / sphinx_toctree_level_up-0.1.1-py3-none-any.whl

Download URL sphinx_toctree_level_up-0.1.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
734496853a1cacfc11dcdc4142263354fa91a2abfe866e5f91f662246d34a637
BLAKE2b-256 checksum
How to use checksums
a652fc23016b218797645ab96e0b2498fabca94bc1520240622b1bd12fb546be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page