[pygobject] docs: Skip "Constructors" header for anonymous structs
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] docs: Skip "Constructors" header for anonymous structs
- Date: Tue, 2 Sep 2014 00:06:51 +0000 (UTC)
commit 8c6cf22d74075b7169512b9e7773a511abb9b759
Author: Simon Feltman <sfeltman src gnome org>
Date: Mon Sep 1 16:48:15 2014 -0700
docs: Skip "Constructors" header for anonymous structs
Structs which don't have a size or constructor should not procuce any doc
string. The trailing "::" was causing a problem with sphinx.
gi/docstring.py | 8 ++++++--
tests/test_docstring.py | 3 ++-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gi/docstring.py b/gi/docstring.py
index 517cbd2..fec5f63 100644
--- a/gi/docstring.py
+++ b/gi/docstring.py
@@ -172,7 +172,8 @@ def _generate_callable_info_doc(info):
def _generate_class_info_doc(info):
- doc = '\n:Constructors:\n\n::\n\n' # start with \n to avoid auto indent of other lines
+ header = '\n:Constructors:\n\n::\n\n' # start with \n to avoid auto indent of other lines
+ doc = ''
if isinstance(info, StructInfo):
# Don't show default constructor for disguised (0 length) structs
@@ -185,7 +186,10 @@ def _generate_class_info_doc(info):
if method_info.is_constructor():
doc += ' ' + _generate_callable_info_doc(method_info) + '\n'
- return doc
+ if doc:
+ return header + doc
+ else:
+ return ''
def _generate_doc_dispatch(info):
diff --git a/tests/test_docstring.py b/tests/test_docstring.py
index ec1c506..aa000b4 100644
--- a/tests/test_docstring.py
+++ b/tests/test_docstring.py
@@ -78,8 +78,9 @@ class Test(unittest.TestCase):
@unittest.skipUnless(has_cairo, 'built without cairo support')
def test_private_struct_constructors(self):
+ # Structs without a size or constructor should have no constructor docs.
doc = Regress.TestBoxedPrivate.__doc__
- self.assertTrue('TestBoxedPrivate()' not in doc)
+ self.assertEqual(doc, '')
def test_array_inout_etc(self):
self.assertEqual(GIMarshallingTests.array_inout_etc.__doc__,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]