Fix #9630: autosummary: Failed to build summary table if primary_domain is not 'py'

Autosummary generates reST code that uses raw `:obj:` xrefs to refer
the python objects in the summary table.  But they're fragile because
they assume the primary_domain=='py'.

This adds `:py:` prefix to these xrefs to make them robust.
This commit is contained in:
Takeshi KOMIYA 2021-09-14 23:44:14 +09:00
parent ed227d7d3c
commit bc012076b8
2 changed files with 4 additions and 2 deletions

View File

@ -18,6 +18,8 @@ Bugs fixed
* #9630: autodoc: Failed to build cross references if :confval:`primary_domain` * #9630: autodoc: Failed to build cross references if :confval:`primary_domain`
is not 'py' is not 'py'
* #9630: autosummary: Failed to build summary table if :confval:`primary_domain`
is not 'py'
Testing Testing
-------- --------

View File

@ -444,9 +444,9 @@ class Autosummary(SphinxDirective):
for name, sig, summary, real_name in items: for name, sig, summary, real_name in items:
qualifier = 'obj' qualifier = 'obj'
if 'nosignatures' not in self.options: if 'nosignatures' not in self.options:
col1 = ':%s:`%s <%s>`\\ %s' % (qualifier, name, real_name, rst.escape(sig)) col1 = ':py:%s:`%s <%s>`\\ %s' % (qualifier, name, real_name, rst.escape(sig))
else: else:
col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name) col1 = ':py:%s:`%s <%s>`' % (qualifier, name, real_name)
col2 = summary col2 = summary
append_row(col1, col2) append_row(col1, col2)