From d9cd0e4fdf5f8a7abdf773b0dd6fe2b370b5bcfc Mon Sep 17 00:00:00 2001 From: Jason Francis Date: Tue, 1 Jun 2021 23:03:33 -0400 Subject: [PATCH] docs: Write gtk-doc comments for constant variables --- docs/gen-api-gtkdoc.py | 30 ++++++++++++++++++++++++++++++ docs/meson.build | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/gen-api-gtkdoc.py b/docs/gen-api-gtkdoc.py index 7248b6ad..6fd259b2 100644 --- a/docs/gen-api-gtkdoc.py +++ b/docs/gen-api-gtkdoc.py @@ -327,6 +327,33 @@ class DoxyFunction(DoxyElement): return e +class DoxyVariable(DoxyElement): + @staticmethod + def from_memberdef(xml): + name = xml.find("name").text + d = normalize_text(xml.find("definition").text) + d += ";" + e = DoxyVariable(name, d) + e.add_brief(xml.find("briefdescription")) + t = xml.find("type") + if t is not None: + typestr = "".join(t.itertext()).strip() + if typestr.startswith("const "): + typestr = typestr[6:] + e.type = "("+typestr+") " + else: + e.type = "" + v = xml.find("initializer") + e.value = v.text.replace("=","").replace("\n","") if v is not None else "" + return e + def to_gtkdoc(self): + s = super().to_gtkdoc() + # need this to get g-ir-scanner to recognize this as a constant + s += "#define "+self.name+" ("+self.type+self.value+")\n" + s += "#undef "+self.name+"\n" + return s + + def main(args): xml_dir = None outfile = None @@ -361,6 +388,9 @@ def main(args): for n1 in n0.xpath(".//*/memberdef[@kind='function']"): e = DoxyFunction.from_memberdef(n1) symbols.append(e) + for n1 in n0.xpath(".//*/memberdef[@kind='variable']"): + e = DoxyVariable.from_memberdef(n1) + symbols.append(e) if (opts.outfile): try: diff --git a/docs/meson.build b/docs/meson.build index 67d60848..5d2ab0f9 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -128,7 +128,7 @@ if build_gir dependencies: [wp_dep, dummy_dep], namespace: 'Wp', nsversion: wireplumber_api_version, - sources: [wpenums_h, wp_lib_headers, wp_gtkdoc_h], + sources: [wpenums_h, wp_gtkdoc_h, wp_lib_headers], include_directories: [wpenums_include_dir], includes: ['GLib-2.0', 'GObject-2.0', 'Gio-2.0'], install: true,