module sphinxext.sphinx_epkg_extension
¶
Short summary¶
module pyquickhelper.sphinxext.sphinx_epkg_extension
Defines a way to reference a package or a page in this package.
Classes¶
class |
truncated documentation |
---|---|
Class as struct. |
|
Defines epkg node. |
Functions¶
function |
truncated documentation |
---|---|
What to do when leaving a node epkg. |
|
Defines custom role epkg. A list of supported urls must be defined in the configuration file. It wants to replace … |
|
setup for |
|
What to do when visiting a node epkg. |
Properties¶
property |
truncated documentation |
---|---|
|
Return the document root node of the tree containing this Node. |
Methods¶
method |
truncated documentation |
---|---|
All arguments are added to the class. |
Documentation¶
Defines a way to reference a package or a page in this package.
- class pyquickhelper.sphinxext.sphinx_epkg_extension.ClassStruct(**kwargs)[source]¶
Bases:
object
Class as struct.
All arguments are added to the class.
- pyquickhelper.sphinxext.sphinx_epkg_extension.depart_epkg_node(self, node)[source]¶
What to do when leaving a node epkg.
- class pyquickhelper.sphinxext.sphinx_epkg_extension.epkg_node(rawsource='', text='', *children, **attributes)[source]¶
Bases:
TextElement
Defines epkg node.
- pyquickhelper.sphinxext.sphinx_epkg_extension.epkg_role(role, rawtext, text, lineno, inliner, options=None, content=None)[source]¶
Defines custom role epkg. A list of supported urls must be defined in the configuration file. It wants to replace something like:
`to_html <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_html.html>`_
By:
:epkg:`pandas:DataFrame.to_html`
It inserts in the configuration the variable:
epkg_dictionary = {'pandas': ('http://pandas.pydata.org/pandas-docs/stable/generated/', ('http://pandas.pydata.org/pandas-docs/stable/generated/{0}.html', 1)) # 1 for one paraemter '*py': ('https://docs.python.org/3/', ('https://docs.python.org/3/library/{0}.html#{0}.{1}', 2)) }
If the module name starts with a ‘*’, the anchor does not contain it. See also epkg: cache references. If no template is found, the role will look into the list of options to see if there is one function. It must be the last one.
def my_custom_links(input): return "string to display", "url" epkg_dictionary = {'weird_package': ('http://pandas.pydata.org/pandas-docs/stable/generated/', ('http://pandas.pydata.org/pandas-docs/stable/generated/{0}.html', 1), my_custom_links)
However, it is impossible to use a function as a value in the configuration because pickle does not handle this scenario (see PicklingError on environment when config option value is a callable),
my_custom_links
needs to be replaced by:("module_where_it_is_defined.function_name", None)
. The role epkg will import it based on its name.- 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.