Generate RST anchors for methods, signals, and properties

Don't rely on the titles.
This commit is contained in:
Emmanuele Bassi 2023-08-28 16:26:24 +01:00
parent 5f33ae8901
commit 5f8af01b8b

View File

@ -120,12 +120,12 @@ class RstCodeGenerator:
def _generate_section(self, title, name): def _generate_section(self, title, name):
"""Generates a section with the given title.""" """Generates a section with the given title."""
res = [ res = [
f".. _{name} {title}:",
"",
"-" * len(title), "-" * len(title),
title, title,
"-" * len(title), "-" * len(title),
"", "",
f".. {name} {title}:",
"",
"", "",
] ]
return "\n".join(res) return "\n".join(res)
@ -142,6 +142,8 @@ class RstCodeGenerator:
else: else:
access = "readable" access = "readable"
res += [ res += [
".. _{title}:",
"",
title, title,
"^" * len(title), "^" * len(title),
"", "",
@ -216,6 +218,8 @@ class RstCodeGenerator:
for m in iface.methods: for m in iface.methods:
title = f"{iface.name}.{m.name}" title = f"{iface.name}.{m.name}"
res += [ res += [
".. _{title}:",
"",
title, title,
"^" * len(title), "^" * len(title),
"", "",
@ -292,6 +296,8 @@ class RstCodeGenerator:
for s in iface.signals: for s in iface.signals:
title = f"{iface.name}::{s.name}" title = f"{iface.name}::{s.name}"
res += [ res += [
".. _{title}:",
"",
title, title,
"^" * len(title), "^" * len(title),
"", "",