Issues

Issue #1203 resolved

Unknown field names without arguments are transformed with a trailing space

Rob Ruana
created an issue

When an unknown field name is encountered in a python docstring, a space is appended to the field name by the sphinx.util.docfields.DocFieldTransformer. The following docstring:

def func_with_unknown_field():
    """Demonstrate unknown field transformation

       :Field_Name: Field Value

    """
    pass

Yields the following incorrect HTML for Field_Name:

<table rules="none" frame="void" class="docutils field-list">
  <colgroup>
    <col class="field-name">
    <col class="field-body">
  </colgroup>
  <tbody valign="top">
    <tr class="field-odd field">
      <th class="field-name">Field_name :</th>
      <td class="field-body">Field Value</td>
    </tr>
  </tbody>
</table>

Note the extra space in Field_name :.

See the reStructuredText Markup Spec regarding field lists.

For examples of this bug in action, see the "Returns" and "Parameters" field names in the NumPy documentation.

Comments (6)

  1. Georg Brandl repo owner

    Fix #1203: Does not append space to unknown field names.

    If an unknown field name is encountered, a space is only appended if the field arguments are not empty. Also, only the first character of the field name is upper cased, and the case of the rest of the string remains unchanged.

    → <<cset 99289a20ecf3>>

  2. Log in to comment