mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #77: If a description environment with info field list only
contains one ``:param:`` entry, no bullet list is generated.
This commit is contained in:
parent
78dec65bcc
commit
e2c52d6e90
3
CHANGES
3
CHANGES
@ -26,6 +26,9 @@ New features added
|
|||||||
the directive -- this allows you to define your document
|
the directive -- this allows you to define your document
|
||||||
structure, but place the links yourself.
|
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:
|
* Configuration:
|
||||||
|
|
||||||
- The new ``html_add_permalinks`` config value can be used to
|
- The new ``html_add_permalinks`` config value can be used to
|
||||||
|
@ -137,7 +137,8 @@ def handle_doc_fields(node, env):
|
|||||||
for child in node.children:
|
for child in node.children:
|
||||||
if not isinstance(child, nodes.field_list):
|
if not isinstance(child, nodes.field_list):
|
||||||
continue
|
continue
|
||||||
params = None
|
params = []
|
||||||
|
pfield = None
|
||||||
param_nodes = {}
|
param_nodes = {}
|
||||||
param_types = {}
|
param_types = {}
|
||||||
new_list = nodes.field_list()
|
new_list = nodes.field_list()
|
||||||
@ -152,11 +153,8 @@ def handle_doc_fields(node, env):
|
|||||||
children = fbody.children
|
children = fbody.children
|
||||||
if typdesc == '%param':
|
if typdesc == '%param':
|
||||||
if not params:
|
if not params:
|
||||||
|
# add the field that later gets all the parameters
|
||||||
pfield = nodes.field()
|
pfield = nodes.field()
|
||||||
pfield += nodes.field_name('', _('Parameters'))
|
|
||||||
pfield += nodes.field_body()
|
|
||||||
params = nodes.bullet_list()
|
|
||||||
pfield[1] += params
|
|
||||||
new_list += pfield
|
new_list += pfield
|
||||||
dlitem = nodes.list_item()
|
dlitem = nodes.list_item()
|
||||||
dlpar = nodes.paragraph()
|
dlpar = nodes.paragraph()
|
||||||
@ -165,7 +163,7 @@ def handle_doc_fields(node, env):
|
|||||||
dlpar += children
|
dlpar += children
|
||||||
param_nodes[obj] = dlpar
|
param_nodes[obj] = dlpar
|
||||||
dlitem += dlpar
|
dlitem += dlpar
|
||||||
params += dlitem
|
params.append(dlitem)
|
||||||
elif typdesc == '%type':
|
elif typdesc == '%type':
|
||||||
typenodes = fbody.children
|
typenodes = fbody.children
|
||||||
if _is_only_paragraph(fbody):
|
if _is_only_paragraph(fbody):
|
||||||
@ -198,6 +196,17 @@ def handle_doc_fields(node, env):
|
|||||||
typ = fnametext.capitalize()
|
typ = fnametext.capitalize()
|
||||||
fname[0] = nodes.Text(typ)
|
fname[0] = nodes.Text(typ)
|
||||||
new_list += field
|
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():
|
for param, type in param_types.iteritems():
|
||||||
if param in param_nodes:
|
if param in param_nodes:
|
||||||
param_nodes[param][1:1] = type
|
param_nodes[param][1:1] = type
|
||||||
|
Loading…
Reference in New Issue
Block a user