diff options
author | Aylur <[email protected]> | 2024-10-25 14:09:04 +0000 |
---|---|---|
committer | Aylur <[email protected]> | 2024-10-25 14:09:04 +0000 |
commit | e8715aec5e05e0438192e611afea2fe6f10cb80f (patch) | |
tree | 2ff8bd9000829022b1438dd0d84035955df68298 /lib/gir.py | |
parent | d6bdcff12256ef1ff8c906c90ebf3c72b58209af (diff) |
docs: battery doc comments
Diffstat (limited to 'lib/gir.py')
-rw-r--r-- | lib/gir.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -8,6 +8,15 @@ import xml.etree.ElementTree as ET import html import sys import subprocess +import re + + +# valac fails on gi-docgen compliant markdown +# gi-docgen removes valac compliant ulink +# so we use vala notation and turn it into markdown +def ulink_to_markdown(text: str): + pattern = r'<ulink url="(.*?)">(.*?)</ulink>' + return re.sub(pattern, r"[\2](\1)", text) def fix_gir(name: str, gir: str, out: str): @@ -24,7 +33,7 @@ def fix_gir(name: str, gir: str, out: str): for doc in root.findall(".//doc", namespaces): if doc.text: - doc.text = ( + doc.text = ulink_to_markdown( html.unescape(doc.text).replace("<para>", "").replace("</para>", "") ) |