summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-11-13 00:54:14 +0100
committerGitHub <[email protected]>2024-11-13 00:54:14 +0100
commit47f04399166a1e155c7edbd83a98cd043bae2986 (patch)
treef42f67e91d18a3954563bbf96c620aada47ab85c /lib
parent5e6844e0c9b07931b13b278aa04cdc4046abeebc (diff)
parentf5284bd7d4774b36d9f18a8dcd2db9c68063edd9 (diff)
Merge pull request #73 from samuraikamel/main
Change gir.py's to use VALADOC environment variable
Diffstat (limited to 'lib')
l---------[-rw-r--r--]lib/astal/gtk4/gir.py59
l---------[-rw-r--r--]lib/astal/io/gir.py59
-rw-r--r--lib/gir.py3
3 files changed, 4 insertions, 117 deletions
diff --git a/lib/astal/gtk4/gir.py b/lib/astal/gtk4/gir.py
index 9ef680f..16a3a64 100644..120000
--- a/lib/astal/gtk4/gir.py
+++ b/lib/astal/gtk4/gir.py
@@ -1,58 +1 @@
-"""
-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
-
-
-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("<para>", "").replace("</para>", "")
- )
-
- 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 = ["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)
+../../gir.py \ No newline at end of file
diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py
index 9ef680f..16a3a64 100644..120000
--- a/lib/astal/io/gir.py
+++ b/lib/astal/io/gir.py
@@ -1,58 +1 @@
-"""
-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
-
-
-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("<para>", "").replace("</para>", "")
- )
-
- 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 = ["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)
+../../gir.py \ No newline at end of file
diff --git a/lib/gir.py b/lib/gir.py
index a0a81dc..66cbcfd 100644
--- a/lib/gir.py
+++ b/lib/gir.py
@@ -9,6 +9,7 @@ import html
import sys
import subprocess
import re
+import os
# valac fails on gi-docgen compliant markdown
@@ -47,7 +48,7 @@ def fix_gir(name: str, gir: str, out: str):
def valadoc(name: str, gir: str, args: list[str]):
- cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args]
+ 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: