Skip to main content

includes jinja templates in a documentation

Project description

https://img.shields.io/travis/tardyp/sphinx-jinja.svg?maxAge=2592000

sphinx-jinja

A sphinx extension to include jinja based templates based documentation into a sphinx doc

Usage

In your rst doc, you can use the following snippet to use a jinja template to generate your doc

.. jinja:: first_ctx

    {% for k, v in topics.items() %}

    {{k}}
    ~~~~~
    {{v}}
    {% endfor %}

In your sphinx conf.py file, you can create or load the contexts needed for your jinja templates

extensions = ['sphinxcontrib.jinja']

jinja_contexts = {
    'first_ctx': {'topics': {'a': 'b', 'c': 'd'}}
}

Available options

  • file: allow to specify a path to Jinja instead of writing it into the content of the directive. Path is relative to the current directory of sphinx-build tool, typically the directory where the conf.py file is located.

  • header_char: character to use for the the headers. You can use it in your template to set your

    own title character:

    For example:

    Title
    {{ options.header_char * 5 }}

Example of declaration in your RST file:

.. jinja:: approval_checks_api
   :file: relative/path/to/template.jinja
   :header_char: -

Each element of the jinja_contexts dictionary is a context dict for use in your jinja templates.

Running tests

  • pip install tox

  • tox

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-jinja-0.3.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

sphinx_jinja-0.3.0-py2-none-any.whl (5.2 kB view details)

Uploaded Python 2

File details

Details for the file sphinx-jinja-0.3.0.tar.gz.

File metadata

File hashes

Hashes for sphinx-jinja-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9f9d97c96aa7e66b8e9897020f46b7a97f4e1e78b45e83edc6740d205ffce38
MD5 fc88aa7ccc602e8d6826ce192f4fc198
BLAKE2b-256 d1412e803b0412945a00ebe2013098d7ab7914d9d139f684e1ae8fa5a8dfa2d9

See more details on using hashes here.

Provenance

File details

Details for the file sphinx_jinja-0.3.0-py2-none-any.whl.

File metadata

File hashes

Hashes for sphinx_jinja-0.3.0-py2-none-any.whl
Algorithm Hash digest
SHA256 80170a744b7723621b9adc32e8b688383ffe6f9f9c151cfacffd179627d83afa
MD5 009e84c86ffc7d92733bfc1b57926d59
BLAKE2b-256 d24efca355ad7dfa049c226ce8b47d097fa434162100745fb9020e9b848c0346

See more details on using hashes here.

Provenance

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