Title: [106786] trunk/Tools
Revision
106786
Author
carlo...@webkit.org
Date
2012-02-06 01:23:08 -0800 (Mon, 06 Feb 2012)

Log Message

[GTK] Fix xrefs after installing API documentation
https://bugs.webkit.org/show_bug.cgi?id=77551

Reviewed by Martin Robinson.

* GNUmakefile.am: Call generate-gtkdoc --rebase after installing
api docs.
* gtk/common.py:
(prefix_of_pkg_config_file): Get the prefix variable of the given
pkg-config file.
(gtk_version_of_pkg_config_file): Get the gtk version required by
the given pkg-config file.
* gtk/generate-gtkdoc: Add --rebase command line option to rebase
installed documentation.
(get_gtkdoc_module_paths): Get paths where API doc is installed
for the dependencies of the given pkg-config file.
(get_common_xref_deps): Get API doc directories of dependencies
common to WebKit1 and WebKit2.
(get_webkit2_options): Add cross_reference_deps option.
(get_webkit1_options): Ditto
(rebase_installed_docs): Helper function to create a generator for
the given pkg-config file and options and call rebase_installed_docs.
* gtk/gtkdoc.py:
(GTKDoc.__init__): Initialize cross_reference_deps.
(GTKDoc._run_gtkdoc_fixxref): Add API doc directories of
dependencies.
(GTKDoc.rebase_installed_docs): Call gtkdoc-rebase to fix xref
links of installed documentation.
(PkgConfigGTKDoc.__init__): Get the prefix from the pkg-config
file.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (106785 => 106786)


--- trunk/Tools/ChangeLog	2012-02-06 09:22:26 UTC (rev 106785)
+++ trunk/Tools/ChangeLog	2012-02-06 09:23:08 UTC (rev 106786)
@@ -1,3 +1,36 @@
+2012-02-06  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Fix xrefs after installing API documentation
+        https://bugs.webkit.org/show_bug.cgi?id=77551
+
+        Reviewed by Martin Robinson.
+
+        * GNUmakefile.am: Call generate-gtkdoc --rebase after installing
+        api docs.
+        * gtk/common.py:
+        (prefix_of_pkg_config_file): Get the prefix variable of the given
+        pkg-config file.
+        (gtk_version_of_pkg_config_file): Get the gtk version required by
+        the given pkg-config file.
+        * gtk/generate-gtkdoc: Add --rebase command line option to rebase
+        installed documentation.
+        (get_gtkdoc_module_paths): Get paths where API doc is installed
+        for the dependencies of the given pkg-config file.
+        (get_common_xref_deps): Get API doc directories of dependencies
+        common to WebKit1 and WebKit2.
+        (get_webkit2_options): Add cross_reference_deps option.
+        (get_webkit1_options): Ditto
+        (rebase_installed_docs): Helper function to create a generator for
+        the given pkg-config file and options and call rebase_installed_docs.
+        * gtk/gtkdoc.py:
+        (GTKDoc.__init__): Initialize cross_reference_deps.
+        (GTKDoc._run_gtkdoc_fixxref): Add API doc directories of
+        dependencies.
+        (GTKDoc.rebase_installed_docs): Call gtkdoc-rebase to fix xref
+        links of installed documentation.
+        (PkgConfigGTKDoc.__init__): Get the prefix from the pkg-config
+        file.
+
 2012-02-06  Sergio Villar Senin  <svil...@igalia.com>
 
         Incorrect statistics shown when running run-webkit-tests with --repeat-each or --iterations

Modified: trunk/Tools/GNUmakefile.am (106785 => 106786)


--- trunk/Tools/GNUmakefile.am	2012-02-06 09:22:26 UTC (rev 106785)
+++ trunk/Tools/GNUmakefile.am	2012-02-06 09:23:08 UTC (rev 106786)
@@ -325,6 +325,7 @@
 	  fi; \
 	fi
 endif
+	$(srcdir)/Tools/gtk/generate-gtkdoc --rebase
 
 uninstall-local:
 	@DOC_MODULE_VERSION=`cat ./Documentation/webkitgtk/version.xml`; \

Modified: trunk/Tools/gtk/common.py (106785 => 106786)


