diff --git a/CHANGES b/CHANGES index 6298b494e..e36262fc1 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,9 @@ New features added the directive -- this allows you to define your document structure, but place the links yourself. + - #77: If a description environment with info field list only + contains one ``:param:`` entry, no bullet list is generated. + * Configuration: - The new ``html_add_permalinks`` config value can be used to diff --git a/sphinx/directives/desc.py b/sphinx/directives/desc.py index e6337f844..b71cf1766 100644 --- a/sphinx/directives/desc.py +++ b/sphinx/directives/desc.py @@ -137,7 +137,8 @@ def handle_doc_fields(node, env): for child in node.children: if not isinstance(child, nodes.field_list): continue - params = None + params = [] + pfield = None param_nodes = {} param_types = {} new_list = nodes.field_list() @@ -152,11 +153,8 @@ def handle_doc_fields(node, env): children = fbody.children if typdesc == '%param': if not params: + # add the field that later gets all the parameters pfield = nodes.field() - pfield += nodes.field_name('', _('Parameters')) - pfield += nodes.field_body() - params = nodes.bullet_list() - pfield[1] += params new_list += pfield dlitem = nodes.list_item() dlpar = nodes.paragraph() @@ -165,7 +163,7 @@ def handle_doc_fields(node, env): dlpar += children param_nodes[obj] = dlpar dlitem += dlpar - params += dlitem + params.append(dlitem) elif typdesc == '%type': typenodes = fbody.children if _is_only_paragraph(fbody): @@ -198,6 +196,17 @@ def handle_doc_fields(node, env): typ = fnametext.capitalize() fname[0] = nodes.Text(typ) new_list += field + if params: + if len(params) == 1: + pfield += nodes.field_name('', _('Parameter')) + pfield += nodes.field_body() + pfield[1] += params[0][0] + else: + pfield += nodes.field_name('', _('Parameters')) + pfield += nodes.field_body() + pfield[1] += nodes.bullet_list() + pfield[1][0].extend(params) + for param, type in param_types.iteritems(): if param in param_nodes: param_nodes[param][1:1] = type