GNOME Bugzilla – Bug 682401
Incorrect anchor generated for GBoxed typedef in the same file as a class
Last modified: 2018-05-22 13:06:31 UTC
If a single C file/H file pair defines a GObject class as normal, but also has a typedef of a struct which is registered as a GBoxed type with GObject, an extraneous <anchor> element will be generated for the typedef in the gtk-doc XML for that file. It’s extraneous because a <refsect> will also be generated for the typedef, with the same ID. The IDs will clash. For example, the following H file (full version here: http://git.gnome.org/browse/totem-pl-parser/tree/plparse/totem-pl-parser.h): typedef struct { … } TotemPlParserClass; /** * TotemPlParserMetadata: * * … */ typedef GHashTable TotemPlParserMetadata; with the following C file (full version here: http://git.gnome.org/browse/totem-pl-parser/tree/plparse/totem-pl-parser.c): GType totem_pl_parser_metadata_get_type (void) { … GType g_define_type_id = g_boxed_type_register_static ( g_intern_static_string ("TotemPlParserMetadata"), (GBoxedCopyFunc) g_hash_table_ref, (GBoxedFreeFunc) g_hash_table_unref); … } will generate the following XML: <refsynopsisdiv id="TotemPlParser.synopsis" role="synopsis"> <title role="synopsis.title">Synopsis</title> <anchor id="TotemPlParserMetadata"/> <synopsis> #include <totem-pl-parser.h> … <refsect2 id="TotemPlParserMetadata" role="typedef"> <title>TotemPlParserMetadata</title> <indexterm zone="TotemPlParserMetadata"><primary>TotemPlParserMetadata</primary></indexterm> <programlisting>typedef GHashTable TotemPlParserMetadata; </programlisting> </refsect2>
Created attachment 222082 [details] [review] Remove generation of anchor elements This patch fixes the issue for me. I can’t see what else can cause an <anchor> element to be generated apart from an object, and objects are guaranteed to generate a <refsect> as well. Therefore, removing <anchor> generation seems (to me) to be the best way to fix it. I’m probably missing something.
See also https://bugzilla.gnome.org/show_bug.cgi?id=593282#c5
Created attachment 222151 [details] changes causes by the patch Applying the patch causes this delta in the test suite. I think it is for the better actually. I'll try this for more pages.
Sorry, I have to correct myself. With your patch applied, I can't like to GEnums and GBoxed types anymore :/
(In reply to comment #4) > Sorry, I have to correct myself. With your patch applied, I can't like to > GEnums and GBoxed types anymore :/ Why not? Shouldn’t a <refsect> be generated for each GEnum and GBoxed with the right ID?
(In reply to comment #5) > (In reply to comment #4) > > Sorry, I have to correct myself. With your patch applied, I can't like to > > GEnums and GBoxed types anymore :/ > > Why not? Shouldn’t a <refsect> be generated for each GEnum and GBoxed with the > right ID? Yes, it should. But this is not implemented right now and I am really short on spare time for this :/.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk-doc/issues/22.