[library-web] add experimental support for detecting documentation parts in CMake modules



commit 1a734af6ebcb0415ccfa198d7f2a758630df391f
Author: Frédéric Péters <fpeters 0d be>
Date:   Fri Apr 6 09:29:40 2018 +0200

    add experimental support for detecting documentation parts in CMake modules
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785522

 src/lgo.py             |   12 ++++++++++++
 src/modtypes/base.py   |    8 +++++++-
 src/modtypes/gtkdoc.py |    2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index af71629..c7621a2 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -698,6 +698,7 @@ class Lgo(App):
         extraction_happened = False
         regex_gdu = re.compile(r'include.*gnome-doc-utils.make', re.DOTALL)
         found_meson = False
+        found_cmake = False
         found_autotools = False
         for tarinfo in tar:
             doc = None
@@ -749,6 +750,17 @@ class Lgo(App):
 
                 found_autotools = True
 
+            elif os.path.split(tarinfo.name)[-1] == 'CMakeLists.txt':
+                fd = tar.extractfile(tarinfo)
+                cmakelists = fd.read()
+                if 'add_gtkdoc' in cmakelists:
+                    logging.debug('found usage of gtk-doc in %s' % tarinfo.name)
+                    doc = GtkDocModule.create_from_tar(tar, tarinfo,
+                            cmakelists=cmakelists, nightly=nightly)
+                else:
+                    continue
+                found_cmake = True
+
             elif os.path.split(tarinfo.name)[-1] == 'meson.build' and not found_autotools:
                 fd = tar.extractfile(tarinfo)
                 meson_build = fd.read()
diff --git a/src/modtypes/base.py b/src/modtypes/base.py
index 204eaf9..3ad7517 100644
--- a/src/modtypes/base.py
+++ b/src/modtypes/base.py
@@ -29,6 +29,7 @@ class DocModule(object):
     '''Base class for documentation shipped in tarballs'''
     makefile_am = None
     meson_build = None
+    cmakelists = None
 
     filename = None
     dirname = None
@@ -44,7 +45,7 @@ class DocModule(object):
     mallard_merge = None
 
     def create_from_tar(cls, tar, tarinfo, makefile_am=None, nightly=False,
-            meson_build=None):
+            meson_build=None, cmakelists=None):
         self = cls()
         if tarinfo.isdir():
             self.dirname = tarinfo.name
@@ -71,6 +72,11 @@ class DocModule(object):
             # remove the version part, so libsoup-2.4 is handled just like
             # another version of libsoup
             self.modulename = re.sub('-\d+\.\d+$', '', self.modulename)
+        elif cmakelists:
+            self.cmakelists = cmakelists
+            match = re.findall(r'add_gtkdoc\(([\w-]+)', s, re.DOTALL)
+            assert match
+            self.modulename = match[0]
         elif meson_build:
             self.meson_build = meson_build
             match = re.findall(r"gnome.gtkdoc\s*\(\s*'([\w-]+)'", meson_build, re.DOTALL)
diff --git a/src/modtypes/gtkdoc.py b/src/modtypes/gtkdoc.py
index 0dc782a..5011c9a 100644
--- a/src/modtypes/gtkdoc.py
+++ b/src/modtypes/gtkdoc.py
@@ -53,7 +53,7 @@ class GtkDocModule(DocModule):
         ext_dirname = os.path.join(app.config.private_dir, 'extracts')
 
         html_images = []
-        if self.meson_build:
+        if self.meson_build or self.cmakelists:
             main_sgml_file = None  # will force external HTML
         else:
             main_sgml_file = re.findall(r'DOC_MAIN_SGML_FILE\s?=\s?(.*)',


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