[geany/geany] 5a391c: Replace comments and asserts with doc-comments and doc-tests

Matthew Brush git-noreply at xxxxx
Tue Feb 16 05:52:09 UTC 2016


Branch:      refs/heads/master
Author:      Matthew Brush <mbrush at codebrainz.ca>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Tue, 16 Feb 2016 05:52:09 UTC
Commit:      5a391c79c3db13f8ee8e1a4279373b3652c7d4d0
             https://github.com/geany/geany/commit/5a391c79c3db13f8ee8e1a4279373b3652c7d4d0

Log Message:
-----------
Replace comments and asserts with doc-comments and doc-tests


Modified Paths:
--------------
    scripts/gen-api-gtkdoc.py

Modified: scripts/gen-api-gtkdoc.py
32 lines changed, 21 insertions(+), 11 deletions(-)
===================================================================
@@ -6,23 +6,33 @@
 from lxml import etree
 from optparse import OptionParser
 
-# " asd\nxxx  " => "asd xxx"
 def normalize_text(s):
-    return s.replace("\n", " ").lstrip().rstrip()
+    r"""
+    Normalizes whitespace in text.
 
-assert(normalize_text("asd xxx") == "asd xxx")
-assert(normalize_text(" asd\nxxx  ") == "asd xxx")
+    >>> normalize_text("asd xxx")
+    'asd xxx'
+    >>> normalize_text(" asd\nxxx  ")
+    'asd xxx'
+    """
+    return s.replace("\n", " ").strip()
 
-# doxygen records some definitions in C++ style, fix those
-# "bool FooBar::flag" => "bool flag"
-# void(* _GeanyObjectClass::project_open) (GKeyFile *keyfile) => void(* project_open) (GKeyFile *keyfile)
 CXX_NAMESPACE_RE = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*::')
 def fix_definition(s):
-    return CXX_NAMESPACE_RE.sub(r"", s);
+    """
+    Removes C++ name qualifications from some definitions.
+
+    For example:
 
-assert(fix_definition("bool flag") == "bool flag")
-assert(fix_definition("bool FooBar::flag") == "bool flag")
-assert(fix_definition("void(* _GeanyObjectClass::project_open) (GKeyFile *keyfile)") == "void(* project_open) (GKeyFile *keyfile)")
+    >>> fix_definition("bool flag")
+    'bool flag'
+    >>> fix_definition("bool FooBar::flag")
+    'bool flag'
+    >>> fix_definition("void(* _GeanyObjectClass::project_open) (GKeyFile *keyfile)")
+    'void(* project_open) (GKeyFile *keyfile)'
+
+    """
+    return CXX_NAMESPACE_RE.sub(r"", s);
 
 class AtAt(object):
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list