[library-web: 2/3] Allow external doc tarballs for gi-docgen modules
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web: 2/3] Allow external doc tarballs for gi-docgen modules
- Date: Thu, 8 Apr 2021 18:27:40 +0000 (UTC)
commit 9256ca12cd65bb8e4faa1ecd582c8a38328a7597
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Mar 18 17:54:08 2021 +0000
Allow external doc tarballs for gi-docgen modules
In case the HTML is not distributed with the tarball itself.
src/modtypes/gidocgen.py | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/src/modtypes/gidocgen.py b/src/modtypes/gidocgen.py
index 0d930f58..039bb684 100644
--- a/src/modtypes/gidocgen.py
+++ b/src/modtypes/gidocgen.py
@@ -40,11 +40,44 @@ class GIDocGenModule(DocModule):
if not os.path.exists(web_output_dir):
os.makedirs(web_output_dir)
- namespace = re.findall(r'\s*namespace\s*=\s*"([\w\-]+)"', self.toml)[0].split()
+ namespace = re.findall(r'\s*namespace\s*=\s*"([\w-]+)"', self.toml)[0].strip()
+
+ # If we didn't find an explicit namespace here, we go for the doc_module's name,
+ # and hope for the best
if not namespace:
namespace = doc_module
htmldir = os.path.join(ext_dirname, self.dirname, namespace)
+ if not os.path.exists(htmldir):
+ tarball_location = app.overlay.get_doc_tarball_location(self.modulename)
+ if tarball_location:
+ tarball_location = tarball_location.replace('{VERSION_FULL}', self.version)
+ tarball_location = tarball_location.replace('{VERSION_ONE_DOT}', self.one_dot_version)
+ htmldir = os.path.join(ext_dirname, 'doc-tarballs', self.dirname, namespace)
+ if not os.path.exists(htmldir):
+ logging.debug('extracting %s' % tarball_location)
+ doc_tarball = app.download(tarball_location)
+ if not doc_tarball:
+ logging.error('skipped %s as it is missing a doc tarball' % doc_module)
+ return
+ os.makedirs(htmldir)
+ tar2 = tarfile.open(doc_tarball, 'r')
+ ext2_dirname = os.path.join(ext_dirname, 'doc-tarballs', self.dirname.split('/')[0])
+ for tar2info in tar2.getmembers():
+ dest = os.path.join(ext2_dirname, tar2info.name)
+ if tar2info.isdir() and not os.path.exists(dest):
+ os.makedirs(dest)
+ elif tar2info.isreg():
+ if not os.path.exists(os.path.dirname(dest)):
+ os.makedirs(os.path.dirname(dest))
+ open(dest, 'w').write(tar2.extractfile(tar2info).read())
+ tar2.close()
+ else:
+ logging.error('skipped %s: no HTML found' % doc_module)
+
+ if not os.path.exists(os.path.join(htmldir, 'index.html')):
+ logging.error('skipped %s: no documentation found in %s' % (doc_module, htmldir))
+ return
# simply copy HTML files shipped in tarball
logging.debug('copying files shipped with tarball')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]