diff options
author | Colin Walters <walters@verbum.org> | 2011-08-12 06:01:56 -0400 |
---|---|---|
committer | Johan Dahlin <jdahlin@litl.com> | 2011-08-13 09:42:38 -0300 |
commit | 1037bdc150df91abdc7c7f4e8bb278fe7e4b5cee (patch) | |
tree | 9c14141a82c48718e619e2208f7e0300ec580347 | |
parent | d3a7314ba46b32e0dc215ad7d54fbf888ac519d0 (diff) | |
download | gobject-introspection-1037bdc150df91abdc7c7f4e8bb278fe7e4b5cee.tar.gz |
scanner: Don't throw away blank lines in the docs
For generating documentation, we actually want to preserve these.
https://bugzilla.gnome.org/show_bug.cgi?id=656389
-rw-r--r-- | giscanner/annotationparser.py | 13 | ||||
-rw-r--r-- | giscanner/girparser.py | 3 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 13 | ||||
-rw-r--r-- | tests/scanner/regress.c | 16 | ||||
-rw-r--r-- | tests/scanner/regress.h | 2 |
6 files changed, 44 insertions, 5 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index ac6430d6..0d7672e4 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -492,13 +492,20 @@ class AnnotationParser(object): lineno = 2 for line in comment[pos+1:].split('\n'): line = line.lstrip() - if (not line.startswith('*') or - self.WHITESPACE_RE.match(line[1:])): + if not line.startswith('*'): + lineno += 1 + continue + is_whitespace = self.WHITESPACE_RE.match(line[1:]) is not None + if parsing_parameters and is_whitespace: # As soon as we find a line that's just whitespace, # we're done parsing the parameters. parsing_parameters = False lineno += 1 continue + elif is_whitespace: + comment_lines.append('') + lineno += 1 + continue line = line[1:].lstrip() @@ -576,7 +583,7 @@ class AnnotationParser(object): elif (not is_parameter): comment_lines.append(line) lineno += 1 - block.comment = '\n'.join(comment_lines) + block.comment = '\n'.join(comment_lines).strip() block.validate() self._blocks[block.name] = block diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 45a93ed6..51de1b15 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -199,7 +199,8 @@ class GIRParser(object): return doc = node.find(_corens('doc')) if doc is not None: - obj.doc = doc.text + if doc.text: + obj.doc = doc.text version = node.attrib.get('version') if version: obj.version = version diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 1da2417d..b3b74357 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -135,7 +135,7 @@ and/or use gtk-doc annotations. ''') self.write_tag('attribute', [('name', key), ('value', value)]) if hasattr(node, 'doc') and node.doc: self.write_tag('doc', [('xml:whitespace', 'preserve')], - node.doc.strip()) + node.doc) def _append_node_generic(self, node, attrs): if node.skip or not node.introspectable: diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index a19969e7..7e0b2e5b 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -2342,6 +2342,19 @@ call and can be released on return.</doc> </parameter> </parameters> </function> + <function name="test_multiline_doc_comments" + c:identifier="regress_test_multiline_doc_comments"> + <doc xml:whitespace="preserve">This is a function. + +It has multiple lines in the documentation. + +The sky is blue. + +You will give me your credit card number.</doc> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + </function> <function name="test_short" c:identifier="regress_test_short"> <return-value transfer-ownership="none"> <type name="gshort" c:type="gshort"/> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index c6608f40..86927a05 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -3143,6 +3143,22 @@ regress_test_strv_in_gvalue (void) } /** + * regress_test_multiline_doc_comments: + * + * This is a function. + * + * It has multiple lines in the documentation. + * + * The sky is blue. + * + * You will give me your credit card number. + */ +void +regress_test_multiline_doc_comments (void) +{ +} + +/** * regress_introspectable_via_alias: * */ diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 04ebe29e..7b8d9de4 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -608,6 +608,8 @@ GValue *regress_test_strv_in_gvalue (void); GObject * _regress_this_is_a_private_symbol (void); +void regress_test_multiline_doc_comments (void); + /** * RegressSkippedStructure: (skip) * |