summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-06-21 05:38:51 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2018-06-21 05:38:51 +0000
commitd3efb8537a07133c2718deaa53b39a3433eef54b (patch)
tree1f578f7515eec3bc9dee219e2e3e47a895854dc2 /giscanner
parent1636bb0ef2b294ca07eea0aae51f16a984044c8c (diff)
parente85a46ea5414e7f684277ec611c3a9effca51e42 (diff)
downloadgobject-introspection-d3efb8537a07133c2718deaa53b39a3433eef54b.tar.gz
Merge branch '134-output-formats' into 'master'
Resolve "Allow multiple output formats" Closes #134 See merge request GNOME/gobject-introspection!4
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/docmain.py14
-rw-r--r--giscanner/doctemplates/mallard/C/callback.tmpl (renamed from giscanner/doctemplates/C/callback.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/class.tmpl (renamed from giscanner/doctemplates/C/class.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/constructor.tmpl (renamed from giscanner/doctemplates/C/constructor.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/default.tmpl (renamed from giscanner/doctemplates/C/default.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/enum.tmpl (renamed from giscanner/doctemplates/C/enum.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/field.tmpl (renamed from giscanner/doctemplates/C/field.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/function.tmpl (renamed from giscanner/doctemplates/C/function.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/interface.tmpl (renamed from giscanner/doctemplates/C/interface.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/method.tmpl (renamed from giscanner/doctemplates/C/method.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/namespace.tmpl (renamed from giscanner/doctemplates/C/namespace.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/property.tmpl (renamed from giscanner/doctemplates/C/property.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/record.tmpl (renamed from giscanner/doctemplates/C/record.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/signal.tmpl (renamed from giscanner/doctemplates/C/signal.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/C/vfunc.tmpl (renamed from giscanner/doctemplates/C/vfunc.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/callback.tmpl (renamed from giscanner/doctemplates/Gjs/callback.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/class.tmpl (renamed from giscanner/doctemplates/Gjs/class.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/constructor.tmpl (renamed from giscanner/doctemplates/Gjs/constructor.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/default.tmpl (renamed from giscanner/doctemplates/Gjs/default.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/enum.tmpl (renamed from giscanner/doctemplates/Gjs/enum.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/field.tmpl (renamed from giscanner/doctemplates/Gjs/field.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/function.tmpl (renamed from giscanner/doctemplates/Gjs/function.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/interface.tmpl (renamed from giscanner/doctemplates/Gjs/interface.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/method.tmpl (renamed from giscanner/doctemplates/Gjs/method.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/namespace.tmpl (renamed from giscanner/doctemplates/Gjs/namespace.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/property.tmpl (renamed from giscanner/doctemplates/Gjs/property.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/record.tmpl (renamed from giscanner/doctemplates/Gjs/record.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/signal.tmpl (renamed from giscanner/doctemplates/Gjs/signal.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Gjs/vfunc.tmpl (renamed from giscanner/doctemplates/Gjs/vfunc.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/callback.tmpl (renamed from giscanner/doctemplates/Python/callback.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/class.tmpl (renamed from giscanner/doctemplates/Python/class.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/constructor.tmpl (renamed from giscanner/doctemplates/Python/constructor.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/default.tmpl (renamed from giscanner/doctemplates/Python/default.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/enum.tmpl (renamed from giscanner/doctemplates/Python/enum.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/field.tmpl (renamed from giscanner/doctemplates/Python/field.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/function.tmpl (renamed from giscanner/doctemplates/Python/function.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/interface.tmpl (renamed from giscanner/doctemplates/Python/interface.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/method.tmpl (renamed from giscanner/doctemplates/Python/method.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/namespace.tmpl (renamed from giscanner/doctemplates/Python/namespace.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/property.tmpl (renamed from giscanner/doctemplates/Python/property.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/record.tmpl (renamed from giscanner/doctemplates/Python/record.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/signal.tmpl (renamed from giscanner/doctemplates/Python/signal.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/Python/vfunc.tmpl (renamed from giscanner/doctemplates/Python/vfunc.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/base.tmpl (renamed from giscanner/doctemplates/base.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/class.tmpl (renamed from giscanner/doctemplates/class.tmpl)0
-rw-r--r--giscanner/doctemplates/mallard/namespace.tmpl (renamed from giscanner/doctemplates/namespace.tmpl)0
-rw-r--r--giscanner/docwriter.py33
47 files changed, 35 insertions, 12 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
diff --git a/giscanner/doctemplates/C/callback.tmpl b/giscanner/doctemplates/mallard/C/callback.tmpl
index f285ff68..f285ff68 100644
--- a/giscanner/doctemplates/C/callback.tmpl
+++ b/giscanner/doctemplates/mallard/C/callback.tmpl
diff --git a/giscanner/doctemplates/C/class.tmpl b/giscanner/doctemplates/mallard/C/class.tmpl
index 3f18b021..3f18b021 100644
--- a/giscanner/doctemplates/C/class.tmpl
+++ b/giscanner/doctemplates/mallard/C/class.tmpl
diff --git a/giscanner/doctemplates/C/constructor.tmpl b/giscanner/doctemplates/mallard/C/constructor.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/C/constructor.tmpl
+++ b/giscanner/doctemplates/mallard/C/constructor.tmpl
diff --git a/giscanner/doctemplates/C/default.tmpl b/giscanner/doctemplates/mallard/C/default.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/C/default.tmpl
+++ b/giscanner/doctemplates/mallard/C/default.tmpl
diff --git a/giscanner/doctemplates/C/enum.tmpl b/giscanner/doctemplates/mallard/C/enum.tmpl
index 1523e0df..1523e0df 100644
--- a/giscanner/doctemplates/C/enum.tmpl
+++ b/giscanner/doctemplates/mallard/C/enum.tmpl
diff --git a/giscanner/doctemplates/C/field.tmpl b/giscanner/doctemplates/mallard/C/field.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/C/field.tmpl
+++ b/giscanner/doctemplates/mallard/C/field.tmpl
diff --git a/giscanner/doctemplates/C/function.tmpl b/giscanner/doctemplates/mallard/C/function.tmpl
index 3f9e6275..3f9e6275 100644
--- a/giscanner/doctemplates/C/function.tmpl
+++ b/giscanner/doctemplates/mallard/C/function.tmpl
diff --git a/giscanner/doctemplates/C/interface.tmpl b/giscanner/doctemplates/mallard/C/interface.tmpl
index 3f18b021..3f18b021 100644
--- a/giscanner/doctemplates/C/interface.tmpl
+++ b/giscanner/doctemplates/mallard/C/interface.tmpl
diff --git a/giscanner/doctemplates/C/method.tmpl b/giscanner/doctemplates/mallard/C/method.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/C/method.tmpl
+++ b/giscanner/doctemplates/mallard/C/method.tmpl
diff --git a/giscanner/doctemplates/C/namespace.tmpl b/giscanner/doctemplates/mallard/C/namespace.tmpl
index cb8195da..cb8195da 100644
--- a/giscanner/doctemplates/C/namespace.tmpl
+++ b/giscanner/doctemplates/mallard/C/namespace.tmpl
diff --git a/giscanner/doctemplates/C/property.tmpl b/giscanner/doctemplates/mallard/C/property.tmpl
index 6ec9e8e1..6ec9e8e1 100644
--- a/giscanner/doctemplates/C/property.tmpl
+++ b/giscanner/doctemplates/mallard/C/property.tmpl
diff --git a/giscanner/doctemplates/C/record.tmpl b/giscanner/doctemplates/mallard/C/record.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/C/record.tmpl
+++ b/giscanner/doctemplates/mallard/C/record.tmpl
diff --git a/giscanner/doctemplates/C/signal.tmpl b/giscanner/doctemplates/mallard/C/signal.tmpl
index 28c0b740..28c0b740 100644
--- a/giscanner/doctemplates/C/signal.tmpl
+++ b/giscanner/doctemplates/mallard/C/signal.tmpl
diff --git a/giscanner/doctemplates/C/vfunc.tmpl b/giscanner/doctemplates/mallard/C/vfunc.tmpl
index aa0394f4..aa0394f4 100644
--- a/giscanner/doctemplates/C/vfunc.tmpl
+++ b/giscanner/doctemplates/mallard/C/vfunc.tmpl
diff --git a/giscanner/doctemplates/Gjs/callback.tmpl b/giscanner/doctemplates/mallard/Gjs/callback.tmpl
index d7b97794..d7b97794 100644
--- a/giscanner/doctemplates/Gjs/callback.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/callback.tmpl
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/mallard/Gjs/class.tmpl
index 7694d726..7694d726 100644
--- a/giscanner/doctemplates/Gjs/class.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/class.tmpl
diff --git a/giscanner/doctemplates/Gjs/constructor.tmpl b/giscanner/doctemplates/mallard/Gjs/constructor.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/Gjs/constructor.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/constructor.tmpl
diff --git a/giscanner/doctemplates/Gjs/default.tmpl b/giscanner/doctemplates/mallard/Gjs/default.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/Gjs/default.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/default.tmpl
diff --git a/giscanner/doctemplates/Gjs/enum.tmpl b/giscanner/doctemplates/mallard/Gjs/enum.tmpl
index e239de18..e239de18 100644
--- a/giscanner/doctemplates/Gjs/enum.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/enum.tmpl
diff --git a/giscanner/doctemplates/Gjs/field.tmpl b/giscanner/doctemplates/mallard/Gjs/field.tmpl
index dda82469..dda82469 100644
--- a/giscanner/doctemplates/Gjs/field.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/field.tmpl
diff --git a/giscanner/doctemplates/Gjs/function.tmpl b/giscanner/doctemplates/mallard/Gjs/function.tmpl
index 8e9d7417..8e9d7417 100644
--- a/giscanner/doctemplates/Gjs/function.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/function.tmpl
diff --git a/giscanner/doctemplates/Gjs/interface.tmpl b/giscanner/doctemplates/mallard/Gjs/interface.tmpl
index 2f01f20f..2f01f20f 100644
--- a/giscanner/doctemplates/Gjs/interface.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/interface.tmpl
diff --git a/giscanner/doctemplates/Gjs/method.tmpl b/giscanner/doctemplates/mallard/Gjs/method.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/Gjs/method.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/method.tmpl
diff --git a/giscanner/doctemplates/Gjs/namespace.tmpl b/giscanner/doctemplates/mallard/Gjs/namespace.tmpl
index 4d80c2a5..4d80c2a5 100644
--- a/giscanner/doctemplates/Gjs/namespace.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/namespace.tmpl
diff --git a/giscanner/doctemplates/Gjs/property.tmpl b/giscanner/doctemplates/mallard/Gjs/property.tmpl
index dda82469..dda82469 100644
--- a/giscanner/doctemplates/Gjs/property.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/property.tmpl
diff --git a/giscanner/doctemplates/Gjs/record.tmpl b/giscanner/doctemplates/mallard/Gjs/record.tmpl
index 1523e0df..1523e0df 100644
--- a/giscanner/doctemplates/Gjs/record.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/record.tmpl
diff --git a/giscanner/doctemplates/Gjs/signal.tmpl b/giscanner/doctemplates/mallard/Gjs/signal.tmpl
index 7c508162..7c508162 100644
--- a/giscanner/doctemplates/Gjs/signal.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/signal.tmpl
diff --git a/giscanner/doctemplates/Gjs/vfunc.tmpl b/giscanner/doctemplates/mallard/Gjs/vfunc.tmpl
index 2bd1127d..2bd1127d 100644
--- a/giscanner/doctemplates/Gjs/vfunc.tmpl
+++ b/giscanner/doctemplates/mallard/Gjs/vfunc.tmpl
diff --git a/giscanner/doctemplates/Python/callback.tmpl b/giscanner/doctemplates/mallard/Python/callback.tmpl
index 4fcbfe3b..4fcbfe3b 100644
--- a/giscanner/doctemplates/Python/callback.tmpl
+++ b/giscanner/doctemplates/mallard/Python/callback.tmpl
diff --git a/giscanner/doctemplates/Python/class.tmpl b/giscanner/doctemplates/mallard/Python/class.tmpl
index 51d25a91..51d25a91 100644
--- a/giscanner/doctemplates/Python/class.tmpl
+++ b/giscanner/doctemplates/mallard/Python/class.tmpl
diff --git a/giscanner/doctemplates/Python/constructor.tmpl b/giscanner/doctemplates/mallard/Python/constructor.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/Python/constructor.tmpl
+++ b/giscanner/doctemplates/mallard/Python/constructor.tmpl
diff --git a/giscanner/doctemplates/Python/default.tmpl b/giscanner/doctemplates/mallard/Python/default.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/Python/default.tmpl
+++ b/giscanner/doctemplates/mallard/Python/default.tmpl
diff --git a/giscanner/doctemplates/Python/enum.tmpl b/giscanner/doctemplates/mallard/Python/enum.tmpl
index 35cdd439..35cdd439 100644
--- a/giscanner/doctemplates/Python/enum.tmpl
+++ b/giscanner/doctemplates/mallard/Python/enum.tmpl
diff --git a/giscanner/doctemplates/Python/field.tmpl b/giscanner/doctemplates/mallard/Python/field.tmpl
index b66ae926..b66ae926 100644
--- a/giscanner/doctemplates/Python/field.tmpl
+++ b/giscanner/doctemplates/mallard/Python/field.tmpl
diff --git a/giscanner/doctemplates/Python/function.tmpl b/giscanner/doctemplates/mallard/Python/function.tmpl
index 7ad1ac04..7ad1ac04 100644
--- a/giscanner/doctemplates/Python/function.tmpl
+++ b/giscanner/doctemplates/mallard/Python/function.tmpl
diff --git a/giscanner/doctemplates/Python/interface.tmpl b/giscanner/doctemplates/mallard/Python/interface.tmpl
index b3596a8d..b3596a8d 100644
--- a/giscanner/doctemplates/Python/interface.tmpl
+++ b/giscanner/doctemplates/mallard/Python/interface.tmpl
diff --git a/giscanner/doctemplates/Python/method.tmpl b/giscanner/doctemplates/mallard/Python/method.tmpl
index a03d2825..a03d2825 100644
--- a/giscanner/doctemplates/Python/method.tmpl
+++ b/giscanner/doctemplates/mallard/Python/method.tmpl
diff --git a/giscanner/doctemplates/Python/namespace.tmpl b/giscanner/doctemplates/mallard/Python/namespace.tmpl
index 4d80c2a5..4d80c2a5 100644
--- a/giscanner/doctemplates/Python/namespace.tmpl
+++ b/giscanner/doctemplates/mallard/Python/namespace.tmpl
diff --git a/giscanner/doctemplates/Python/property.tmpl b/giscanner/doctemplates/mallard/Python/property.tmpl
index c93d59b7..c93d59b7 100644
--- a/giscanner/doctemplates/Python/property.tmpl
+++ b/giscanner/doctemplates/mallard/Python/property.tmpl
diff --git a/giscanner/doctemplates/Python/record.tmpl b/giscanner/doctemplates/mallard/Python/record.tmpl
index 1523e0df..1523e0df 100644
--- a/giscanner/doctemplates/Python/record.tmpl
+++ b/giscanner/doctemplates/mallard/Python/record.tmpl
diff --git a/giscanner/doctemplates/Python/signal.tmpl b/giscanner/doctemplates/mallard/Python/signal.tmpl
index c61b7229..c61b7229 100644
--- a/giscanner/doctemplates/Python/signal.tmpl
+++ b/giscanner/doctemplates/mallard/Python/signal.tmpl
diff --git a/giscanner/doctemplates/Python/vfunc.tmpl b/giscanner/doctemplates/mallard/Python/vfunc.tmpl
index 2c532e70..2c532e70 100644
--- a/giscanner/doctemplates/Python/vfunc.tmpl
+++ b/giscanner/doctemplates/mallard/Python/vfunc.tmpl
diff --git a/giscanner/doctemplates/base.tmpl b/giscanner/doctemplates/mallard/base.tmpl
index 7a1d8db2..7a1d8db2 100644
--- a/giscanner/doctemplates/base.tmpl
+++ b/giscanner/doctemplates/mallard/base.tmpl
diff --git a/giscanner/doctemplates/class.tmpl b/giscanner/doctemplates/mallard/class.tmpl
index 86333866..86333866 100644
--- a/giscanner/doctemplates/class.tmpl
+++ b/giscanner/doctemplates/mallard/class.tmpl
diff --git a/giscanner/doctemplates/namespace.tmpl b/giscanner/doctemplates/mallard/namespace.tmpl
index d4edcec0..d4edcec0 100644
--- a/giscanner/doctemplates/namespace.tmpl
+++ b/giscanner/doctemplates/mallard/namespace.tmpl
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index cfc41729..d9c2ed57 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -462,6 +462,8 @@ class DocFormatter(object):
class DocFormatterC(DocFormatter):
language = "C"
mime_type = "text/x-csrc"
+ output_format = "mallard"
+ output_extension = ".page"
fundamentals = {
"TRUE": "TRUE",
@@ -507,6 +509,8 @@ class DocFormatterIntrospectableBase(DocFormatter):
class DocFormatterPython(DocFormatterIntrospectableBase):
language = "Python"
mime_type = "text/python"
+ output_format = "mallard"
+ output_extension = ".page"
fundamentals = {
"TRUE": "True",
@@ -514,6 +518,12 @@ class DocFormatterPython(DocFormatterIntrospectableBase):
"NULL": "None",
}
+ def get_output_format(self):
+ return 'mallard'
+
+ def get_output_extension(self):
+ return 'page'
+
def should_render_node(self, node):
if getattr(node, "is_constructor", False):
return False
@@ -585,6 +595,8 @@ class DocFormatterPython(DocFormatterIntrospectableBase):
class DocFormatterGjs(DocFormatterIntrospectableBase):
language = "Gjs"
mime_type = "text/x-gjs"
+ output_format = "mallard"
+ output_extension = ".page"
fundamentals = {
"TRUE": "true",
@@ -878,20 +890,23 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
for p in construct_params)
LANGUAGES = {
- "c": DocFormatterC,
- "python": DocFormatterPython,
- "gjs": DocFormatterGjs,
+ "mallard": {
+ "c": DocFormatterC,
+ "python": DocFormatterPython,
+ "gjs": DocFormatterGjs,
+ },
}
class DocWriter(object):
- def __init__(self, transformer, language):
+ def __init__(self, transformer, language, output_format):
self._transformer = transformer
try:
- formatter_class = LANGUAGES[language.lower()]
+ formatter_class = LANGUAGES[output_format][language.lower()]
except KeyError:
- raise SystemExit("Unsupported language: %s" % (language, ))
+ raise SystemExit("Unsupported language %s for output format %s" %
+ (language, output_format))
self._formatter = formatter_class(self._transformer)
self._language = self._formatter.language
@@ -905,7 +920,8 @@ class DocWriter(object):
else:
srcdir = os.path.dirname(__file__)
- template_dir = os.path.join(srcdir, 'doctemplates')
+ template_dir = os.path.join(srcdir, 'doctemplates',
+ self._formatter.output_format)
return TemplateLookup(directories=[template_dir],
module_directory=tempfile.mkdtemp(),
@@ -955,7 +971,8 @@ class DocWriter(object):
formatter=self._formatter,
ast=ast)
+ output_base_name = page_id + self._formatter.output_extension
output_file_name = os.path.join(os.path.abspath(output),
- page_id + '.page')
+ output_base_name)
with open(output_file_name, 'wb') as fp:
fp.write(result)