Skip to content

Commit fe47bf4

Browse files
authored
Merge pull request #9470 from lmmx/4.x
Reviewed all docstrings to improve readability and correctness
2 parents 05cce83 + 10dba79 commit fe47bf4

31 files changed

+157
-148
lines changed

sphinx/application.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def __init__(self, srcdir: str, confdir: Optional[str], outdir: str, doctreedir:
197197

198198
# notice for parallel build on macOS and py38+
199199
if sys.version_info > (3, 8) and platform.system() == 'Darwin' and parallel > 1:
200-
logger.info(bold(__("For security reason, parallel mode is disabled on macOS and "
200+
logger.info(bold(__("For security reasons, parallel mode is disabled on macOS and "
201201
"python3.8 and above. For more details, please read "
202202
"https://github.com/sphinx-doc/sphinx/issues/6803")))
203203

@@ -415,7 +415,7 @@ def connect(self, event: str, callback: Callable, priority: int = 500) -> int:
415415
:param event: The name of target event
416416
:param callback: Callback function for the event
417417
:param priority: The priority of the callback. The callbacks will be invoked
418-
in the order of *priority* in asending.
418+
in order of *priority* (ascending).
419419
:return: A listener ID. It can be used for :meth:`disconnect`.
420420
421421
.. versionchanged:: 3.0
@@ -493,7 +493,7 @@ def add_config_value(self, name: str, default: Any, rebuild: Union[bool, str],
493493
values accordingly.
494494
495495
496-
:param name: The name of configuration value. It is recommended to be prefixed
496+
:param name: The name of the configuration value. It is recommended to be prefixed
497497
with the extension name (ex. ``html_logo``, ``epub_title``)
498498
:param default: The default value of the configuration.
499499
:param rebuild: The condition of rebuild. It must be one of those values:
@@ -539,10 +539,10 @@ def set_translator(self, name: str, translator_class: Type[nodes.NodeVisitor],
539539
"""Register or override a Docutils translator class.
540540
541541
This is used to register a custom output translator or to replace a
542-
builtin translator. This allows extensions to use custom translator
542+
builtin translator. This allows extensions to use a custom translator
543543
and define custom nodes for the translator (see :meth:`add_node`).
544544
545-
:param name: The name of builder for the translator
545+
:param name: The name of the builder for the translator
546546
:param translator_class: A translator class
547547
:param override: If true, install the translator forcedly even if another translator
548548
is already installed as the same name
@@ -606,11 +606,11 @@ def add_enumerable_node(self, node: Type[Element], figtype: str,
606606
using :rst:role:`numref`.
607607
608608
:param node: A node class
609-
:param figtype: The type of enumerable nodes. Each figtypes have individual numbering
610-
sequences. As a system figtypes, ``figure``, ``table`` and
611-
``code-block`` are defined. It is able to add custom nodes to these
612-
default figtypes. It is also able to define new custom figtype if new
613-
figtype is given.
609+
:param figtype: The type of enumerable nodes. Each figtype has individual numbering
610+
sequences. As system figtypes, ``figure``, ``table`` and
611+
``code-block`` are defined. It is possible to add custom nodes to
612+
these default figtypes. It is also possible to define new custom
613+
figtype if a new figtype is given.
614614
:param title_getter: A getter function to obtain the title of node. It takes an
615615
instance of the enumerable node, and it must return its title as
616616
string. The title is used to the default title of references for
@@ -629,7 +629,7 @@ def add_enumerable_node(self, node: Type[Element], figtype: str,
629629
def add_directive(self, name: str, cls: Type[Directive], override: bool = False) -> None:
630630
"""Register a Docutils directive.
631631
632-
:param name: The name of directive
632+
:param name: The name of the directive
633633
:param cls: A directive class
634634
:param override: If true, install the directive forcedly even if another directive
635635
is already installed as the same name
@@ -755,9 +755,9 @@ def add_role_to_domain(self, domain: str, name: str, role: Union[RoleFunction, X
755755
Like :meth:`add_role`, but the role is added to the domain named
756756
*domain*.
757757
758-
:param domain: The name of target domain
759-
:param name: A name of role
760-
:param role: A role function
758+
:param domain: The name of the target domain
759+
:param name: The name of the role
760+
:param role: The role function
761761
:param override: If true, install the role forcedly even if another role is already
762762
installed as the same name
763763
@@ -773,8 +773,8 @@ def add_index_to_domain(self, domain: str, index: Type[Index], override: bool =
773773
774774
Add a custom *index* class to the domain named *domain*.
775775
776-
:param domain: The name of target domain
777-
:param index: A index class
776+
:param domain: The name of the target domain
777+
:param index: The index class
778778
:param override: If true, install the index forcedly even if another index is
779779
already installed as the same name
780780
@@ -942,8 +942,8 @@ def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None
942942
Add *filename* to the list of JavaScript files that the default HTML
943943
template will include in order of *priority* (ascending). The filename
944944
must be relative to the HTML static path , or a full URI with scheme.
945-
If the priority of JavaScript file is the same as others, the JavaScript
946-
files will be included in order of the registration. If the keyword
945+
If the priority of the JavaScript file is the same as others, the JavaScript
946+
files will be included in order of registration. If the keyword
947947
argument ``body`` is given, its value will be added between the
948948
``<script>`` tags. Extra keyword arguments are included as attributes of
949949
the ``<script>`` tag.
@@ -971,7 +971,7 @@ def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None
971971
* - 800
972972
- default priority for :confval:`html_js_files`
973973
974-
A JavaScript file can be added to the specific HTML page when on extension
974+
A JavaScript file can be added to the specific HTML page when an extension
975975
calls this method on :event:`html-page-context` event.
976976
977977
.. versionadded:: 0.5
@@ -993,8 +993,8 @@ def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> Non
993993
Add *filename* to the list of CSS files that the default HTML template
994994
will include in order of *priority* (ascending). The filename must be
995995
relative to the HTML static path, or a full URI with scheme. If the
996-
priority of CSS file is the same as others, the CSS files will be
997-
included in order of the registration. The keyword arguments are also
996+
priority of the CSS file is the same as others, the CSS files will be
997+
included in order of registration. The keyword arguments are also
998998
accepted for attributes of ``<link>`` tag.
999999
10001000
Example::
@@ -1022,15 +1022,15 @@ def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> Non
10221022
* - 800
10231023
- default priority for :confval:`html_css_files`
10241024
1025-
A CSS file can be added to the specific HTML page when on extension calls
1025+
A CSS file can be added to the specific HTML page when an extension calls
10261026
this method on :event:`html-page-context` event.
10271027
10281028
.. versionadded:: 1.0
10291029
10301030
.. versionchanged:: 1.6
10311031
Optional ``alternate`` and/or ``title`` attributes can be supplied
1032-
with the *alternate* (of boolean type) and *title* (a string)
1033-
arguments. The default is no title and *alternate* = ``False``. For
1032+
with the arguments *alternate* (a Boolean) and *title* (a string).
1033+
The default is no title and *alternate* = ``False``. For
10341034
more information, refer to the `documentation
10351035
<https://mdn.io/Web/CSS/Alternative_style_sheets>`__.
10361036
@@ -1051,7 +1051,7 @@ def add_latex_package(self, packagename: str, options: str = None,
10511051
r"""Register a package to include in the LaTeX source code.
10521052
10531053
Add *packagename* to the list of packages that LaTeX source code will
1054-
include. If you provide *options*, it will be taken to `\usepackage`
1054+
include. If you provide *options*, it will be taken to the `\usepackage`
10551055
declaration. If you set *after_hyperref* truthy, the package will be
10561056
loaded after ``hyperref`` package.
10571057
@@ -1087,7 +1087,7 @@ def add_autodocumenter(self, cls: Any, override: bool = False) -> None:
10871087
10881088
Add *cls* as a new documenter class for the :mod:`sphinx.ext.autodoc`
10891089
extension. It must be a subclass of
1090-
:class:`sphinx.ext.autodoc.Documenter`. This allows to auto-document
1090+
:class:`sphinx.ext.autodoc.Documenter`. This allows auto-documenting
10911091
new types of objects. See the source of the autodoc module for
10921092
examples on how to subclass :class:`Documenter`.
10931093
@@ -1140,10 +1140,10 @@ def add_source_suffix(self, suffix: str, filetype: str, override: bool = False)
11401140
"""Register a suffix of source files.
11411141
11421142
Same as :confval:`source_suffix`. The users can override this
1143-
using the setting.
1143+
using the config setting.
11441144
11451145
If *override* is True, the given *suffix* is forcedly installed even if
1146-
a same suffix is already installed.
1146+
the same suffix is already installed.
11471147
11481148
.. versionadded:: 1.8
11491149
"""
@@ -1204,8 +1204,8 @@ def add_html_math_renderer(self, name: str,
12041204
def add_message_catalog(self, catalog: str, locale_dir: str) -> None:
12051205
"""Register a message catalog.
12061206
1207-
:param catalog: A name of catalog
1208-
:param locale_dir: The base path of message catalog
1207+
:param catalog: The name of the catalog
1208+
:param locale_dir: The base path of the message catalog
12091209
12101210
For more details, see :func:`sphinx.locale.get_translation()`.
12111211
@@ -1216,7 +1216,7 @@ def add_message_catalog(self, catalog: str, locale_dir: str) -> None:
12161216

12171217
# ---- other methods -------------------------------------------------
12181218
def is_parallel_allowed(self, typ: str) -> bool:
1219-
"""Check parallel processing is allowed or not.
1219+
"""Check whether parallel processing is allowed or not.
12201220
12211221
:param typ: A type of processing; ``'read'`` or ``'write'``.
12221222
"""

sphinx/config.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def is_serializable(obj: Any) -> bool:
5656

5757

5858
class ENUM:
59-
"""represents the config value should be a one of candidates.
59+
"""Represents the candidates which a config value should be one of.
6060
6161
Example:
6262
app.add_config_value('latex_show_urls', 'no', None, ENUM('no', 'footnote', 'inline'))
@@ -215,7 +215,8 @@ def convert_overrides(self, name: str, value: Any) -> Any:
215215

216216
def pre_init_values(self) -> None:
217217
"""
218-
Initialize some limited config variables before initialize i18n and loading extensions
218+
Initialize some limited config variables before initializing i18n and loading
219+
extensions.
219220
"""
220221
variables = ['needs_sphinx', 'suppress_warnings', 'language', 'locale_dirs']
221222
for name in variables:
@@ -343,7 +344,7 @@ def eval_config_file(filename: str, tags: Optional[Tags]) -> Dict[str, Any]:
343344

344345

345346
def convert_source_suffix(app: "Sphinx", config: Config) -> None:
346-
"""This converts old styled source_suffix to new styled one.
347+
"""Convert old styled source_suffix to new styled one.
347348
348349
* old style: str or list
349350
* new style: a dict which maps from fileext to filetype
@@ -371,7 +372,7 @@ def convert_highlight_options(app: "Sphinx", config: Config) -> None:
371372
"""Convert old styled highlight_options to new styled one.
372373
373374
* old style: options
374-
* new style: dict that maps language names to options
375+
* new style: a dict which maps from language name to options
375376
"""
376377
options = config.highlight_options
377378
if options and not all(isinstance(v, dict) for v in options.values()):
@@ -392,7 +393,7 @@ def init_numfig_format(app: "Sphinx", config: Config) -> None:
392393

393394

394395
def correct_copyright_year(app: "Sphinx", config: Config) -> None:
395-
"""correct values of copyright year that are not coherent with
396+
"""Correct values of copyright year that are not coherent with
396397
the SOURCE_DATE_EPOCH environment variable (if set)
397398
398399
See https://reproducible-builds.org/specs/source-date-epoch/
@@ -405,7 +406,7 @@ def correct_copyright_year(app: "Sphinx", config: Config) -> None:
405406

406407

407408
def check_confval_types(app: "Sphinx", config: Config) -> None:
408-
"""check all values for deviation from the default value's type, since
409+
"""Check all values for deviation from the default value's type, since
409410
that can result in TypeErrors all over the place NB.
410411
"""
411412
for confval in config:
@@ -469,7 +470,7 @@ def check_primary_domain(app: "Sphinx", config: Config) -> None:
469470
def check_root_doc(app: "Sphinx", env: "BuildEnvironment", added: Set[str],
470471
changed: Set[str], removed: Set[str]) -> Set[str]:
471472
"""Adjust root_doc to 'contents' to support an old project which does not have
472-
no root_doc setting.
473+
any root_doc setting.
473474
"""
474475
if (app.config.root_doc == 'index' and
475476
'index' not in app.project.docnames and

sphinx/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,5 @@ class NoUri(Exception):
129129

130130

131131
class FiletypeNotFoundError(Exception):
132-
"Raised by get_filetype() if a filename matches no source suffix."
132+
"""Raised by get_filetype() if a filename matches no source suffix."""
133133
pass

sphinx/ext/apidoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def walk(rootpath: str, excludes: List[str], opts: Any
226226

227227

228228
def has_child_module(rootpath: str, excludes: List[str], opts: Any) -> bool:
229-
"""Check the given directory contains child modules at least one."""
229+
"""Check the given directory contains child module/s (at least one)."""
230230
for root, subs, files in walk(rootpath, excludes, opts):
231231
if files:
232232
return True

sphinx/ext/autodoc/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class Documenter:
306306
307307
A Documenter has an *option_spec* that works like a docutils directive's;
308308
in fact, it will be used to parse an auto directive's options that matches
309-
the documenter.
309+
the Documenter.
310310
"""
311311
#: name by which the directive is called (auto...) and the default
312312
#: generated directive name
@@ -331,7 +331,7 @@ def get_attr(self, obj: Any, name: str, *defargs: Any) -> Any:
331331
@classmethod
332332
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
333333
) -> bool:
334-
"""Called to see if a member can be documented by this documenter."""
334+
"""Called to see if a member can be documented by this Documenter."""
335335
raise NotImplementedError('must be implemented in subclasses')
336336

337337
def __init__(self, directive: "DocumenterBridge", name: str, indent: str = '') -> None:
@@ -552,7 +552,7 @@ def add_directive_header(self, sig: str) -> None:
552552
def get_doc(self, ignore: int = None) -> Optional[List[List[str]]]:
553553
"""Decode and return lines of the docstring(s) for the object.
554554
555-
When it returns None value, autodoc-process-docstring will not be called for this
555+
When it returns None, autodoc-process-docstring will not be called for this
556556
object.
557557
"""
558558
if ignore is not None:
@@ -643,7 +643,7 @@ def get_object_members(self, want_all: bool) -> Tuple[bool, ObjectMembers]:
643643
list of `(membername, member)` pairs of the members of *self.object*.
644644
645645
If *want_all* is True, return all members. Else, only return those
646-
members given by *self.options.members* (which may also be none).
646+
members given by *self.options.members* (which may also be None).
647647
"""
648648
warnings.warn('The implementation of Documenter.get_object_members() will be '
649649
'removed from Sphinx-6.0.', RemovedInSphinx60Warning)
@@ -820,7 +820,7 @@ def is_filtered_inherited_member(name: str, obj: Any) -> bool:
820820
def document_members(self, all_members: bool = False) -> None:
821821
"""Generate reST for member documentation.
822822
823-
If *all_members* is True, do all members, else those given by
823+
If *all_members* is True, document all members, else those given by
824824
*self.options.members*.
825825
"""
826826
# set current namespace for finding members
@@ -2382,7 +2382,7 @@ def is_runtime_instance_attribute_not_commented(self, parent: Any) -> bool:
23822382
return None
23832383

23842384
def import_object(self, raiseerror: bool = False) -> bool:
2385-
"""Check the existence of runtime instance attribute when failed to import the
2385+
"""Check the existence of runtime instance attribute after failing to import the
23862386
attribute."""
23872387
try:
23882388
return super().import_object(raiseerror=True) # type: ignore

sphinx/ext/autodoc/directive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self, env: BuildEnvironment, reporter: Reporter, options: Options,
6161
self.state = state
6262

6363
def warn(self, msg: str) -> None:
64-
warnings.warn('DocumenterBridge.warn is deprecated. Plase use sphinx.util.logging '
64+
warnings.warn('DocumenterBridge.warn is deprecated. Please use sphinx.util.logging '
6565
'module instead.',
6666
RemovedInSphinx60Warning, stacklevel=2)
6767
logger.warning(msg, location=(self.env.docname, self.lineno))
@@ -107,7 +107,7 @@ def process_documenter_options(documenter: Type[Documenter], config: Config, opt
107107

108108
def parse_generated_content(state: RSTState, content: StringList, documenter: Documenter
109109
) -> List[Node]:
110-
"""Parse a generated content by Documenter."""
110+
"""Parse an item of content generated by Documenter."""
111111
with switch_source_input(state, content):
112112
if documenter.titles_allowed:
113113
node: Element = nodes.section()
@@ -125,8 +125,8 @@ def parse_generated_content(state: RSTState, content: StringList, documenter: Do
125125
class AutodocDirective(SphinxDirective):
126126
"""A directive class for all autodoc directives. It works as a dispatcher of Documenters.
127127
128-
It invokes a Documenter on running. After the processing, it parses and returns
129-
the generated content by Documenter.
128+
It invokes a Documenter upon running. After the processing, it parses and returns
129+
the content generated by Documenter.
130130
"""
131131
option_spec = DummyOptionSpec()
132132
has_content = True

sphinx/ext/autodoc/importer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
def mangle(subject: Any, name: str) -> str:
33-
"""mangle the given name."""
33+
"""Mangle the given name."""
3434
try:
3535
if isclass(subject) and name.startswith('__') and not name.endswith('__'):
3636
return "_%s%s" % (subject.__name__, name)
@@ -41,7 +41,7 @@ def mangle(subject: Any, name: str) -> str:
4141

4242

4343
def unmangle(subject: Any, name: str) -> Optional[str]:
44-
"""unmangle the given name."""
44+
"""Unmangle the given name."""
4545
try:
4646
if isclass(subject) and not name.endswith('__'):
4747
prefix = "_%s__" % subject.__name__

sphinx/ext/autosummary/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def parse(doc: List[str], settings: Any) -> nodes.document:
568568

569569
def limited_join(sep: str, items: List[str], max_chars: int = 30,
570570
overflow_marker: str = "...") -> str:
571-
"""Join a number of strings to one, limiting the length to *max_chars*.
571+
"""Join a number of strings into one, limiting the length to *max_chars*.
572572
573573
If the string overflows this limit, replace the last fitting item by
574574
*overflow_marker*.

sphinx/io.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def get_transforms(self) -> List[Type[Transform]]:
7373
return transforms
7474

7575
def new_document(self) -> nodes.document:
76-
"""Creates a new document object which having a special reporter object good
76+
"""
77+
Creates a new document object which has a special reporter object good
7778
for logging.
7879
"""
7980
document = super().new_document()

0 commit comments

Comments
 (0)