Table Of Contents

This Page

sphinxcontrib.jinjadomain — Documenting jinja templates

This contrib extension, sphinxcontrib.jinjadomain, provides a Sphinx domain for describing jinja templates.

In order to use it, add sphinxcontrib.jinjadomain into extensions list of your Sphinx configuration file (conf.py):

extensions = ['sphinxcontrib.jinjadomain']

Basic usage

There are several provided directives that describe jinja templates.

.. jinja:template:: /etc/network/interfaces

   Template for network config

   :param hostname: your computer's hostname
   :type hostname: str
   :param ip: your computer's ip
   :type ip: str

will be rendered as:

TEMPLATE /etc/network/interfaces

Template for network config

Parameters:
  • hostname (str) – your computer’s hostname
  • ip (str) – your computer’s ip

Directives

.. jinja:template:: path

Describes an jinja template.

Resource Fields

Inside HTTP resource description directives like get, reStructuredText field lists with these fields are recognized and formatted nicely:

param, parameter, arg, argument
Description of URL parameter.

sphinxcontrib.autojinja.jinja — Creates jinja

It generates jinja reference documentation from a start comment in jinja template. Basicly it just takes docstring betwene {# and #} and inserts it where you specified autojinja directive.

In order to use it, add sphinxcontrib.autojinja.jinja into extensions list of your Sphinx configuration (conf.py) file:

extensions = ['sphinxcontrib.autojinja.jinja']

To make everything work you also have to specify relative or absolute path to your templates. If this option is not specified templates won’t be displayed in your documentation. You can do this by setting jinja_template_path in your Sphinx configuration (conf.py) file.

For example:

.. autojinja: sample_template.in

will be rendered as:

TEMPLATE sample_template.in

This is a sample template

Parameters:
  • param1 (str) – This is sample input parameter to this template

Author and License

The sphinxcontrib.jinjadomain and sphinxcontrib.autojinja, parts of sphinxcontrib, are written by Jaka Hudoklin and distributed under BSD license.

The source code is mantained under the common repository of contributed extensions for Sphinx (find the jinjadomain directory inside the repository).

$ git clone git://github.com/offlinehacker/sphinxcontrib.jinjadomain.git
$ cd jinjadomain
$ python setup.py install

This package is also avalible on PyPI as sphinxcontrib-jinjadomain