diff --git a/docs/api/wscript_build b/docs/api/wscript_build new file mode 100644 index 00000000..7cba870e --- /dev/null +++ b/docs/api/wscript_build @@ -0,0 +1,33 @@ +#! /usr/bin/env python +# WAF build script for midori + +import pproc as subprocess + +for module in ('midori', 'katze'): + try: + if not os.access ('_build_', os.F_OK): + os.mkdir ('_build_') + if not os.access ('_build_/docs', os.F_OK): + os.mkdir ('_build_/docs') + if not os.access ('_build_/docs/api', os.F_OK): + os.mkdir ('_build_/docs/api') + subprocess.call (['gtkdoc-scan', '--module=' + module, + '--source-dir=' + module, '--output-dir=_build_/docs/api/' + module, + '--rebuild-sections', '--rebuild-types']) + os.chdir ('_build_/docs/api/' + module) + subprocess.call (['gtkdoc-mktmpl', '--module=' + module, + '--output-dir=.' + module]) + subprocess.call (['gtkdoc-mkdb', '--module=' + module, + '--source-dir=.', '--output-dir=xml', + '--source-suffixes=c,h', '--output-format=xml', + '--default-includes=%s/%s.h' % (module, module), + '--sgml-mode', '--main-sgml-file=%s.sgml' % module]) + if not os.access ('html', os.F_OK): + os.mkdir ('html') + os.chdir ('html') + subprocess.call (['gtkdoc-mkhtml', module, '../%s.sgml' % module]) + Params.pprint ('YELLOW', "Created documentation for %s." % module) + os.chdir ('../../../../..') + except Exception, msg: + print msg + Params.pprint ('RED', "Failed to create documentation for %s." % module) diff --git a/wscript b/wscript index ed38e04c..9fb4a0bb 100644 --- a/wscript +++ b/wscript @@ -45,6 +45,20 @@ def configure (conf): update_po = 'no' conf.check_message_custom ('localization file', 'updates', update_po) + if Params.g_options.enable_api_docs: + conf.find_program ('gtkdoc-scan', var='GTKDOC_SCAN') + conf.find_program ('gtkdoc-mktmpl', var='GTKDOC_MKTMPL') + conf.find_program ('gtkdoc-mkdb', var='GTKDOC_MKDB') + conf.find_program ('gtkdoc-mkhtml', var='GTKDOC_MKHTML') + if conf.env['GTKDOC_SCAN'] and conf.env['GTKDOC_MKTMPL'] \ + and conf.env['GTKDOC_MKDB'] and conf.env['GTKDOC_MKHTML']: + api_docs = 'yes' + else: + api_docs = 'not available' + else: + api_docs = 'no' + conf.check_message_custom ('generate', 'API documentation', api_docs) + if not Params.g_options.disable_unique: conf.check_pkg ('unique-1.0', destvar='UNIQUE', vnum='0.9', mandatory=False) single_instance = ['not available','yes'][conf.env['HAVE_UNIQUE'] == 1] @@ -101,6 +115,8 @@ def set_options (opt): opt.add_option ('--enable-update-po', action='store_true', default=False, help='Enables localization file updates', dest='enable_update_po') + opt.add_option ('--enable-api-docs', action='store_true', default=False, + help='Enables API documentation', dest='enable_api_docs') def build (bld): bld.add_subdirs ('katze midori icons') @@ -108,6 +124,9 @@ def build (bld): if bld.env ()['INTLTOOL']: bld.add_subdirs ('po') + if bld.env ()['GTKDOC_SCAN'] and Params.g_commands['build']: + bld.add_subdirs ('docs/api') + if bld.env ()['INTLTOOL']: obj = bld.create_obj ('intltool_in') obj.source = 'midori.desktop.in'