mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-14 17:32:12 -05:00
Merge branch '2.0' into 7023_partial_listed_as_module_members
This commit is contained in:
commit
4e257a8084
7 files changed
+53
-13
No files matched your search
@@ -51,6 +51,7 @@ Bugs fixed
|
||||
* #6559: Wrong node-ids are generated in glossary directive
|
||||
* #6986: apidoc: misdetects module name for .so file inside module
|
||||
* #6999: napoleon: fails to parse tilde in :exc: role
|
||||
* #7019: gettext: Absolute path used in message catalogs
|
||||
* #7023: autodoc: nested partial functions are not listed
|
||||
* #7023: autodoc: partial functions imported from other modules are listed as
|
||||
module members without :impoprted-members: option
|
||||
|
||||
@@ -42,7 +42,7 @@ extras_require = {
|
||||
'sphinxcontrib-websupport',
|
||||
],
|
||||
'test': [
|
||||
'pytest',
|
||||
'pytest < 5.3.3',
|
||||
'pytest-cov',
|
||||
'html5lib',
|
||||
'flake8>=3.5.0',
|
||||
|
||||
@@ -30,7 +30,7 @@ from sphinx.util import split_index_msg, logging, status_iterator
|
||||
from sphinx.util.console import bold # type: ignore
|
||||
from sphinx.util.i18n import CatalogInfo, docname_to_domain
|
||||
from sphinx.util.nodes import extract_messages, traverse_translatable_index
|
||||
from sphinx.util.osutil import ensuredir, canon_path
|
||||
from sphinx.util.osutil import ensuredir, canon_path, relpath
|
||||
from sphinx.util.tags import Tags
|
||||
from sphinx.util.template import SphinxRenderer
|
||||
|
||||
@@ -108,7 +108,8 @@ class MsgOrigin:
|
||||
|
||||
|
||||
class GettextRenderer(SphinxRenderer):
|
||||
def __init__(self, template_path: str = None) -> None:
|
||||
def __init__(self, template_path: str = None, outdir: str = None) -> None:
|
||||
self.outdir = outdir
|
||||
if template_path is None:
|
||||
template_path = path.join(package_dir, 'templates', 'gettext')
|
||||
super().__init__(template_path)
|
||||
@@ -122,6 +123,13 @@ class GettextRenderer(SphinxRenderer):
|
||||
self.env.filters['e'] = escape
|
||||
self.env.filters['escape'] = escape
|
||||
|
||||
def render(self, filename: str, context: Dict) -> str:
|
||||
def _relpath(s: str) -> str:
|
||||
return canon_path(relpath(s, self.outdir))
|
||||
|
||||
context['relpath'] = _relpath
|
||||
return super().render(filename, context)
|
||||
|
||||
|
||||
class I18nTags(Tags):
|
||||
"""Dummy tags module for I18nBuilder.
|
||||
@@ -297,7 +305,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
ensuredir(path.join(self.outdir, path.dirname(textdomain)))
|
||||
|
||||
context['messages'] = list(catalog)
|
||||
content = GettextRenderer().render('message.pot_t', context)
|
||||
content = GettextRenderer(outdir=self.outdir).render('message.pot_t', context)
|
||||
|
||||
pofn = path.join(self.outdir, textdomain + '.pot')
|
||||
if should_write(pofn, content):
|
||||
|
||||
+3
-1
@@ -394,8 +394,10 @@ class GUILabel(SphinxRole):
|
||||
|
||||
|
||||
class MenuSelection(GUILabel):
|
||||
BULLET_CHARACTER = '\N{TRIANGULAR BULLET}'
|
||||
|
||||
def run(self) -> Tuple[List[Node], List[system_message]]:
|
||||
self.text = self.text.replace('-->', '\N{TRIANGULAR BULLET}')
|
||||
self.text = self.text.replace('-->', self.BULLET_CHARACTER)
|
||||
return super().run()
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ msgstr ""
|
||||
{% for message in messages %}
|
||||
{% if display_location -%}
|
||||
{% for source, line in message.locations -%}
|
||||
#: {{ source }}:{{ line }}
|
||||
#: {{ relpath(source) }}:{{ line }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ class Cell(object):
|
||||
#: Make a cell alive.
|
||||
set_alive = partialmethod(set_state, True)
|
||||
|
||||
# a partialmethod with no docstring
|
||||
set_dead = partialmethod(set_state, False)
|
||||
"""Make a cell dead."""
|
||||
+35
-6
@@ -1341,12 +1341,6 @@ def test_partialmethod(app):
|
||||
' Make a cell alive.',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: Cell.set_dead()',
|
||||
' :module: target.partialmethod',
|
||||
' ',
|
||||
' Make a cell dead.',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: Cell.set_state(state)',
|
||||
' :module: target.partialmethod',
|
||||
' ',
|
||||
@@ -1359,6 +1353,41 @@ def test_partialmethod(app):
|
||||
assert list(actual) == expected
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_partialmethod_undoc_members(app):
|
||||
expected = [
|
||||
'',
|
||||
'.. py:class:: Cell',
|
||||
' :module: target.partialmethod',
|
||||
'',
|
||||
' An example for partialmethod.',
|
||||
' ',
|
||||
' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: Cell.set_alive()',
|
||||
' :module: target.partialmethod',
|
||||
' ',
|
||||
' Make a cell alive.',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: Cell.set_dead()',
|
||||
' :module: target.partialmethod',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: Cell.set_state(state)',
|
||||
' :module: target.partialmethod',
|
||||
' ',
|
||||
' Update state of cell to *state*.',
|
||||
' ',
|
||||
]
|
||||
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.partialmethod.Cell', options)
|
||||
assert list(actual) == expected
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='pycode-egg')
|
||||
def test_autodoc_for_egged_code(app):
|
||||
options = {"members": None,
|
||||
|
||||
Reference in new issue
Block a user