aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/sphinxext.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 07:58:40 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 08:05:00 +0300
commitbcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch)
treec93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/sphinxext.py
parent1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff)
downloadydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/sphinxext.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/sphinxext.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/contrib/python/Pygments/py3/pygments/sphinxext.py b/contrib/python/Pygments/py3/pygments/sphinxext.py
index f935688f1c..a742897c0b 100644
--- a/contrib/python/Pygments/py3/pygments/sphinxext.py
+++ b/contrib/python/Pygments/py3/pygments/sphinxext.py
@@ -5,7 +5,7 @@
Sphinx extension to generate automatic documentation of lexers,
formatters and filters.
- :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -33,6 +33,8 @@ LEXERDOC = '''
%s
+ %s
+
'''
FMTERDOC = '''
@@ -119,11 +121,11 @@ class PygmentsDoc(Directive):
def write_row(*columns):
"""Format a table row"""
out = []
- for l, c in zip(column_lengths, columns):
- if c:
- out.append(c.ljust(l))
+ for length, col in zip(column_lengths, columns):
+ if col:
+ out.append(col.ljust(length))
else:
- out.append(' '*l)
+ out.append(' '*length)
return ' '.join(out)
@@ -160,7 +162,7 @@ class PygmentsDoc(Directive):
self.filenames.add(mod.__file__)
cls = getattr(mod, classname)
if not cls.__doc__:
- print("Warning: %s does not have a docstring." % classname)
+ print(f"Warning: {classname} does not have a docstring.")
docstring = cls.__doc__
if isinstance(docstring, bytes):
docstring = docstring.decode('utf8')
@@ -182,12 +184,18 @@ class PygmentsDoc(Directive):
for line in content.splitlines():
docstring += f' {line}\n'
+ if cls.version_added:
+ version_line = f'.. versionadded:: {cls.version_added}'
+ else:
+ version_line = ''
+
modules.setdefault(module, []).append((
classname,
', '.join(data[2]) or 'None',
', '.join(data[3]).replace('*', '\\*').replace('_', '\\') or 'None',
', '.join(data[4]) or 'None',
- docstring))
+ docstring,
+ version_line))
if module not in moduledocstrings:
moddoc = mod.__doc__
if isinstance(moddoc, bytes):
@@ -196,7 +204,7 @@ class PygmentsDoc(Directive):
for module, lexers in sorted(modules.items(), key=lambda x: x[0]):
if moduledocstrings[module] is None:
- raise Exception("Missing docstring for %s" % (module,))
+ raise Exception(f"Missing docstring for {module}")
heading = moduledocstrings[module].splitlines()[4].strip().rstrip('.')
out.append(MODULEDOC % (module, heading, '-'*len(heading)))
for data in lexers: