diff options
| -rw-r--r-- | CHANGES.rst | 3 | ||||
| -rw-r--r-- | src/zope/schema/_bootstrapfields.py | 1 | ||||
| -rw-r--r-- | src/zope/schema/tests/test__bootstrapfields.py | 27 |
3 files changed, 31 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index a861314..d50182e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,9 @@ - Nothing changed yet. +- Fix ``Field.getDoc()`` when ``value_type`` or ``key_type`` is + present. Previously it could produce ReST that generated Sphinx + warnings. See `issue 76 <https://github.com/zopefoundation/zope.schema/issues/76>`_. 4.8.0 (2018-09-19) ================== diff --git a/src/zope/schema/_bootstrapfields.py b/src/zope/schema/_bootstrapfields.py index 0ba053f..6aa778b 100644 --- a/src/zope/schema/_bootstrapfields.py +++ b/src/zope/schema/_bootstrapfields.py @@ -397,6 +397,7 @@ class Field(Attribute): ('value_type', 'Value Type')): field = getattr(self, name, None) if hasattr(field, 'getDoc'): + lines.append("") lines.append(".. rubric:: " + rubric) lines.append(field.getDoc()) diff --git a/src/zope/schema/tests/test__bootstrapfields.py b/src/zope/schema/tests/test__bootstrapfields.py index c8bb2b0..021377e 100644 --- a/src/zope/schema/tests/test__bootstrapfields.py +++ b/src/zope/schema/tests/test__bootstrapfields.py @@ -420,6 +420,33 @@ class FieldTests(EqualityTestsMixin, self.assertIn('.. rubric:: Key Type', doc) self.assertIn('.. rubric:: Value Type', doc) + self.assertEqual( + field.getDoc(), + textwrap.dedent(""" + :Implementation: :class:`zope.schema.Field` + :Read Only: True + :Required: False + :Default Factory: 'default' + :Allowed Type: :class:`str`, :class:`object` + + .. rubric:: Key Type + + :Implementation: :class:`zope.schema.Field` + :Read Only: False + :Required: True + :Default Value: None + + + .. rubric:: Value Type + + :Implementation: :class:`zope.schema.Field` + :Read Only: False + :Required: True + :Default Value: None + + """) + ) + field = self._makeOne(title=u'A title', description=u"""Multiline description. Some lines have leading whitespace. |
