PEP8 the GtkDoc header generator script a little

But use 110 as line length and leave visual operators alignment alone.
This commit is contained in:
Colomban Wendling 2016-02-28 04:49:51 +01:00
parent 871c562589
commit 00f0ce5991

View File

@ -6,6 +6,7 @@ import re
from lxml import etree
from optparse import OptionParser
def normalize_text(s):
r"""
Normalizes whitespace in text.
@ -17,6 +18,7 @@ def normalize_text(s):
"""
return s.replace("\n", " ").strip()
CXX_NAMESPACE_RE = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*::')
def fix_definition(s):
"""
@ -32,10 +34,10 @@ def fix_definition(s):
'void(* project_open) (GKeyFile *keyfile)'
"""
return CXX_NAMESPACE_RE.sub(r"", s);
return CXX_NAMESPACE_RE.sub(r"", s)
class AtAt(object):
def __init__(self):
self.retval = None
self.since = ""
@ -44,6 +46,7 @@ class AtAt(object):
def cb(type, str):
return "@%s %s" % (type, str)
class AtDoc(object):
def __init__(self):
self.retval = None
@ -52,7 +55,7 @@ class AtDoc(object):
def cb(self, type, str):
if (type == "param"):
words = str.split(" ", 2);
words = str.split(" ", 2)
self.annot = []
elif (type == "return"):
self.annot = []
@ -82,10 +85,12 @@ class AtDoc(object):
return ""
class At(object):
def __init__(self, cb):
self.cb = cb
class DoxygenProcess(object):
def __init__(self):
self.at = None
@ -179,8 +184,9 @@ class DoxygenProcess(object):
pass # parameters are handled separately in DoxyFunction::from_memberdef()
return s
class DoxyMember(object):
def __init__(self, name, brief, extra = ""):
def __init__(self, name, brief, extra=""):
self.name = name
self.brief = brief
self.extra = extra
@ -253,8 +259,8 @@ class DoxyElement(object):
s.append("")
return "\n".join(s)
class DoxyTypedef(DoxyElement):
class DoxyTypedef(DoxyElement):
@staticmethod
def from_memberdef(xml):
name = xml.find("name").text
@ -262,15 +268,15 @@ class DoxyTypedef(DoxyElement):
d += ";"
return DoxyTypedef(name, d)
class DoxyEnum(DoxyElement):
class DoxyEnum(DoxyElement):
@staticmethod
def from_memberdef(xml):
name = xml.find("name").text
d = "typedef enum {\n"
for member in xml.findall("enumvalue"):
v = member.find("initializer")
d += "\t%s%s,\n" % ( member.find("name").text, " "+v.text if v is not None else "")
d += "\t%s%s,\n" % (member.find("name").text, " "+v.text if v is not None else "")
d += "} %s;\n" % name
e = DoxyEnum(name, d)
@ -279,13 +285,13 @@ class DoxyEnum(DoxyElement):
e.add_member(p)
return e
class DoxyStruct(DoxyElement):
class DoxyStruct(DoxyElement):
@staticmethod
def from_compounddef(xml, typedefs = []):
def from_compounddef(xml, typedefs=[]):
name = xml.find("compoundname").text
section = xml.find("sectiondef")
d = "struct %s {\n" % name;
d = "struct %s {\n" % name
for p in section.findall("memberdef"):
# workaround for struct members. g-ir-scanner can't properly map struct members
# (beginning with struct GeanyFoo) to the typedef and assigns a generic type for them
@ -310,8 +316,8 @@ class DoxyStruct(DoxyElement):
e.add_member(p)
return e
class DoxyFunction(DoxyElement):
class DoxyFunction(DoxyElement):
@staticmethod
def from_memberdef(xml):
name = xml.find("name").text
@ -329,8 +335,8 @@ class DoxyFunction(DoxyElement):
e.add_return(x[0])
return e
def main(args):
def main(args):
xml_dir = None
outfile = None