diff options
| author | Jason Madden <jamadden@gmail.com> | 2018-09-23 08:45:11 -0500 |
|---|---|---|
| committer | Jason Madden <jamadden@gmail.com> | 2018-09-23 08:45:11 -0500 |
| commit | 295aa9325e752f4c8596f5941b25d0a499e9c383 (patch) | |
| tree | 0ed54c120ccb26e29ce32f04b674ea9c83d84ea6 | |
| parent | d78c57c3c9ab8608fda1c1213c64d1666db770e2 (diff) | |
| download | zope-schema-issue76.tar.gz | |
Fix Field.getDoc() when value_type or key_type are presentissue76
Fixes #76
| -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. |
