sphinx: integrate standalone vytask command in conf.py

References to VyOS Phabricator can now be build by using the statemenmt: :vytask:`T1234`
This commit is contained in:
Robert Göhler 2019-12-29 10:43:13 +01:00 committed by Christian Poessinger
parent 21aec14168
commit addb616f6c

View File

@ -16,6 +16,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from docutils import nodes, utils
from docutils.parsers.rst.roles import set_classes
# -- Project information -----------------------------------------------------
@ -169,6 +171,22 @@ texinfo_documents = [
'Miscellaneous'),
]
def vytask_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
app = inliner.document.settings.env.app
base = app.config.vyos_phabricator_url
ref = base + str(text)
set_classes(options)
node = nodes.reference(
rawtext, utils.unescape(str(text)), refuri=ref, **options)
return [node], []
def setup(app):
app.add_config_value(
'vyos_phabricator_url',
'https://phabricator.vyos.net/', ''
)
app.add_role('vytask', vytask_role)
app.add_object_type('opcmd', 'opcmd')
app.add_object_type('cfgcmd', 'cfgcmd')