--- trunk/Tools/gtk/common.py	2012-02-06 09:22:26 UTC (rev 106785)
+++ trunk/Tools/gtk/common.py	2012-02-06 09:23:08 UTC (rev 106786)
@@ -76,3 +76,22 @@
     process = subprocess.Popen([script_path('num-cpus')], stdout=subprocess.PIPE)
     stdout = process.communicate()[0]
     return int(stdout)
+
+
+def prefix_of_pkg_config_file(package):
+    process = subprocess.Popen(['pkg-config', '--variable=prefix', package],
+                                   stdout=subprocess.PIPE)
+    stdout = process.communicate()[0]
+    if process.returncode != 0:
+        return None
+    return stdout.strip()
+
+
+def gtk_version_of_pkg_config_file(pkg_config_path):
+    process = subprocess.Popen(['pkg-config', pkg_config_path, '--print-requires'],
+                               stdout=subprocess.PIPE)
+    stdout = process.communicate()[0]
+
+    if 'gtk+-3.0' in stdout:
+        return 3
+    return 2

Modified: trunk/Tools/gtk/generate-gtkdoc (106785 => 106786)


--- trunk/Tools/gtk/generate-gtkdoc	2012-02-06 09:22:26 UTC (rev 106785)
+++ trunk/Tools/gtk/generate-gtkdoc	2012-02-06 09:23:08 UTC (rev 106786)
@@ -34,6 +34,21 @@
     else:
         handler.setFormatter(logging.Formatter('%(message)s'))
 
+
+def get_gtkdoc_module_paths(xref_dep_packages):
+    deps = []
+    html_dir = os.path.join('share', 'gtk-doc', 'html')
+
+    for package in xref_dep_packages:
+        prefix = common.prefix_of_pkg_config_file(package)
+        if prefix is None:
+            continue
+        for module in xref_dep_packages[package]:
+            deps.append(os.path.join(prefix, html_dir, module))
+
+    return deps
+
+
 def get_common_options():
     return {
         'decorator': 'WEBKIT_API',
@@ -41,12 +56,24 @@
         'library_path' : common.build_path('.libs'),
     }
 
+def get_common_xref_deps():
+    return {
+        'glib-2.0' : ['glib', 'gobject', 'gio'],
+        'libsoup-2.4' : ['libsoup-2.4'],
+        'gdk-pixbuf-2.0': ['gdk-pixbuf']
+    }
+
 def get_webkit2_options():
     def derived_sources_path(*args):
         return common.build_path(*(('DerivedSources', 'WebKit2') + args))
     def src_path(*args):
         return common.top_level_path(*(('Source', 'WebKit2', 'UIProcess', 'API', 'gtk') + args))
 
+    xref_deps = get_common_xref_deps().copy()
+    xref_deps.update({
+        'gtk+-3.0' : ['gtk3', 'gdk3']
+    })
+
     options = get_common_options().copy()
     options.update({
         'module_name' : 'webkit2gtk',
@@ -58,6 +85,7 @@
                    ' -I' + derived_sources_path('include') + \
                    ' -I' + common.top_level_path('Source') + \
                    ' -I' + src_path(),
+        'cross_reference_deps' : get_gtkdoc_module_paths(xref_deps),
         'ignored_files': glob.glob(src_path('*Private.h')) + \
                          glob.glob(src_path('*Client*')) + \
                          glob.glob(src_path('WebKitWebViewBaseAccessible.*')) + \
@@ -65,10 +93,20 @@
     })
     return options
 
-def get_webkit1_options():
+def get_webkit1_options(gtk_version):
     def src_path(*args):
         return common.top_level_path(*(('Source', 'WebKit', 'gtk') + args))
 
+    xref_deps = get_common_xref_deps().copy()
+    if gtk_version == 3:
+        xref_deps.update({
+                'gtk+-3.0' : ['gtk3', 'gdk3']
+        })
+    else:
+        xref_deps.update({
+                'gtk+-2.0' : ['gtk', 'gdk']
+        })
+
     options = get_common_options().copy()
     options.update({
         'module_name' : 'webkitgtk',
@@ -80,6 +118,7 @@
                    ' -I' + src_path() + \
                    ' -I' + common.top_level_path('Source') + \
                    ' -I' + common.top_level_path('Source', '_javascript_Core', 'ForwardingHeaders'),
+        'cross_reference_deps' : get_gtkdoc_module_paths(xref_deps),
         'ignored_files': glob.glob(src_path('webkit', '*private.*'))
     })
     return options
