module sphinxext.sphinx_template_extension

Inheritance diagram of pyquickhelper.sphinxext.sphinx_template_extension

Short summary

module pyquickhelper.sphinxext.sphinx_template_extension

Defines a sphinx extension tpl, a role which use templating.

source on GitHub

Classes

class

truncated documentation

ClassStruct

Class as struct.

tpl_node

Defines tpl node.

Functions

function

truncated documentation

depart_tpl_node

What to do when leaving a node tpl.

evaluate_template

Evaluate a template given a list of parameters given a list of named parameters.

setup

setup for bigger (sphinx)

tpl_role

Defines custom role tpl. A template must be specified in the configuration file.

visit_tpl_node

What to do when visiting a node tpl.

Properties

property

truncated documentation

document

Return the document root node of the tree containing this Node.

Methods

method

truncated documentation

__init__

All arguments are added to the class.

Documentation

Defines a sphinx extension tpl, a role which use templating.

source on GitHub

class pyquickhelper.sphinxext.sphinx_template_extension.ClassStruct(**kwargs)[source]

Bases: object

Class as struct.

source on GitHub

All arguments are added to the class.

source on GitHub

__init__(**kwargs)[source]

All arguments are added to the class.

source on GitHub

pyquickhelper.sphinxext.sphinx_template_extension.depart_tpl_node(self, node)[source]

What to do when leaving a node tpl.

source on GitHub

pyquickhelper.sphinxext.sphinx_template_extension.evaluate_template(template, engine='jinja2', **kwargs)[source]

Evaluate a template given a list of parameters given a list of named parameters.

Parameters:
  • template – template (jinja2)

  • enginejinja2 or mako

  • kwargs – additional parameters

Returns:

outcome

The function uses apply_template.

source on GitHub

pyquickhelper.sphinxext.sphinx_template_extension.setup(app)[source]

setup for bigger (sphinx)

source on GitHub

class pyquickhelper.sphinxext.sphinx_template_extension.tpl_node(rawsource='', text='', *children, **attributes)[source]

Bases: TextElement

Defines tpl node.

source on GitHub

__slotnames__ = [][source]
pyquickhelper.sphinxext.sphinx_template_extension.tpl_role(role, rawtext, text, lineno, inliner, options=None, content=None)[source]

Defines custom role tpl. A template must be specified in the configuration file.

:tpl:`template_name,p1=v2, p2=v2, ...`

The role evaluate this expression with function eval:

evaluate_template(template, p1=v1, p2=v2, ...)

You can switch engine by adding parameter engine='mako'. In the configuration file, the following must be added:

tpl_template = {'template_name': 'some template'}

template_name can also be a function.

tpl_template = {'py': python_link_doc}

And the corresponding line in the documentation:

:tpl:`py,m='ftplib',o='FTP.storbinary'`

Which gives: ftplib.FTP.storbinary based on function python_link_doc.

Parameters:
  • role – The role name used in the document.

  • rawtext – The entire markup snippet, with role.

  • text – The text marked with the role.

  • lineno – The line number where rawtext appears in the input.

  • inliner – The inliner instance that called us.

  • options – Directive options for customization.

  • content – The directive content for customization.

source on GitHub

pyquickhelper.sphinxext.sphinx_template_extension.visit_tpl_node(self, node)[source]

What to do when visiting a node tpl.

source on GitHub