diff options
Diffstat (limited to 'Tools/gtk/generate-gtkdoc')
-rwxr-xr-x | Tools/gtk/generate-gtkdoc | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/Tools/gtk/generate-gtkdoc b/Tools/gtk/generate-gtkdoc index 37eeee94c..33b2824f8 100755 --- a/Tools/gtk/generate-gtkdoc +++ b/Tools/gtk/generate-gtkdoc @@ -19,13 +19,16 @@ from __future__ import print_function from ConfigParser import SafeConfigParser import argparse +import codecs import common import glob import gtkdoc import logging import os.path import sys -import webkitdom + +sys.stdout = codecs.getwriter("utf-8")(sys.stdout) +sys.stderr = codecs.getwriter("utf-8")(sys.stderr) def configure_logging(verbose): level = logging.DEBUG if verbose else logging.INFO @@ -39,16 +42,13 @@ def configure_logging(verbose): else: handler.setFormatter(logging.Formatter('%(message)s')) -def get_gtkdoc_module_paths(gtk_version): +def get_gtkdoc_module_paths(cross_reference_deps): dependent_packages = { 'glib-2.0' : ['glib', 'gobject', 'gio'], 'libsoup-2.4' : ['libsoup-2.4'], - 'gdk-pixbuf-2.0': ['gdk-pixbuf'] + 'gdk-pixbuf-2.0': ['gdk-pixbuf'], + 'gtk+-3.0' : ['gtk3', 'gdk3'] } - if gtk_version == 3: - dependent_packages.update({'gtk+-3.0' : ['gtk3', 'gdk3']}) - else: - dependent_packages.update({'gtk+-2.0' : ['gtk', 'gdk']}) paths = [] html_dir = os.path.join('share', 'gtk-doc', 'html') @@ -58,9 +58,9 @@ def get_gtkdoc_module_paths(gtk_version): continue for module in modules: paths.append(os.path.join(prefix, html_dir, module)) - # This technically is not needed for the GObject DOM bindings documentation itself, - # but adding it doesn't hurt and allows us to avoid a check here. - paths.append(common.build_path('Documentation', 'webkitdomgtk', 'html')) + + for local_dep in cross_reference_deps: + paths.append(common.build_path('Documentation', local_dep, 'html')) return paths def print_missing_api(generator): @@ -91,13 +91,13 @@ def files_to_ignore(source_dirs, headers_with_gtkdoc): if os.path.splitext(file)[1] not in ['.h', '.c', '.cpp', '.cc']: return False # These files are ignored anyway. if not os.path.isfile(file): - return False + return True return os.path.abspath(file) not in implementation_files all_files = sum([[os.path.join(dir, file) for file in os.listdir(dir)] for dir in source_dirs], []) return filter(file_should_be_ignored, all_files) -def get_generator_for_config(config_file, virtual_root): +def get_generator_for_config(config_file, virtual_root, cross_reference_deps = []): if not os.path.isfile(config_file): return None @@ -105,7 +105,6 @@ def get_generator_for_config(config_file, virtual_root): config.read(config_file) module_name = config.sections()[0] pkgconfig_file = config.get(module_name, 'pkgconfig_file') - gtk_version = common.gtk_version_of_pkg_config_file(pkgconfig_file) if not os.path.isfile(pkgconfig_file): return None @@ -121,37 +120,32 @@ def get_generator_for_config(config_file, virtual_root): 'namespace': config.get(module_name, 'namespace'), 'doc_dir': config.get(module_name, 'doc_dir'), 'output_dir': common.build_path('Documentation', module_name), + 'main_sgml_file': config.get(module_name, 'main_sgml_file'), 'source_dirs': source_dirs, 'headers': headers, 'cflags': " ".join(config.get(module_name, 'cflags').split()), - 'cross_reference_deps': get_gtkdoc_module_paths(gtk_version), + 'cross_reference_deps': get_gtkdoc_module_paths(cross_reference_deps), 'ignored_files': files_to_ignore(source_dirs, headers), }) def generate_doc(generator, skip_html): - print("\nGenerating {0} documentation...".format(generator.module_name)) generator.generate(not skip_html) if generator.saw_warnings: print_missing_api(generator) return generator.saw_warnings def rebase_doc(generator): - print("\nRebasing {0} documentation...".format(generator.module_name)) try: generator.rebase_installed_docs() except Exception: print("Rebase did not happen, likely no documentation is present.") -def generate_documentation_for_config(config_file): - generator = get_generator_for_config(config_file, arguments.virtual_root) - if not generator: - print("{0} does not exist! Skipping that documentation.".format(os.path.basename(config_file))) - return - +def generate_documentation(generator): if not arguments.rebase: return generate_doc(generator, arguments.skip_html) rebase_doc(generator) + return False def prepare_environment_for_gtkdoc_generation(): # We need to add the JavaScriptCore build directory to the PKG_CONFIG_PATH @@ -174,10 +168,6 @@ def prepare_environment_for_gtkdoc_generation(): cflags += ' -Wno-cast-align' os.environ['CFLAGS'] = cflags - # Clang can be noisy, throwing unnecessary warnings for unused arguments. - if os.environ.get('CC') == "clang": - os.environ['CFLAGS'] += ' -Qunused-arguments' - # Paths from the GNUmakefile generated configuration files are relative to the build directory. os.chdir(common.build_path()) @@ -200,10 +190,18 @@ if __name__ == "__main__": prepare_environment_for_gtkdoc_generation() - webkitdom.write_doc_files() - generate_documentation_for_config(common.build_path('gtkdoc-webkitdom.cfg')) - - saw_webkit1_warnings = generate_documentation_for_config(common.build_path('gtkdoc-webkitgtk.cfg')) - saw_webkit2_warnings = generate_documentation_for_config(common.build_path('gtkdoc-webkit2gtk.cfg')) - - sys.exit(saw_webkit1_warnings or saw_webkit2_warnings) + webkitdom_generator = get_generator_for_config(common.build_path('gtkdoc-webkitdom.cfg'), arguments.virtual_root) + if not webkitdom_generator: + print("gtkdoc-webkitdom.cfg does not exist! Skipping that documentation") + sys.exit(1) + saw_warnings = generate_documentation(webkitdom_generator) + if saw_warnings: + sys.exit(saw_warnings) + + webkit2_generator = get_generator_for_config(common.build_path('gtkdoc-webkit2gtk.cfg'), arguments.virtual_root, [webkitdom_generator.module_name]) + if not webkit2_generator: + print("gtkdoc-webkit2gtk.cfg does not exist! Skipping that documentation") + sys.exit(1) + saw_warnings = generate_documentation(webkit2_generator) + + sys.exit(saw_warnings) |