Commits

Georg Brandl  committed af69933

Regression of #77: If there is only one parameter given with ``:param:`` markup, the bullet list is now suppressed again.

  • Participants
  • Parent commits a653015

Comments (0)

Files changed (4)

 Release 1.0.6 (in development)
 ==============================
 
+* Regression of #77: If there is only one parameter given with
+  ``:param:`` markup, the bullet list is now suppressed again.
+
 * #556: Fix missing paragraph breaks in LaTeX output in certain
   situations.
 

File sphinx/domains/python.py

         TypedField('parameter', label=l_('Parameters'),
                    names=('param', 'parameter', 'arg', 'argument',
                           'keyword', 'kwarg', 'kwparam'),
-                   typerolename='obj', typenames=('paramtype', 'type')),
+                   typerolename='obj', typenames=('paramtype', 'type'),
+                   can_collapse=True),
         TypedField('variable', label=l_('Variables'), rolename='obj',
                    names=('var', 'ivar', 'cvar'),
-                   typerolename='obj', typenames=('vartype',)),
+                   typerolename='obj', typenames=('vartype',),
+                   can_collapse=True),
         GroupedField('exceptions', label=l_('Raises'), rolename='exc',
                      names=('raises', 'raise', 'exception', 'except'),
                      can_collapse=True),

File sphinx/util/docfields.py

     is_typed = True
 
     def __init__(self, name, names=(), typenames=(), label=None,
-                 rolename=None, typerolename=None):
-        GroupedField.__init__(self, name, names, label, rolename, False)
+                 rolename=None, typerolename=None, can_collapse=False):
+        GroupedField.__init__(self, name, names, label, rolename, can_collapse)
         self.typenames = typenames
         self.typerolename = typerolename
 
     def make_field(self, types, domain, items):
-        fieldname = nodes.field_name('', self.label)
-        listnode = self.list_type()
-        for fieldarg, content in items:
+        def handle_item(fieldarg, content):
             par = nodes.paragraph()
             par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong)
             if fieldarg in types:
                 par += nodes.Text(')')
             par += nodes.Text(' -- ')
             par += content
-            listnode += nodes.list_item('', par)
-        fieldbody = nodes.field_body('', listnode)
+            return par
+
+        fieldname = nodes.field_name('', self.label)
+        if len(items) == 1 and self.can_collapse:
+            fieldarg, content = items[0]
+            bodynode = handle_item(fieldarg, content)
+        else:
+            bodynode = self.list_type()
+            for fieldarg, content in items:
+                bodynode += nodes.list_item('', handle_item(fieldarg, content))
+        fieldbody = nodes.field_body('', bodynode)
         return nodes.field('', fieldname, fieldbody)
 
 

File tests/root/objects.txt

 
 .. class:: TimeInt
 
+   Has only one parameter (triggers special behavior...)
+
    :param moo: |test|
    :type moo: |test|