[gimp] Issue #7685: g-ir-doc-tool produces broken XML.



commit 7123b6c466dcf38bb274734e9d7494c9c4fd8b8e
Author: Jehan <jehan girinstud io>
Date:   Sat Mar 26 17:49:45 2022 +0100

    Issue #7685: g-ir-doc-tool produces broken XML.
    
    To work around the issue, I just wrote a stupid sed script. Of course,
    it means that if we encounter again the issue on some other docs, we'll
    have to update it. In other words, it's neither robust nor a proper
    long-term fix. Just a temporary hack.
    See: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/425
    
    Also fixing this issue, I encountered another bug, this time in meson,
    which changes backslashes in slashes on 'command' arguments, in a
    completely uninvited manner! The only workaround to this is apparently
    to call an external script, which is ridiculous for such a basic stuff.
    But well… here is why I implement this with a script, instead of
    directly calling sed in the meson 'command'.
    See: https://github.com/mesonbuild/meson/issues/1564

 devel-docs/g-ir-docs/docs_pages_fix.sh |  3 +++
 devel-docs/g-ir-docs/meson.build       | 24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/devel-docs/g-ir-docs/docs_pages_fix.sh b/devel-docs/g-ir-docs/docs_pages_fix.sh
new file mode 100755
index 0000000000..422138e9d6
--- /dev/null
+++ b/devel-docs/g-ir-docs/docs_pages_fix.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sed -i 's/<\(Prefix\|Image\)/\&lt;\1/g' "$1"
diff --git a/devel-docs/g-ir-docs/meson.build b/devel-docs/g-ir-docs/meson.build
index d16bf4ebd4..552f7536ab 100644
--- a/devel-docs/g-ir-docs/meson.build
+++ b/devel-docs/g-ir-docs/meson.build
@@ -17,6 +17,8 @@ foreach lang : [ 'python', 'gjs' ]
     ],
     build_by_default: true)
 
+  ## Gimp Module ##
+
   # XXX `output` is bogus. g-ir-doc-tool produces a lot of output,
   # basically one page per public symbol, which is more than 1000 so
   # it's not usable. Since custom_target() requires an 'output', I could
@@ -41,10 +43,28 @@ foreach lang : [ 'python', 'gjs' ]
     ],
     build_by_default: true)
 
-  ## Gimp Module ##
+  # This step is completely an ugly workaround for 2 tool issues. The
+  # first issue is that g-ir-doc-tool generates invalid XML by not
+  # transforming less-than signs into entities. So I am special-casing
+  # the one API documentation where we need to write a less-than (it will
+  # need to be updated if this happens again).
+  # See GIMP issue #7685.
+  # The second issue is in meson itself which transforms backslash into
+  # slashes preventing to write most basic regexp in a 'command'. For
+  # this reason, I need to add the sed command as an external script.
+  # See meson issue #1564.
+  docs_pages_fix_sh = find_program('docs_pages_fix.sh')
+  gir_docs_pages_fix = custom_target('g-ir-Gimp-' + lang + '-pages-fix',
+    input: [ gir_docs_pages ],
+    output: [ 'Gimp-' + lang + '-pages-fix' ],
+    command: [
+      docs_pages_fix_sh,
+      '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version + '/Gimp.Procedure.add_menu_path.page',
+    ],
+    build_by_default: true)
 
   gir_docs_cache = custom_target('g-ir-Gimp-' + lang + '-cache',
-    input: [ gir_docs_pages ],
+    input: [ gir_docs_pages_fix ],
     output: [ 'Gimp-' + lang + '-cache' ],
     command: [
       yelp_build, 'cache',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]