mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6452: autosummary: crashed when generating document of properties
This commit is contained in:
parent
2f93300920
commit
bc5e18af92
1
CHANGES
1
CHANGES
@ -17,6 +17,7 @@ Bugs fixed
|
||||
----------
|
||||
|
||||
* #6448: autodoc: crashed when autodocumenting classes with ``__slots__ = None``
|
||||
* #6452: autosummary: crashed when generating document of properties
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -221,7 +221,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||
get_members(obj, {'attribute', 'property'})
|
||||
|
||||
parts = name.split('.')
|
||||
if doc.objtype in ('method', 'attribute'):
|
||||
if doc.objtype in ('method', 'attribute', 'property'):
|
||||
mod_name = '.'.join(parts[:-2])
|
||||
cls_name = parts[-2]
|
||||
obj_name = '.'.join(parts[-2:])
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import sys
|
||||
from io import StringIO
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -19,6 +19,7 @@ from sphinx import addnodes
|
||||
from sphinx.ext.autosummary import (
|
||||
autosummary_table, autosummary_toc, mangle_signature, import_by_name, extract_summary
|
||||
)
|
||||
from sphinx.ext.autosummary.generate import generate_autosummary_docs
|
||||
from sphinx.testing.util import assert_node, etree_parse
|
||||
from sphinx.util.docutils import new_document
|
||||
|
||||
@ -286,3 +287,18 @@ def test_autosummary_imported_members(app, status, warning):
|
||||
' \n' in module)
|
||||
finally:
|
||||
sys.modules.pop('autosummary_dummy_package', None)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='ext-autodoc')
|
||||
def test_generate_autosummary_docs_property(app):
|
||||
with patch('sphinx.ext.autosummary.generate.find_autosummary_in_files') as mock:
|
||||
mock.return_value = [('target.methods.Base.prop', 'prop', None)]
|
||||
generate_autosummary_docs([], output_dir=app.srcdir, builder=app.builder, app=app)
|
||||
|
||||
content = (app.srcdir / 'target.methods.Base.prop.rst').text()
|
||||
assert content == ("target.methods.Base.prop\n"
|
||||
"========================\n"
|
||||
"\n"
|
||||
".. currentmodule:: target.methods\n"
|
||||
"\n"
|
||||
".. autoproperty:: Base.prop")
|
||||
|
Loading…
Reference in New Issue
Block a user