diff --git a/gio/gdbus-2.0/codegen/codegen_rst.py b/gio/gdbus-2.0/codegen/codegen_rst.py
index 026ad675d..303e547cf 100644
--- a/gio/gdbus-2.0/codegen/codegen_rst.py
+++ b/gio/gdbus-2.0/codegen/codegen_rst.py
@@ -142,7 +142,7 @@ class RstCodeGenerator:
else:
access = "readable"
res += [
- ".. _{title}:",
+ f".. _{title}:",
"",
title,
"^" * len(title),
@@ -218,7 +218,7 @@ class RstCodeGenerator:
for m in iface.methods:
title = f"{iface.name}.{m.name}"
res += [
- ".. _{title}:",
+ f".. _{title}:",
"",
title,
"^" * len(title),
@@ -296,7 +296,7 @@ class RstCodeGenerator:
for s in iface.signals:
title = f"{iface.name}::{s.name}"
res += [
- ".. _{title}:",
+ f".. _{title}:",
"",
title,
"^" * len(title),
diff --git a/gio/tests/codegen.py b/gio/tests/codegen.py
index 9fd4321f3..bb570f170 100644
--- a/gio/tests/codegen.py
+++ b/gio/tests/codegen.py
@@ -28,6 +28,7 @@ import shutil
import subprocess
import sys
import tempfile
+import textwrap
import unittest
import xml.etree.ElementTree as ET
@@ -519,6 +520,138 @@ G_END_DECLS
rst = f.readlines()
self.assertTrue(len(rst) != 0)
+ def test_generate_rst_method(self):
+ """Test generating a method documentation with the rst generator."""
+ xml_contents = """
+
+
+
+
+
+
+ """
+ res = self.runCodegenWithInterface(
+ xml_contents,
+ "--generate-rst",
+ "test",
+ )
+ self.assertEqual("", res.err)
+ self.assertEqual("", res.out)
+ with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
+ rst = f.read()
+ self.assertIn(
+ textwrap.dedent(
+ """
+ -------
+ Methods
+ -------
+
+ .. _org.project.Bar.Frobnicator.RandomMethod:
+
+ org.project.Bar.Frobnicator.RandomMethod
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ ::
+
+ RandomMethod ()
+
+
+ A random test method."""
+ ),
+ rst,
+ )
+
+ def test_generate_rst_signal(self):
+ """Test generating a signal documentation with the rst generator."""
+ xml_contents = """
+
+
+
+
+
+
+ """
+ res = self.runCodegenWithInterface(
+ xml_contents,
+ "--generate-rst",
+ "test",
+ )
+ self.assertEqual("", res.err)
+ self.assertEqual("", res.out)
+ with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
+ rst = f.read()
+ self.assertIn(
+ textwrap.dedent(
+ """
+ -------
+ Signals
+ -------
+
+ .. _org.project.Bar.Frobnicator::RandomSignal:
+
+ org.project.Bar.Frobnicator::RandomSignal
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ ::
+
+ RandomSignal ()
+
+
+ A random test signal."""
+ ),
+ rst,
+ )
+
+ def test_generate_rst_property(self):
+ """Test generating a property documentation with the rst generator."""
+ xml_contents = """
+
+
+
+
+
+
+ """
+ res = self.runCodegenWithInterface(
+ xml_contents,
+ "--generate-rst",
+ "test",
+ )
+ self.assertEqual("", res.err)
+ self.assertEqual("", res.out)
+ with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
+ rst = f.read()
+ self.assertIn(
+ textwrap.dedent(
+ """
+ ----------
+ Properties
+ ----------
+
+ .. _org.project.Bar.Frobnicator:RandomProperty:
+
+ org.project.Bar.Frobnicator:RandomProperty
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ ::
+
+ RandomProperty readable s
+
+
+ A random test property."""
+ ),
+ rst,
+ )
+
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_min_required_invalid(self):
"""Test running with an invalid --glib-min-required."""