@@ -89,6 +128,10 @@
     generator.generate(html='--skip-html' not in sys.argv)
     return generator.saw_warnings
 
+def rebase_installed_docs(pkg_config_path, options):
+    generator = gtkdoc.PkgConfigGTKDoc(pkg_config_path, options)
+    generator.rebase_installed_docs()
+
 configure_logging()
 
 # We need to add the _javascript_Core build directory to the PKG_CONFIG_PATH
@@ -104,13 +147,23 @@
 if not os.path.exists(pkg_config_path):
     pkg_config_path = common.build_path('Source', 'WebKit', 'gtk', 'webkitgtk-1.0.pc')
 if os.path.exists(pkg_config_path):
-    print "Generating WebKit1 documentation..."
-    saw_webkit1_warnings = generate_doc(pkg_config_path, get_webkit1_options())
+    options = get_webkit1_options(common.gtk_version_of_pkg_config_file(pkg_config_path))
+    if '--rebase' not in sys.argv:
+        print "Generating WebKit1 documentation..."
+        saw_webkit1_warnings = generate_doc(pkg_config_path, options)
+    else:
+        print "Rebasing WebKit1 documentation..."
+        rebase_installed_docs(pkg_config_path, options)
 
 # WebKit2 might not be enabled, so check for the pkg-config file before building documentation.
 pkg_config_path = common.build_path('Source', 'WebKit2', 'webkit2gtk-3.0.pc')
 if os.path.exists(pkg_config_path):
-    print "\nGenerating WebKit2 documentation..."
-    saw_webkit2_warnings = generate_doc(pkg_config_path, get_webkit2_options())
+    options = get_webkit2_options()
+    if '--rebase' not in sys.argv:
+        print "\nGenerating WebKit2 documentation..."
+        saw_webkit2_warnings = generate_doc(pkg_config_path, options)
+    else:
+        print "\nRebasing WebKit2 documentation..."
+        rebase_installed_docs(pkg_config_path, options)
 
 sys.exit(saw_webkit1_warnings or saw_webkit2_warnings)

Modified: trunk/Tools/gtk/gtkdoc.py (106785 => 106786)


--- trunk/Tools/gtk/gtkdoc.py	2012-02-06 09:22:26 UTC (rev 106785)
+++ trunk/Tools/gtk/gtkdoc.py	2012-02-06 09:23:08 UTC (rev 106786)
@@ -95,6 +95,9 @@
         self.doc_dir = ''
         self.main_sgml_file = ''
 
+        # Parameters specific to gtkdoc-fixxref.
+        self.cross_reference_deps = []
+
         self.interactive = False
 
         self.logger = logging.getLogger('gtkdoc')
@@ -340,13 +343,21 @@
                           cwd=html_dest_dir)
 
     def _run_gtkdoc_fixxref(self):
-        self._run_command(['gtkdoc-fixxref',
-                           '--module-dir=html',
-                           '--html-dir=html'],
-                          cwd=self.output_dir,
-                          ignore_warnings=True)
+        args = ['gtkdoc-fixxref',
+                '--module-dir=html',
+                '--html-dir=html']
+        args.extend(['--extra-dir=%s' % extra_dir for extra_dir in self.cross_reference_deps])
+        self._run_command(args, cwd=self.output_dir, ignore_warnings=True)
 
+    def rebase_installed_docs(self):
+        html_dir = os.path.join(self.prefix, 'share', 'gtk-doc', 'html', self.module_name)
+        args = ['gtkdoc-rebase',
+                '--relative',
+                '--html-dir=%s' % html_dir]
+        args.extend(['--other-dir=%s' % extra_dir for extra_dir in self.cross_reference_deps])
+        self._run_command(args, cwd=self.output_dir)
 
+
 class PkgConfigGTKDoc(GTKDoc):
 
     """Class reads a library's pkgconfig file to guess gtkdoc parameters.
@@ -376,3 +387,6 @@
         self.version = self._run_command(['pkg-config',
                                           pkg_config_path,
                                           '--modversion'], print_output=False)
+        self.prefix = self._run_command(['pkg-config',
+                                         pkg_config_path,
+                                         '--variable=prefix'], print_output=False)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to