[gtk-doc] common: extract helper from rebase



commit f0faf12092387e30d0c1a12e207085fe33870cea
Author: Stefan Sauer <ensonic users sf net>
Date:   Mon Apr 10 19:50:00 2017 +0200

    common: extract helper from rebase
    
    We need the same code in fixxref.

 gtkdoc/common.py |   15 +++++++++++++++
 gtkdoc/rebase.py |    6 ++----
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gtkdoc/common.py b/gtkdoc/common.py
index 4ece6fe..36c5734 100644
--- a/gtkdoc/common.py
+++ b/gtkdoc/common.py
@@ -22,6 +22,8 @@
 import logging
 import os
 
+from . import config
+
 
 def UpdateFileIfChanged(old_file, new_file, make_backup):
     """Compares the old version of the file with the new version and if the
@@ -57,3 +59,16 @@ def UpdateFileIfChanged(old_file, new_file, make_backup):
 
     os.rename(new_file, old_file)
     return True
+
+
+def GetModuleDocDir(module_name):
+    """Get the docdir for the given module via pkg-config
+
+    Args:
+      module_name: The module, e.g. 'glib-2.0'
+
+    Returns:
+      string: the doc directory
+    """
+    path = subprocess.check_output([config.pkg_config, '--variable=prefix', module_name], 
universal_newlines=True)
+    return os.path.join(path.strip(), "/share/gtk-doc/html")
diff --git a/gtkdoc/rebase.py b/gtkdoc/rebase.py
index 1b471cd..91f5397 100755
--- a/gtkdoc/rebase.py
+++ b/gtkdoc/rebase.py
@@ -31,7 +31,7 @@ import sys
 import subprocess
 import re
 
-from . import config
+from . import common
 
 # Maps.
 # These two point to the last seen URI of given type for a package:
@@ -63,9 +63,7 @@ def run(options):
                 log(options, "Prepending GNOME2_PATH directory:", dir)
                 other_dirs = [dir] + other_dirs
 
-    dir = subprocess.check_output([config.pkg_config, '--variable=prefix', 'glib-2.0'], 
universal_newlines=True)
-    dir = dir.strip()
-    dir = os.path.join(dir, "/share/gtk-doc/html")
+    dir = common.GetModuleDocDir('glib-2.0')
     log(options, "Prepending GLib directory", dir)
     other_dirs = [dir] + other_dirs
 


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