Added function to automatically extract documentation from interface field properties dev-dc
authorThierry Florac <thierry.florac@onf.fr>
Thu, 12 Apr 2018 11:11:15 +0200
branchdev-dc
changeset 45 918d3c9b53ee
parent 41 9379f4e44a5a (diff)
parent 44 915602c1fb3a (current diff)
child 46 5fe8d5ffccde
Added function to automatically extract documentation from interface field properties
src/source/conf.py
src/source/pyams_portal/pyams_portal.zmi.portlets.rst
--- a/src/source/conf.py	Mon Apr 09 17:40:10 2018 +0200
+++ b/src/source/conf.py	Thu Apr 12 11:11:15 2018 +0200
@@ -221,3 +221,17 @@
 epub_exclude_files = ['search.html']
 
 
+try:
+    from zope.schema.fieldproperty import FieldProperty
+except ImportError:
+    raise
+else:
+    def get_field_doc(self):
+        field = self._FieldProperty__field
+        if field.title and field.description:
+            return '{0}: {1}'.format(field.title, field.description)
+        elif field.title:
+            return field.title
+        else:
+            return super(self.__class__, self).__doc__
+    FieldProperty.__doc__ = property(get_field_doc)