From 569eea6ee85ec4d679bb38a890c167b58ee727dd Mon Sep 17 00:00:00 2001 From: Jean Abou-Samra Date: Tue, 11 Apr 2023 16:22:28 +0200 Subject: Enable Sphinx nitpicky mode and fix warnings (#2403) --- doc/docs/api.rst | 11 ++++++++--- pygments/formatter.py | 5 +++-- pygments/lexer.py | 2 +- pygments/styles/__init__.py | 4 ++-- tox.ini | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/docs/api.rst b/doc/docs/api.rst index 07c51415..1e6cbad1 100644 --- a/doc/docs/api.rst +++ b/doc/docs/api.rst @@ -39,13 +39,14 @@ Functions from :mod:`pygments.formatters`: .. autofunction:: get_formatter_for_filename .. autofunction:: load_formatter_from_file + .. module:: pygments.styles Functions from :mod:`pygments.styles`: .. autofunction:: get_style_by_name .. autofunction:: get_all_styles - +.. autodata:: STYLE_MAP .. module:: pygments.lexer @@ -78,8 +79,8 @@ A formatter is derived from this class: .. module:: pygments.util -Option processing -================= +Utilities +========= The :mod:`pygments.util` module has some utility functions usable for processing command line options. All of the following functions get values from a @@ -92,3 +93,7 @@ converted to the expected type if possible. .. autofunction:: get_int_opt .. autofunction:: get_list_opt .. autofunction:: get_choice_opt + +It also defines an exception: + +.. autoexception:: ClassNotFound diff --git a/pygments/formatter.py b/pygments/formatter.py index 2f991c76..87183abb 100644 --- a/pygments/formatter.py +++ b/pygments/formatter.py @@ -27,7 +27,8 @@ class Formatter: Converts a token stream to text. Formatters should have attributes to help selecting them. These - are similar to the corresponding :class:`lexer.Lexer` attributes. + are similar to the corresponding :class:`~pygments.lexer.Lexer` + attributes. .. autoattribute:: name :no-value: @@ -70,7 +71,7 @@ class Formatter: #: the formatter from a list, e.g. using :func:`.get_formatter_by_name()`. aliases = [] - #: A list of :mod:`fnmatch` patterns that match filenames for which this + #: A list of fnmatch patterns that match filenames for which this #: formatter can produce output. The patterns in this list should be unique #: among all formatters. filenames = [] diff --git a/pygments/lexer.py b/pygments/lexer.py index 7c596719..6f4918c9 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -145,7 +145,7 @@ class Lexer(metaclass=LexerMeta): As these options must all be specifiable as strings (due to the command line usage), there are various utility functions - available to help with that, see `Option processing`_. + available to help with that, see `Utilities`_. """ self.options = options self.stripnl = get_bool_opt(options, 'stripnl', True) diff --git a/pygments/styles/__init__.py b/pygments/styles/__init__.py index 34744c6a..d563baa4 100644 --- a/pygments/styles/__init__.py +++ b/pygments/styles/__init__.py @@ -11,8 +11,8 @@ from pygments.plugin import find_plugin_styles from pygments.util import ClassNotFound - -#: Maps style names to 'submodule::classname'. +#: A dictionary of built-in styles, mapping style names to +#: ``'submodule::classname'`` strings. STYLE_MAP = { 'default': 'default::DefaultStyle', 'emacs': 'emacs::EmacsStyle', diff --git a/tox.ini b/tox.ini index 1dcc73a7..56bce5be 100644 --- a/tox.ini +++ b/tox.ini @@ -73,7 +73,7 @@ deps = sphinx wcag-contrast-ratio commands = - sphinx-build -b {posargs:html} {env:SPHINXOPTS} . _build/{posargs:html} + sphinx-build -b {posargs:html} -n {env:SPHINXOPTS} . _build/{posargs:html} [testenv:web-doc] -- cgit v1.2.1