Skip to main content

Add support for tree view to Sphinx.

Project description

Sphinx Tree View

A lightweight Sphinx extension that provides a customizable tree view for documentation. A tree view can have an associated decorator type, which can be used to add custom icons to the tree view. By default, the extension provides a decorator type "dir" with file and folder icons.

Installation

pip install sphinx-treeview

Basic Usage

Add the extension to your Sphinx conf.py:

extensions = [
    'sphinx_treeview'
]

Use the directive in your RST files:

:::{treeview}
- {<decorator name>}`<icon1>` foo
  - {<decorator name>}`<icon2>` bar
- <decorator>`<icon1>` baz
:::

For example, with the default decorator "dir":

:::{treeview}
- {dir}`<folder>` folder
  - {dir}`<file>` file.jpeg
  - {dir}`<file>` file.png
:::

The rendered tree view will look like this:

Tree View

Configuration Options

The following options can be configured in your conf.py:

# Add custom decorators
stv_decorators = [
    DecoratorType(name="custom", icons=[DecoratorIcon(path="path/to/icon.svg", sphinx_static_path="icon/path/for/sphinx/", width=1.3, height=1.3, css_properties={...})])
]

# Disable default decorators (dir decorator)
stv_disable_default_decorators = False

A decorator icon is defined by a path to the icon file, and the path where the icon will be copied to in the Sphinx static folder. This second path is used in the CSS to load the icon. width and height are the dimensions of the icon in em, and css_properties is a dictionary of CSS properties to be applied to the icon. The name used for the icon in the tree view is the name of the icon file without the extension.

If you want to load all images of a folder as icons, you can use the imagesToDecoratorIcons function:

icons = imagesToDecoratorIcons(path="path/to/folder", sphinx_static_path="path/to/sphinx/folder")

By default, the dimensions of the icons are 1.3em × 1.3em.

License

This project is licensed under the MPL-2.0 License. See the LICENSE file for details. Images came from pictogrammers and are under Apache-2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_treeview-1.0.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_treeview-1.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_treeview-1.0.0.tar.gz.

File metadata

  • Download URL: sphinx_treeview-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.1 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for sphinx_treeview-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fca3ab4ab6601cd7a24a10e953698e799e30cd15edb2f33de4357faa21199230
MD5 31856a3ed0bea5045a0218cb810699b6
BLAKE2b-256 ae13a44bc8ca44a65077b3d6d26f4cd4aa88f961fbc8d77d56794f6f5f45bf44

See more details on using hashes here.

File details

Details for the file sphinx_treeview-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sphinx_treeview-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.1 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for sphinx_treeview-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02cd39bee9e4516c5f080f8d73e3e164d2d6a81597d83a259ee5c61526846a8b
MD5 857a73fa8290f0cdd73e1a2d7c16704a
BLAKE2b-256 ddcbe5047ac4afd08ff0d1aef2f720096e3dbf9acaf03d58520488a007c820f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page