Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: reformat Sphinx conf.py files #16301

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions doc/developer/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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,
Expand Down Expand Up @@ -53,18 +54,18 @@
master_doc = "index"

# General information about the project.
project = u"FRR"
copyright = u"2017, FRR"
author = u"FRR authors"
project = "FRR"
copyright = "2017, FRR"
author = "FRR authors"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

# The short X.Y version.
version = u"?.?"
version = "?.?"
# The full version, including alpha/beta/rc tags.
release = u"?.?-?"
release = "?.?-?"


# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -287,7 +288,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "FRR.tex", u"FRR Developer's Manual", u"FRR", "manual"),
(master_doc, "FRR.tex", "FRR Developer's Manual", "FRR", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -315,7 +316,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "frr", u"FRR Developer's Manual", [author], 1)]
man_pages = [(master_doc, "frr", "FRR Developer's Manual", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -330,7 +331,7 @@
(
master_doc,
"frr",
u"FRR Developer's Manual",
"FRR Developer's Manual",
author,
"FRR",
"One line description of project.",
Expand Down Expand Up @@ -358,27 +359,29 @@
with open("../extra/frrlexer.py", "rb") as lex:
frrlexerpy = lex.read()

frrfmt_re = re.compile(r'^\s*%(?P<spec>[^\s]+)\s+\((?P<types>.*)\)\s*$')
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)
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')
spec, types = m.group("spec"), m.group("types")

node += addnodes.desc_sig_operator('%', '%')
node += addnodes.desc_name(spec + ' ', spec + ' ')
node += addnodes.desc_sig_operator("%", "%")
node += addnodes.desc_name(spec + " ", spec + " ")
plist = addnodes.desc_parameterlist()
for typ in types.split(','):
for typ in types.split(","):
typ = typ.strip()
plist += addnodes.desc_parameter(typ, typ)
node += plist
return '%' + spec
return "%" + spec


# custom extensions here
def setup(app):
Expand Down
22 changes: 12 additions & 10 deletions doc/user/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@
master_doc = "index"

# General information about the project.
project = u"FRR"
copyright = u"2017, FRR"
author = u"FRR authors"
project = "FRR"
copyright = "2017, FRR"
author = "FRR authors"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

# The short X.Y version.
version = u"?.?"
version = "?.?"
# The full version, including alpha/beta/rc tags.
release = u"?.?-?"
release = "?.?-?"


# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -287,7 +287,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "FRR.tex", u"FRR User Manual", u"FRR", "manual"),
(master_doc, "FRR.tex", "FRR User Manual", "FRR", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -315,7 +315,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "frr", u"FRR User Manual", [author], 1)]
man_pages = [(master_doc, "frr", "FRR User Manual", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -330,7 +330,7 @@
(
master_doc,
"frr",
u"FRR User Manual",
"FRR User Manual",
author,
"FRR",
"One line description of project.",
Expand Down Expand Up @@ -358,6 +358,7 @@
with open("../extra/frrlexer.py", "rb") as lex:
frrlexerpy = lex.read()


# Parse version string into int array
def vparse(s):
a = []
Expand All @@ -376,7 +377,9 @@ def vparse(s):
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", indextemplate="pair: %s; configuration command")
app.add_object_type(
"clicmd", "clicmd", indextemplate="pair: %s; configuration command"
)

# I dont care how stupid this is
if "add_js_file" in dir(app):
Expand All @@ -389,7 +392,6 @@ def setup(app):
else:
app.add_stylesheet("overrides.css")


# load Pygments lexer for FRR config syntax
#
# NB: in Pygments 2.2+ this can be done with `load_lexer_from_file`, but we
Expand Down
Loading