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