diff --git a/doc-source/changelog.rst b/doc-source/changelog.rst index 097e49a..0616914 100644 --- a/doc-source/changelog.rst +++ b/doc-source/changelog.rst @@ -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 ---------------------- diff --git a/sphinx_toolbox/more_autodoc/autonamedtuple.py b/sphinx_toolbox/more_autodoc/autonamedtuple.py index 2d88a24..d023a0d 100644 --- a/sphinx_toolbox/more_autodoc/autonamedtuple.py +++ b/sphinx_toolbox/more_autodoc/autonamedtuple.py @@ -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("--") diff --git a/sphinx_toolbox/more_autodoc/variables.py b/sphinx_toolbox/more_autodoc/variables.py index 232561d..174ff9a 100644 --- a/sphinx_toolbox/more_autodoc/variables.py +++ b/sphinx_toolbox/more_autodoc/variables.py @@ -145,6 +145,7 @@ "InstanceAttributeDocumenter", "SlotsAttributeDocumenter", "type_template", + "old_type_template", "get_variable_type", "setup", ) @@ -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: @@ -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): """