From f5284bd7d4774b36d9f18a8dcd2db9c68063edd9 Mon Sep 17 00:00:00 2001 From: samuraikamel <176351360+samuraikamel@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:07:20 -0800 Subject: Change gir.py's to symlink --- lib/astal/io/gir.py | 59 +---------------------------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) mode change 100644 => 120000 lib/astal/io/gir.py (limited to 'lib/astal/io/gir.py') diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py deleted file mode 100644 index f397b3e..0000000 --- a/lib/astal/io/gir.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -Vala's generated gir does not contain comments, -so we use valadoc to generate them. However, they are formatted -for valadoc and not gi-docgen so we need to fix it. -""" - -import xml.etree.ElementTree as ET -import html -import sys -import subprocess -import os - -def fix_gir(name: str, gir: str, out: str): - namespaces = { - "": "http://www.gtk.org/introspection/core/1.0", - "c": "http://www.gtk.org/introspection/c/1.0", - "glib": "http://www.gtk.org/introspection/glib/1.0", - } - for prefix, uri in namespaces.items(): - ET.register_namespace(prefix, uri) - - tree = ET.parse(gir) - root = tree.getroot() - - for doc in root.findall(".//doc", namespaces): - if doc.text: - doc.text = ( - html.unescape(doc.text).replace("", "").replace("", "") - ) - - if (inc := root.find("c:include", namespaces)) is not None: - inc.set("name", f"{name}.h") - else: - print("no c:include tag found", file=sys.stderr) - exit(1) - - tree.write(out, encoding="utf-8", xml_declaration=True) - - -def valadoc(name: str, gir: str, args: list[str]): - cmd = [os.getenv("VALADOC", "valadoc"), "-o", "docs", "--package-name", name, "--gir", gir, *args] - try: - subprocess.run(cmd, check=True, text=True, capture_output=True) - except subprocess.CalledProcessError as e: - print(e.stderr, file=sys.stderr) - exit(1) - - -if __name__ == "__main__": - name = sys.argv[1] - in_out = sys.argv[2].split(":") - args = sys.argv[3:] - - gir = in_out[0] - out = in_out[1] if len(in_out) > 1 else gir - - valadoc(name, gir, args) - fix_gir(name, gir, out) diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py new file mode 120000 index 0000000..16a3a64 --- /dev/null +++ b/lib/astal/io/gir.py @@ -0,0 +1 @@ +../../gir.py \ No newline at end of file -- cgit v1.2.3