Add option to generate API documentation

This commit is contained in:
Christian Dywan 2008-09-07 21:48:04 +02:00
parent cecce23061
commit ee33d8e3dd
2 changed files with 52 additions and 0 deletions

33
docs/api/wscript_build Normal file
View file

@ -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)

19
wscript
View file

@ -45,6 +45,20 @@ def configure (conf):
update_po = 'no' update_po = 'no'
conf.check_message_custom ('localization file', 'updates', update_po) 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: if not Params.g_options.disable_unique:
conf.check_pkg ('unique-1.0', destvar='UNIQUE', vnum='0.9', mandatory=False) conf.check_pkg ('unique-1.0', destvar='UNIQUE', vnum='0.9', mandatory=False)
single_instance = ['not available','yes'][conf.env['HAVE_UNIQUE'] == 1] 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, opt.add_option ('--enable-update-po', action='store_true', default=False,
help='Enables localization file updates', dest='enable_update_po') 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): def build (bld):
bld.add_subdirs ('katze midori icons') bld.add_subdirs ('katze midori icons')
@ -108,6 +124,9 @@ def build (bld):
if bld.env ()['INTLTOOL']: if bld.env ()['INTLTOOL']:
bld.add_subdirs ('po') bld.add_subdirs ('po')
if bld.env ()['GTKDOC_SCAN'] and Params.g_commands['build']:
bld.add_subdirs ('docs/api')
if bld.env ()['INTLTOOL']: if bld.env ()['INTLTOOL']:
obj = bld.create_obj ('intltool_in') obj = bld.create_obj ('intltool_in')
obj.source = 'midori.desktop.in' obj.source = 'midori.desktop.in'