diff options
author | Jason Madden <jason+github@nextthought.com> | 2018-09-24 12:32:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 12:32:34 -0500 |
commit | 556c475b61418473e8a8b641ada11d4efb901260 (patch) | |
tree | 6ae1108db3cc664d4b3f0a519e84a118f5f59e28 | |
parent | c8d9d479fe79e0eeb9885ba95edb6edf596a199c (diff) | |
parent | 295aa9325e752f4c8596f5941b25d0a499e9c383 (diff) | |
download | zope-schema-556c475b61418473e8a8b641ada11d4efb901260.tar.gz |
Merge pull request #77 from zopefoundation/issue76
Fix Field.getDoc() when value_type or key_type are present
-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 01773e1..be6cffa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,9 @@ ``INativeStringLine``. Previously these were just aliases for either ``Text`` (on Python 3) or ``Bytes`` (on Python 2). +- 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. |