Skip to main content

Include code examples to sphinx documentation

Project description

Sphinx Example Includer

Build Sphinx docs for the package's source code and automatically gaenerate .rst files from examples folder for the sphinx documentation. It is used by the sphinx-docs action to automate the generation of sphinx documentation.

examples screenshot

Installation

pip install sphinx_example_includer

Usage

usage: Sphinx Example Includer [-h] [--debug] [--info] [--overwrite] [--files FILES [FILES ...]] [--dest-dir DEST_DIR] [--toc-fname TOC_FNAME]
                               [--title TITLE] [--readme README] [--build] [--conf CONF] [--docs-dir DOCS_DIR] [--project-dir PROJECT_DIR]
                               [--index INDEX]

A Sphinx docs generation tool

options:
  -h, --help            show this help message and exit
  --debug               Showing debug messages
  --info                Showing info messages
  --overwrite           Overwrite files that already exists
  --files FILES [FILES ...]
                        one or more files to be
  --dest-dir DEST_DIR   The output directory of the included files inside the docs dir (e.g., docs/examples)
  --toc-fname TOC_FNAME
                        The name of the toc file
  --title TITLE         The title of the documentation in the index page.
  --readme README       The readme file to include in the docs index page.
  --build               Build Sphinx docs.
  --conf CONF           The configuration file (e.g., pyproject.toml)
  --docs-dir DOCS_DIR   The directory of the documentation
  --project-dir PROJECT_DIR
                        The path of the project's code
  --index INDEX         The name of the index file.

Example

python -m sphinx_example_includer --info --build --project src --files examples/*example*.py --overwrite --readme README.md

How to use it

Assumptions

  1. You have your example source code in examples/
  2. Your code is documented so Sphinx can generate the docs for you.

Generating the docs

  1. Install the package sphinx_example_includer
  2. In the directory of your project (that you want to document), run the command python -m sphinx_example_includer --build. Note that the --build is the flag responsible for generating the docs. You can also specify the directory of your code with the flag --project.
  3. Include the examples into the docs. This can be done by running the same command with --files flag and you can choose multiple files using a pattern as shown in the example above.

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_example_includer-0.5.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

sphinx_example_includer-0.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_example_includer-0.5.tar.gz.

File metadata

  • Download URL: sphinx_example_includer-0.5.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for sphinx_example_includer-0.5.tar.gz
Algorithm Hash digest
SHA256 e9ba4821b11895cebacb064c4932f6cc2f8ca4dba4286b0efb74e0f661223c17
MD5 6958afe5751f081e93e429a757f8223a
BLAKE2b-256 9b2b70e69c69fabbce6548b88d954beb32776a6e6ff10fa5319cee2c27f94724

See more details on using hashes here.

File details

Details for the file sphinx_example_includer-0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_example_includer-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a20e07f451bf953a79f99bb920d02df6d83c81af1d0f02d09be0aca15abbda
MD5 3ccb712607fe7f64110067e014856332
BLAKE2b-256 302cb206d3bb2f7a7e17da6db6ac2deaf433ecc9a218fa13b9d8f4ecf4b12917

See more details on using hashes here.

Supported by

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