summaryrefslogtreecommitdiff
path: root/giscanner/docmain.py
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2015-06-06 17:10:52 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2018-05-25 20:00:43 -0700
commite85a46ea5414e7f684277ec611c3a9effca51e42 (patch)
treed9c7e393f26641b8d0f1f45a9804a5e76bfdbe86 /giscanner/docmain.py
parentbd67726644d6466031010e766c1fb6cc7969e5b7 (diff)
downloadgobject-introspection-e85a46ea5414e7f684277ec611c3a9effca51e42.tar.gz
docwriter: Option to select output format
For generating other output formats such as DevDocs-ready HTML, we add an output format option (-f). The default output format is "mallard" which leaves the existing behaviour unchanged. We can fold the existing --write-sections-file option into the new output format option, as a new "sections" format. Closes #134.
Diffstat (limited to 'giscanner/docmain.py')
-rw-r--r--giscanner/docmain.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index 53f5206c..966b33c2 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -32,6 +32,8 @@ from .docwriter import DocWriter
from .sectionparser import generate_sections_file, write_sections_file
from .transformer import Transformer
+FORMATS = ('mallard', 'sections')
+
def doc_main(args):
parser = argparse.ArgumentParser()
@@ -45,12 +47,16 @@ def doc_main(args):
action="store", dest="language",
default="c",
help="Output language")
+ parser.add_argument("-f", "--format",
+ action="store", dest="format",
+ choices=FORMATS, default=FORMATS[0],
+ help="Output format")
parser.add_argument("-I", "--add-include-path",
action="append", dest="include_paths", default=[],
help="include paths for other GIR files")
parser.add_argument("-s", "--write-sections-file",
- action="store_true", dest="write_sections",
- help="Generate and write out a sections file")
+ action="store_const", dest="format", const="sections",
+ help="Backwards-compatible equivalent to -f sections")
args = parser.parse_args(args[1:])
if not args.output:
@@ -65,13 +71,13 @@ def doc_main(args):
extra_include_dirs.extend(args.include_paths)
transformer = Transformer.parse_from_gir(args.girfile, extra_include_dirs)
- if args.write_sections:
+ if args.format == 'sections':
sections_file = generate_sections_file(transformer)
with open(args.output, 'w') as fp:
write_sections_file(fp, sections_file)
else:
- writer = DocWriter(transformer, args.language)
+ writer = DocWriter(transformer, args.language, args.format)
writer.write(args.output)
return 0