]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Add the doc:format argument in the .gir file tintou/writer-doc-format
authorCorentin Noël <tintou@noel.tf>
Tue, 8 Apr 2025 20:28:22 +0000 (22:28 +0200)
committerCorentin Noël <tintou@noel.tf>
Tue, 8 Apr 2025 20:28:22 +0000 (22:28 +0200)
By default, output the "unknown" format, the girwriter from valadoc is able to
output the markdown-flavoured gtk-doc format.

codegen/valagirwriter.vala
tests/girwriter/GirTest-1.0.gir-expected
tests/girwriter/class-final.test
tests/girwriter/combined.test
valadoc/girwriter.vala
valadoc/tests/girwriter/GirTest-1.0.gir-expected

index 77388bb0559c491ce7ea9b02d9b549923be431f7..9c33c0e20debe11b2430a4053c797f2723daae06 100644 (file)
@@ -32,6 +32,8 @@ public class Vala.GIRWriter : CodeVisitor {
        private string gir_version;
        private string gir_shared_library;
 
+       protected string doc_format = "unknown";
+
        protected virtual string? get_interface_comment (Interface iface) {
                return null;
        }
@@ -208,6 +210,7 @@ public class Vala.GIRWriter : CodeVisitor {
                stream.printf ("<repository version=\"1.2\"");
                stream.printf (" xmlns=\"http://www.gtk.org/introspection/core/1.0\"");
                stream.printf (" xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"");
+               stream.printf (" xmlns:doc=\"http://www.gtk.org/introspection/doc/1.0\"");
                stream.printf (" xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\"");
                stream.printf (">\n");
                indent++;
@@ -308,6 +311,11 @@ public class Vala.GIRWriter : CodeVisitor {
                buffer.append_printf ("<c:include name=\"%s\"/>\n", name);
        }
 
+       private void write_doc_format (string name) {
+               write_indent ();
+               buffer.append_printf ("<doc:format name=\"%s\"/>\n", name);
+       }
+
        public override void visit_source_file (SourceFile source_file) {
                if (source_file.file_type != SourceFileType.PACKAGE) {
                        return;
@@ -371,6 +379,7 @@ public class Vala.GIRWriter : CodeVisitor {
                ns.set_attribute_string ("CCode", "gir_version", gir_version);
 
                write_c_includes (ns);
+               write_doc_format (doc_format);
 
                write_indent ();
                buffer.append_printf ("<namespace name=\"%s\" version=\"%s\"", gir_namespace, gir_version);
index 0a22e2121d03eb715356aae2093a06850d40559c..5a1ce706d545befb6bd92410005f1833886d13bf 100644 (file)
@@ -1,9 +1,10 @@
-<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:doc="http://www.gtk.org/introspection/doc/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
 <include name="GObject" version="2.0"/>
 <include name="GLib" version="2.0"/>
 <include name="Gio" version="2.0"/>
 <package name="girtest"/>
 <c:include name="girtest.h"/>
+<doc:format name="unknown"/>
 <namespace name="GirTest" version="1.0" shared-library="girtest" c:prefix="GirTest" c:identifier-prefixes="GirTest" c:symbol-prefixes="gir_test">
        <function name="nested_function" c:identifier="gir_test_nested_function">
                <return-value transfer-ownership="full">
index e92739ebe8f9aa34f8525c63690f4bd63d5c29f9..9bb5ea8c771b6887c6ada2e46288b678a59f6bd1 100644 (file)
@@ -12,6 +12,7 @@ Output:
 <include name="GObject" version="2.0"/>
 <package name="test"/>
 <c:include name="test.h"/>
+<doc:format name="unknown"/>
 <namespace name="Test" version="1.2" c:prefix="Test" c:identifier-prefixes="Test" c:symbol-prefixes="test">
        <class name="TestFoo" c:type="TestTestFoo" c:symbol-prefix="foo" glib:type-name="TestTestFoo" glib:get-type="test_test_foo_get_type" glib:type-struct="TestFooClass" glib:fundamental="1" glib:ref-func="test_test_foo_ref" glib:unref-func="test_test_foo_unref" glib:set-value-func="test_test_value_set_foo" glib:get-value-func="test_test_value_get_foo">
                <field name="parent_instance" readable="0" private="1">
index 8d4e267cac121350b7ea96e8e6878b82068e52b7..0db286b489385706956ccf7fb1fca793927ef72c 100644 (file)
@@ -20,6 +20,7 @@ Output:
 <include name="Manam" version="1.0"/>
 <package name="test"/>
 <c:include name="test.h"/>
+<doc:format name="unknown"/>
 <namespace name="Test" version="1.2" c:prefix="Test" c:identifier-prefixes="Test" c:symbol-prefixes="test">
        <function name="use_combined_foo" c:identifier="test_use_combined_foo">
                <return-value transfer-ownership="full">
index 1a68b24ae8fc32e927750a291949911eddacd6ec..32b944735ec313754aa1f14675a61ea52be76bfb 100644 (file)
@@ -33,6 +33,7 @@ public class Valadoc.GirWriter : Vala.GIRWriter {
        public GirWriter (SymbolResolver resolver) {
                this.renderer = new GtkdocRenderer ();
                this.resolver = resolver;
+               this.doc_format = "gtk-doc-markdown";
        }
 
        private string? translate (Content.Comment? documentation) {
index 77ea56b8cbcd1ca33d21dac56d2abff02d6d88d1..46da066bc3454c68097d00ce9f252602e7588ccd 100644 (file)
@@ -1,7 +1,8 @@
-<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:doc="http://www.gtk.org/introspection/doc/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
 <include name="GObject" version="2.0"/>
 <package name="girtest"/>
 <c:include name="girtest.h"/>
+<doc:format name="gtk-doc-markdown"/>
 <namespace name="GirTest" version="1.0" c:prefix="GirTest" c:identifier-prefixes="GirTest" c:symbol-prefixes="gir_test">
        <enumeration name="EnumTest" c:type="GirTestEnumTest" glib:type-name="GirTestEnumTest" glib:get-type="gir_test_enum_test_get_type">
                <doc xml:space="preserve" filename="girtest.vala" line="40" column="2">&lt;para&gt;An example comment for an example enum.&lt;/para&gt;</doc>