Skip to content

Commit

Permalink
Merge pull request #9282 from tk0miya/9280_exceptions
Browse files Browse the repository at this point in the history
Fix #9280: py domain: "exceptions" module is not displayed
  • Loading branch information
tk0miya committed May 30, 2021
2 parents 7dbe8eb + 201f61f commit 5c27519
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -59,6 +59,7 @@ Bugs fixed
* #9270: html theme : pyramid theme generates incorrect logo links
* #9217: manpage: The name of manpage directory that is generated by
:confval:`man_make_section_directory` is not correct
* #9280: py domain: "exceptions" module is not displayed
* #9224: ``:param:`` and ``:type:`` fields does not support a type containing
whitespace (ex. ``Dict[str, str]``)

Expand Down
9 changes: 3 additions & 6 deletions sphinx/domains/python.py
Expand Up @@ -448,12 +448,9 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]

if prefix:
signode += addnodes.desc_addname(prefix, prefix)
elif add_module and self.env.config.add_module_names:
if modname and modname != 'exceptions':
# exceptions are a special case, since they are documented in the
# 'exceptions' module.
nodetext = modname + '.'
signode += addnodes.desc_addname(nodetext, nodetext)
elif modname and add_module and self.env.config.add_module_names:
nodetext = modname + '.'
signode += addnodes.desc_addname(nodetext, nodetext)

signode += addnodes.desc_name(name, name)
if arglist:
Expand Down
16 changes: 2 additions & 14 deletions tests/test_domain_py.py
Expand Up @@ -477,23 +477,11 @@ def test_optional_pyfunction_signature(app):


def test_pyexception_signature(app):
text = ".. py:exception:: exceptions.IOError"
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index,
[desc, ([desc_signature, ([desc_annotation, "exception "],
[desc_addname, "exceptions."],
[desc_name, "IOError"])],
desc_content)]))
assert_node(doctree[1], desc, desctype="exception",
domain="py", objtype="exception", noindex=False)


def test_exceptions_module_is_ignored(app):
text = (".. py:exception:: IOError\n"
" :module: exceptions\n")
text = ".. py:exception:: builtins.IOError"
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index,
[desc, ([desc_signature, ([desc_annotation, "exception "],
[desc_addname, "builtins."],
[desc_name, "IOError"])],
desc_content)]))
assert_node(doctree[1], desc, desctype="exception",
Expand Down

0 comments on commit 5c27519

Please sign in to comment.