diff options
author | David Lamparter <equinox@diac24.net> | 2021-03-21 17:35:43 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2021-03-30 22:34:56 +0200 |
commit | 19b1a1c6a975f772b22dda9c5c42c6288e2ce459 (patch) | |
tree | ff74bd129e46bbc0a33f68c033c42c7b74f1dd0a /doc/developer/conf.py | |
parent | lib: save errno in vty_out() (diff) | |
download | frr-19b1a1c6a975f772b22dda9c5c42c6288e2ce459.tar.xz frr-19b1a1c6a975f772b22dda9c5c42c6288e2ce459.zip |
doc/developer: improve printfrr extension docs
The table is getting rather clunky, let's just break this out and make
it pretty there.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'doc/developer/conf.py')
-rw-r--r-- | doc/developer/conf.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/developer/conf.py b/doc/developer/conf.py index f4bb65ec7..20265f4aa 100644 --- a/doc/developer/conf.py +++ b/doc/developer/conf.py @@ -17,6 +17,8 @@ import os import re import pygments from sphinx.highlighting import lexers +from sphinx.util import logging +logger = logging.getLogger(__name__) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -362,11 +364,37 @@ texinfo_documents = [ with open("../extra/frrlexer.py", "rb") as lex: frrlexerpy = lex.read() +frrfmt_re = re.compile(r'^\s*%(?P<spec>[^\s]+)\s+\((?P<types>.*)\)\s*$') + +def parse_frrfmt(env, text, node): + from sphinx import addnodes + + m = frrfmt_re.match(text) + if not m: + logger.warning('could not parse frrfmt:: %r' % (text), location=node) + node += addnodes.desc_name(text, text) + return text + + spec, types = m.group('spec'), m.group('types') + + node += addnodes.desc_sig_operator('%', '%') + node += addnodes.desc_name(spec + ' ', spec + ' ') + plist = addnodes.desc_parameterlist() + for typ in types.split(','): + typ = typ.strip() + plist += addnodes.desc_parameter(typ, typ) + node += plist + return '%' + spec + # custom extensions here def setup(app): # object type for FRR CLI commands, can be extended to document parent CLI # node later on app.add_object_type("clicmd", "clicmd") + + # printfrr extensions + app.add_object_type("frrfmt", "frrfmt", parse_node=parse_frrfmt) + # css overrides for HTML theme app.add_stylesheet("overrides.css") # load Pygments lexer for FRR config syntax |