Skip to content

Commit

Permalink
Merge d4869ce into 697e325
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Jan 23, 2023
2 parents 697e325 + d4869ce commit d5a5179
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
12 changes: 12 additions & 0 deletions doc-source/changelog.rst
Expand Up @@ -2,6 +2,18 @@
Changelog
===============

3.4.0
----------------------


* Renamed :py:obj:`sphinx_toolbox.more_autodoc.variables.type_template`
to :py:obj:`sphinx_toolbox.more_autodoc.variables.old_type_template`
and replaced the original with a version using unicode codepoints
instead of reST substitutions.

* On non-ReStructuredText parsers :mod:`sphinx_toolbox.more_autodoc.variables`
and :mod:`sphinx_toolbox.more_autodoc.autonamedtuple` no longer output spurrious ``|nbsp|``.

3.3.0
----------------------

Expand Down
3 changes: 2 additions & 1 deletion sphinx_toolbox/more_autodoc/autonamedtuple.py
Expand Up @@ -398,7 +398,8 @@ def sort_members(

self.add_line(f"{a_tab}.. namedtuple-field:: {field}", sourcename)
self.add_line('', sourcename)
field_entry = [f"{a_tab}{pos})", "|nbsp|", f"**{field}**"]
# field_entry = [f"{a_tab}{pos})", "|nbsp|", f"**{field}**"]
field_entry = [f"{a_tab}{pos}) \u00A0**{field}**"]
if arg_type:
field_entry.append(f"({arg_type}\\)")
field_entry.append("--")
Expand Down
21 changes: 19 additions & 2 deletions sphinx_toolbox/more_autodoc/variables.py
Expand Up @@ -145,6 +145,7 @@
"InstanceAttributeDocumenter",
"SlotsAttributeDocumenter",
"type_template",
"old_type_template",
"get_variable_type",
"setup",
)
Expand Down Expand Up @@ -198,9 +199,9 @@ def get_variable_type(documenter: Documenter) -> str:
return ''


type_template = " **Type:** |nbsp| |nbsp| |nbsp| |nbsp| %s"
old_type_template = " **Type:** |nbsp| |nbsp| |nbsp| |nbsp| %s"
"""
Template for rendering type annotations in :class:`~.VariableDocumenter`,
Old template for rendering type annotations in :class:`~.VariableDocumenter`,
:class:`~.TypedAttributeDocumenter` and :class:`~.InstanceAttributeDocumenter`.
Renders like:
Expand All @@ -213,6 +214,22 @@ def get_variable_type(documenter: Documenter) -> str:
of any extensions using this template.
"""

type_template = " **Type:**    %s"
"""
Template for rendering type annotations in :class:`~.VariableDocumenter`,
:class:`~.TypedAttributeDocumenter` and :class:`~.InstanceAttributeDocumenter`.
Renders like:
**Type:** \u00A0\u00A0\u00A0\u00A0 :class:`str`
.. versionchanged:: 3.4.0
This template now uses the unicode codepoint for a non-breaking space,
rather than the ReStructuredText substitution used in 3.3.0 and earlier.
The old template is available as ``old_type_template``.
"""


class VariableDocumenter(DataDocumenter):
"""
Expand Down

0 comments on commit d5a5179

Please sign in to comment.