From: Corentin Noël Date: Tue, 8 Apr 2025 20:28:22 +0000 (+0200) Subject: girwriter: Add the doc:format argument in the .gir file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftintou%2Fwriter-doc-format;p=thirdparty%2Fvala.git girwriter: Add the doc:format argument in the .gir file By default, output the "unknown" format, the girwriter from valadoc is able to output the markdown-flavoured gtk-doc format. --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index 77388bb05..9c33c0e20 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -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 ("\n"); indent++; @@ -308,6 +311,11 @@ public class Vala.GIRWriter : CodeVisitor { buffer.append_printf ("\n", name); } + private void write_doc_format (string name) { + write_indent (); + buffer.append_printf ("\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 (" + + diff --git a/tests/girwriter/class-final.test b/tests/girwriter/class-final.test index e92739ebe..9bb5ea8c7 100644 --- a/tests/girwriter/class-final.test +++ b/tests/girwriter/class-final.test @@ -12,6 +12,7 @@ Output: + diff --git a/tests/girwriter/combined.test b/tests/girwriter/combined.test index 8d4e267ca..0db286b48 100644 --- a/tests/girwriter/combined.test +++ b/tests/girwriter/combined.test @@ -20,6 +20,7 @@ Output: + diff --git a/valadoc/girwriter.vala b/valadoc/girwriter.vala index 1a68b24ae..32b944735 100644 --- a/valadoc/girwriter.vala +++ b/valadoc/girwriter.vala @@ -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) { diff --git a/valadoc/tests/girwriter/GirTest-1.0.gir-expected b/valadoc/tests/girwriter/GirTest-1.0.gir-expected index 77ea56b8c..46da066bc 100644 --- a/valadoc/tests/girwriter/GirTest-1.0.gir-expected +++ b/valadoc/tests/girwriter/GirTest-1.0.gir-expected @@ -1,7 +1,8 @@ - + + <para>An example comment for an example enum.</para>