mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '3.1.x' into 7812_broken_stubs_for_same_qualname_entries
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -16,8 +16,10 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #7808: autodoc: Warnings raised on variable and attribute type annotations
|
||||
* #7812: autosummary: generates broken stub files if the target code contains
|
||||
an attribute and module that are same name
|
||||
* #7811: sphinx.util.inspect causes circular import problem
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -623,7 +623,8 @@ class PyVariable(PyObject):
|
||||
|
||||
typ = self.options.get('type')
|
||||
if typ:
|
||||
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), type_to_xref(typ))
|
||||
annotations = _parse_annotation(typ)
|
||||
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), *annotations)
|
||||
|
||||
value = self.options.get('value')
|
||||
if value:
|
||||
@@ -868,7 +869,8 @@ class PyAttribute(PyObject):
|
||||
|
||||
typ = self.options.get('type')
|
||||
if typ:
|
||||
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), type_to_xref(typ))
|
||||
annotations = _parse_annotation(typ)
|
||||
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), *annotations)
|
||||
|
||||
value = self.options.get('value')
|
||||
if value:
|
||||
|
||||
@@ -19,7 +19,6 @@ from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from sphinx.pycode.ast import ast # for py37 or older
|
||||
from sphinx.pycode.ast import parse, unparse
|
||||
from sphinx.util.inspect import signature_from_ast
|
||||
|
||||
|
||||
comment_re = re.compile('^\\s*#: ?(.*)\r?\n?$')
|
||||
@@ -262,6 +261,8 @@ class VariableCommentPicker(ast.NodeVisitor):
|
||||
self.finals.append(".".join(qualname))
|
||||
|
||||
def add_overload_entry(self, func: ast.FunctionDef) -> None:
|
||||
# avoid circular import problem
|
||||
from sphinx.util.inspect import signature_from_ast
|
||||
qualname = self.get_qualname_for(func.name)
|
||||
if qualname:
|
||||
overloads = self.overloads.setdefault(".".join(qualname), [])
|
||||
|
||||
@@ -31,7 +31,7 @@ if False:
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.domain import IndexEntry
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.utils.tags import Tags
|
||||
from sphinx.util.tags import Tags
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -679,7 +679,7 @@ def test_pyattribute(app):
|
||||
text = (".. py:class:: Class\n"
|
||||
"\n"
|
||||
" .. py:attribute:: attr\n"
|
||||
" :type: str\n"
|
||||
" :type: Optional[str]\n"
|
||||
" :value: ''\n")
|
||||
domain = app.env.get_domain('py')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@@ -692,7 +692,10 @@ def test_pyattribute(app):
|
||||
entries=[('single', 'attr (Class attribute)', 'Class.attr', '', None)])
|
||||
assert_node(doctree[1][1][1], ([desc_signature, ([desc_name, "attr"],
|
||||
[desc_annotation, (": ",
|
||||
[pending_xref, "str"])],
|
||||
[pending_xref, "Optional"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "str"],
|
||||
[desc_sig_punctuation, "]"])],
|
||||
[desc_annotation, " = ''"])],
|
||||
[desc_content, ()]))
|
||||
assert 'Class.attr' in domain.objects
|
||||
|
||||
Reference in New Issue
Block a user