summaryrefslogtreecommitdiff
path: root/sphinx/util/docfields.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/docfields.py')
-rw-r--r--sphinx/util/docfields.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py
index c654fed32..f4eb703ce 100644
--- a/sphinx/util/docfields.py
+++ b/sphinx/util/docfields.py
@@ -6,7 +6,7 @@
"Doc fields" are reST field lists in object descriptions that will
be domain-specifically transformed to a more appealing presentation.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -53,8 +53,8 @@ class Field(object):
self.rolename = rolename
self.bodyrolename = bodyrolename
- def make_xref(self, rolename, domain, target, innernode=nodes.emphasis,
- contnode=None):
+ def make_xref(self, rolename, domain, target,
+ innernode=addnodes.literal_emphasis, contnode=None):
if not rolename:
return contnode or innernode(target, target)
refnode = addnodes.pending_xref('', refdomain=domain, refexplicit=False,
@@ -106,8 +106,6 @@ class GroupedField(Field):
def make_field(self, types, domain, items):
fieldname = nodes.field_name('', self.label)
listnode = self.list_type()
- if len(items) == 1 and self.can_collapse:
- return Field.make_field(self, types, domain, items[0])
for fieldarg, content in items:
par = nodes.paragraph()
par += self.make_xref(self.rolename, domain, fieldarg,
@@ -115,6 +113,9 @@ class GroupedField(Field):
par += nodes.Text(' -- ')
par += content
listnode += nodes.list_item('', par)
+ if len(items) == 1 and self.can_collapse:
+ fieldbody = nodes.field_body('', listnode[0][0])
+ return nodes.field('', fieldname, fieldbody)
fieldbody = nodes.field_body('', listnode)
return nodes.field('', fieldname, fieldbody)
@@ -159,7 +160,8 @@ class TypedField(GroupedField):
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
- par += self.make_xref(self.typerolename, domain, typename)
+ par += self.make_xref(self.typerolename, domain, typename,
+ addnodes.literal_emphasis)
else:
par += fieldtype
par += nodes.Text(')')