Can generate gtkdoc documentation.

pull/218/head
Jussi Pakkanen 10 years ago
parent c12a4c1aca
commit 8b52dec6d9
  1. 68
      gtkdochelper.py
  2. 4
      interpreter.py
  3. 20
      modules/gnome.py
  4. 3
      test cases/frameworks/10 gtk-doc/doc/meson.build
  5. 15
      test cases/frameworks/10 gtk-doc/include/foo.h
  6. 3
      test cases/frameworks/10 gtk-doc/meson.build

@ -0,0 +1,68 @@
#!/usr/bin/env python3
# Copyright 2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys, os
import subprocess
import shutil
def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, 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)
subprocess.check_call(['gtkdoc-mkdb',
'--module=' + module,
'--output-format=xml',
'--source-dir=' + abs_src], cwd=abs_out)
shutil.rmtree(htmldir, ignore_errors=True)
try:
os.mkdir(htmldir)
except Exception:
pass
subprocess.check_call(['gtkdoc-mkhtml',
module,
'../%s-docs.xml' % module], cwd=htmldir)
subprocess.check_call(['gtkdoc-fixxref',
'--module=' + module,
'--module-dir=html'], cwd=abs_out)
def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module):
source = os.path.join(build_root, doc_subdir, 'html')
final_destination = os.path.join(install_prefix, datadir, module)
shutil.rmtree(final_destination, ignore_errors=True)
shutil.copytree(source, final_destination)
if __name__ == '__main__':
# source_root = '/home/jpakkane/workspace/meson/test cases/frameworks/10 gtk-doc'
# build_root = '/home/jpakkane/workspace/meson/work area'
# doc_subdir = 'doc'
# src_subdir = 'include'
# module = 'foobar'
if len(sys.argv) != 6:
print(sys.argv)
print("Bad arguments.")
sys.exit(1)
(source_root, build_root, doc_subdir, src_subdir, module) = sys.argv[1:]
build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module)
if 'MESON_INSTALL_PREFIX' in os.environ:
if 'DESTDIR' in os.environ:
installdir = os.environ['DESTDIR'] + os.environ['MESON_INSTALL_PREFIX']
else:
installdir = os.environ['MESON_INSTALL_PREFIX']
install_gtkdoc(build_root, doc_subdir, installdir, 'share/gtk-doc/html', module)

@ -908,6 +908,10 @@ class Interpreter():
outvalues.append(self.module_method_callback(v))
elif isinstance(v, build.GeneratedList):
outvalues.append(GeneratedListHolder(v))
elif isinstance(v, build.RunTarget):
if v.name in self.build.targets:
raise InterpreterException('Tried to create target %s which already exists.' % v.name)
self.build.targets[v.name] = v
else:
print(v)
raise InterpreterException('Module returned a value of unknown type.')

@ -16,7 +16,7 @@
functionality such as gobject-introspection and gresources.'''
import build
import os
import os, sys
import subprocess
from coredata import MesonException
import mlog
@ -176,6 +176,24 @@ class GnomeModule:
target_g = build.CustomTarget(targetname, state.subdir, kwargs)
return target_g
def gtkdoc(self, state, args, kwargs):
if len(args) != 1:
raise MesonException('Gtkdoc must have one positional argument.')
modulename = args[0]
if not isinstance(modulename, str):
raise MesonException('Gtkdoc arg must be string.')
if not 'src_dir' in kwargs:
raise MesonException('Keyword argument src_dir missing.')
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)),
modulename]
return build.RunTarget(targetname, command, args, state.subdir)
def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')

@ -0,0 +1,3 @@
gnome = import('gnome')
gnome.gtkdoc('foobar', src_dir : '../include')

@ -0,0 +1,15 @@
#pragma once
/**
* FooIndecision:
* @FOO_MAYBE: Something maybe
* @FOO_POSSIBLY: Something possible
*
* The indecision type.
**/
typedef enum {
FOO_MAYBE,
FOO_POSSIBLY,
} FooIndecision;

@ -0,0 +1,3 @@
project('gtkdoctest', 'c')
subdir('doc')
Loading…
Cancel
Save