module sphinxext.sphinx_template_extension
¶
Short summary¶
module pyquickhelper.sphinxext.sphinx_template_extension
Defines a sphinx extension tpl
, a role which use templating.
Classes¶
class |
truncated documentation |
---|---|
Class as struct. |
|
Defines tpl node. |
Functions¶
function |
truncated documentation |
---|---|
What to do when leaving a node tpl. |
|
Evaluate a template given a list of parameters given a list of named parameters. |
|
setup for |
|
Defines custom role tpl. A template must be specified in the configuration file. |
|
What to do when visiting a node tpl. |
Documentation¶
Defines a sphinx extension tpl
, a role which use templating.
-
class
pyquickhelper.sphinxext.sphinx_template_extension.
ClassStruct
(**kwargs)[source][source]¶ Bases:
object
Class as struct.
All arguments are added to the class.
-
pyquickhelper.sphinxext.sphinx_template_extension.
depart_tpl_node
(self, node)[source][source]¶ What to do when leaving a node tpl.
-
pyquickhelper.sphinxext.sphinx_template_extension.
evaluate_template
(template, engine='jinja2', **kwargs)[source][source]¶ Evaluate a template given a list of parameters given a list of named parameters.
- Parameters
- Returns
outcome
The function uses
apply_template
.
-
pyquickhelper.sphinxext.sphinx_template_extension.
setup
(app)[source][source]¶ setup for
bigger
(sphinx)
-
class
pyquickhelper.sphinxext.sphinx_template_extension.
tpl_node
(rawsource='', text='', *children, **attributes)[source][source]¶ Bases:
docutils.nodes.TextElement
Defines tpl node.
-
pyquickhelper.sphinxext.sphinx_template_extension.
tpl_role
(role, rawtext, text, lineno, inliner, options=None, content=None)[source][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.