| 1 |
#!/usr/bin/env python3 |
| 2 |
# |
| 3 |
# Copyright (C) 2017 Carlos Garcia Campos <[email protected]> |
| 4 |
# Copyright (C) 2019 Albert Astals Cid <[email protected]> |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
|
| 20 |
import argparse |
| 21 |
import logging |
| 22 |
import os |
| 23 |
from gtkdoc import PkgConfigGTKDoc |
| 24 |
|
| 25 |
def configure_logging(verbose): |
| 26 |
level = logging.DEBUG if verbose else logging.INFO |
| 27 |
logger = logging.getLogger('gtkdoc') |
| 28 |
logger.setLevel(level) |
| 29 |
handler = logging.StreamHandler() |
| 30 |
handler.setLevel(level) |
| 31 |
logger.addHandler(handler) |
| 32 |
if level == logging.DEBUG: |
| 33 |
handler.setFormatter(logging.Formatter('[%(asctime)s] %(message)s')) |
| 34 |
else: |
| 35 |
handler.setFormatter(logging.Formatter('%(message)s')) |
| 36 |
|
| 37 |
|
| 38 |
parser = argparse.ArgumentParser(description='Make poppler GLib API documentation.') |
| 39 |
parser.add_argument('-v', '--verbose', action='store_true', default = False, |
| 40 |
help='Whether or not to run in verbose mode.') |
| 41 |
parser.add_argument('--skip-html', action='store_true', |
| 42 |
help='Whether or not to skip HTML generation, which can be slow.') |
| 43 |
parser.add_argument('-s', '--src-dir', action='store', default='.', dest='src_dir', |
| 44 |
help='The source directory') |
| 45 |
parser.add_argument('-b', '--build-dir', action='store', default='build', dest='build_dir', |
| 46 |
help='The build directory') |
| 47 |
args = parser.parse_args() |
| 48 |
configure_logging(args.verbose) |
| 49 |
|
| 50 |
pkgconfig_file = os.path.join(args.build_dir, 'poppler-glib.pc') |
| 51 |
pkgconfig_path = os.environ.get("PKG_CONFIG_PATH") |
| 52 |
os.environ['PKG_CONFIG_PATH'] = args.build_dir |
| 53 |
if pkgconfig_path: |
| 54 |
os.environ['PKG_CONFIG_PATH'] += ':' + pkgconfig_path |
| 55 |
|
| 56 |
gtkdoc = PkgConfigGTKDoc(pkgconfig_file, { |
| 57 |
'library_path': os.path.join(args.build_dir, 'glib'), |
| 58 |
'module_name': 'poppler', |
| 59 |
'doc_dir': os.path.join(args.src_dir, 'glib', 'reference'), |
| 60 |
'output_dir': os.path.join(args.build_dir, 'glib', 'reference'), |
| 61 |
'main_sgml_file': 'poppler-docs.sgml', |
| 62 |
'source_dirs': [os.path.join(args.src_dir, 'glib'), os.path.join(args.build_dir, 'glib')], |
| 63 |
'cflags': '-I%s' % os.path.join(args.src_dir, 'glib'), |
| 64 |
'ignored_files': ['poppler-private.h', 'poppler-input-stream.h', 'poppler-cached-file-loader.h', 'demo'] |
| 65 |
}) |
| 66 |
|
| 67 |
gtkdoc.generate(not args.skip_html) |