Skip to content

Commit

Permalink
Now with xmlness.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Aug 7, 2015
1 parent 849786d commit 270b24c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
19 changes: 12 additions & 7 deletions gtkdochelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,39 @@
import subprocess
import shutil

def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_sgml, module):
def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_file, module):
abs_src = os.path.join(source_root, src_subdir)
abs_out = os.path.join(build_root, doc_subdir)
htmldir = os.path.join(abs_out, 'html')
subprocess.check_call(['gtkdoc-scan',
'--module=' + module,
'--source-dir=' + abs_src,
'--output-dir=.'], cwd=abs_out)
if main_file.endswith('sgml'):
modeflag = '--sgml-mode'
else:
modeflag = '--xml-mode'
mkdb_cmd = ['gtkdoc-mkdb',
'--module=' + module,
'--output-format=xml',
'--sgml-mode',
modeflag,
'--source-dir=' + abs_src]
sgml_abs = os.path.join(source_root, doc_subdir, main_sgml)
main_abs = os.path.join(source_root, doc_subdir, main_file)
if len(main_sgml) > 0:
mkdb_cmd.append('--main-sgml-file=' + sgml_abs)
# Yes, this is the flag even if the file is in xml.
mkdb_cmd.append('--main-sgml-file=' + main_abs)
subprocess.check_call(mkdb_cmd, cwd=abs_out)
shutil.rmtree(htmldir, ignore_errors=True)
try:
os.mkdir(htmldir)
except Exception:
pass
mkhtml_cmd = ['gtkdoc-mkhtml', module]
if len(main_sgml) > 0:
if len(main_file) > 0:
# Workaround for
# https://bugzilla.gnome.org/show_bug.cgi?id=753145
plainfile = os.path.split(sgml_abs)[1]
shutil.copy(sgml_abs, os.path.join(abs_out, plainfile))
plainfile = os.path.split(main_abs)[1]
shutil.copy(main_abs, os.path.join(abs_out, plainfile))
mkhtml_cmd.append('../' + plainfile)
else:
mkhtml_cmd.append('../%s-docs.xml' % module)
Expand Down
13 changes: 10 additions & 3 deletions modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,24 @@ def gtkdoc(self, state, args, kwargs):
raise MesonException('Gtkdoc arg must be string.')
if not 'src_dir' in kwargs:
raise MesonException('Keyword argument src_dir missing.')
main_sgml = kwargs.get('main_sgml', '')
if not isinstance(main_sgml, str):
main_file = kwargs.get('main_sgml', '')
if not isinstance(main_file, str):
raise MesonException('Main sgml keyword argument must be a string.')
main_xml = kwargs.get('main_xml', '')
if not isinstance(main_xml, str):
raise MesonException('Main xml keyword argument must be a string.')
if main_xml != '':
if main_file != '':
raise MesonException('You can only specify main_xml or main_sgml, not both.')
main_file = main_xml
src_dir = kwargs['src_dir']
targetname = modulename + '-doc'
command = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../gtkdochelper.py"))
args = [state.environment.get_source_dir(),
state.environment.get_build_dir(),
state.subdir,
os.path.normpath(os.path.join(state.subdir, src_dir)),
main_sgml,
main_file,
modulename]
res = [build.RunTarget(targetname, command, args, state.subdir)]
if kwargs.get('install', True):
Expand Down

0 comments on commit 270b24c

Please sign in to comment.