[gtk-doc] fixxref/rebase: move the exception handling to the common module



commit f8ea839aa531b8cf1de2f623f37064178d24f033
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed Oct 25 21:00:02 2017 +0200

    fixxref/rebase: move the exception handling to the common module
    
    Handle the exception in the commond module. This was added in the previous
    commit, but this is only called from exactly those two functions.

 gtkdoc/common.py  |    8 ++++++--
 gtkdoc/fixxref.py |   28 ++++++++++++----------------
 gtkdoc/rebase.py  |   13 +++++--------
 3 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/gtkdoc/common.py b/gtkdoc/common.py
index 470722e..50c9f5f 100644
--- a/gtkdoc/common.py
+++ b/gtkdoc/common.py
@@ -99,9 +99,13 @@ def GetModuleDocDir(module_name):
       module_name (string): The module, e.g. 'glib-2.0'
 
     Returns:
-      str: the doc directory
+      str: the doc directory or None
     """
-    path = subprocess.check_output([config.pkg_config, '--variable=prefix', module_name], 
universal_newlines=True)
+    path = None
+    try:
+        path = subprocess.check_output([config.pkg_config, '--variable=prefix', module_name], 
universal_newlines=True)
+    except subprocess.CalledProcessError:
+        return None
     return os.path.join(path.strip(), 'share/gtk-doc/html')
 
 
diff --git a/gtkdoc/fixxref.py b/gtkdoc/fixxref.py
index 739e84b..3027c10 100755
--- a/gtkdoc/fixxref.py
+++ b/gtkdoc/fixxref.py
@@ -71,27 +71,23 @@ def Run(options):
 
     # We scan the directory containing GLib and any directories in GNOME2_PATH
     # first, but these will be overriden by any later scans.
-    try:
-        dir = common.GetModuleDocDir('glib-2.0')
-    except subprocess.CalledProcessError:
-        pass
-    else:
-        if os.path.exists(dir):
-            # Some predefined link targets to get links into type hierarchies as these
-            # have no targets. These are always absolute for now.
-            Links['GBoxed'] = dir + '/gobject/gobject-Boxed-Types.html'
-            Links['GEnum'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html'
-            Links['GFlags'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html'
-            Links['GInterface'] = dir + '/gobject/GTypeModule.html'
-
-            if dir != options.html_dir:
-                logging.info('Scanning GLib directory: %s', dir)
-                ScanIndices(dir, (re.search(prefix_match, dir) is None))
+    dir = common.GetModuleDocDir('glib-2.0')
+    if dir and os.path.exists(dir):
+        # Some predefined link targets to get links into type hierarchies as these
+        # have no targets. These are always absolute for now.
+        Links['GBoxed'] = dir + '/gobject/gobject-Boxed-Types.html'
+        Links['GEnum'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html'
+        Links['GFlags'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html'
+        Links['GInterface'] = dir + '/gobject/GTypeModule.html'
+
+        if dir != options.html_dir:
+            logging.info('Scanning GLib directory: %s', dir)
+            ScanIndices(dir, (re.search(prefix_match, dir) is None))
 
     path = os.environ.get('GNOME2_PATH')
     if path:
         for dir in path.split(':'):
-            dir += '/share/gtk-doc/html'
+            dir += 'share/gtk-doc/html'
             if os.path.exists(dir) and dir != options.html_dir:
                 logging.info('Scanning GNOME2_PATH directory: %s', dir)
                 ScanIndices(dir, (re.search(prefix_match, dir) is None))
diff --git a/gtkdoc/rebase.py b/gtkdoc/rebase.py
index 23e3d6e..e518586 100755
--- a/gtkdoc/rebase.py
+++ b/gtkdoc/rebase.py
@@ -59,18 +59,15 @@ def run(options):
     # first, but these will be overriden by any later scans.
     if "GNOME2_PATH" in os.environ:
         for dir in os.environ["GNOME2_PATH"].split(':'):
-            dir = os.path.join(dir, "/share/gtk-doc/html")
+            dir = os.path.join(dir, "share/gtk-doc/html")
             if os.path.isdir(dir):
                 log(options, "Prepending GNOME2_PATH directory:", dir)
                 other_dirs = [dir] + other_dirs
 
-    try:
-        dir = common.GetModuleDocDir('glib-2.0')
-    except subprocess.CalledProcessError:
-        pass
-    else:
-        log(options, "Prepending GLib directory", dir)
-        other_dirs = [dir] + other_dirs
+    glib_dir = common.GetModuleDocDir('glib-2.0')
+    if glib_dir:
+        log(options, "Prepending GLib directory", glib_dir)
+        other_dirs = [glib_dir] + other_dirs
 
     # Check all other dirs, but skip already scanned dirs ord subdirs of those
 


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