[gobject-introspection: 1/2] docwriter: Option to select output format
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection: 1/2] docwriter: Option to select output format
- Date: Thu, 21 Jun 2018 05:39:25 +0000 (UTC)
commit e85a46ea5414e7f684277ec611c3a9effca51e42
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Jun 6 17:10:52 2015 -0700
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.
Makefile-giscanner.am | 90 +++++++++++-----------
giscanner/docmain.py | 14 +++-
.../doctemplates/{ => mallard}/C/callback.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/class.tmpl | 0
.../doctemplates/{ => mallard}/C/constructor.tmpl | 0
.../doctemplates/{ => mallard}/C/default.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/enum.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/field.tmpl | 0
.../doctemplates/{ => mallard}/C/function.tmpl | 0
.../doctemplates/{ => mallard}/C/interface.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/method.tmpl | 0
.../doctemplates/{ => mallard}/C/namespace.tmpl | 0
.../doctemplates/{ => mallard}/C/property.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/record.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/signal.tmpl | 0
giscanner/doctemplates/{ => mallard}/C/vfunc.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/callback.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/class.tmpl | 0
.../{ => mallard}/Gjs/constructor.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/default.tmpl | 0
giscanner/doctemplates/{ => mallard}/Gjs/enum.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/field.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/function.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/interface.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/method.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/namespace.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/property.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/record.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/signal.tmpl | 0
.../doctemplates/{ => mallard}/Gjs/vfunc.tmpl | 0
.../{ => mallard}/Python/callback.tmpl | 0
.../doctemplates/{ => mallard}/Python/class.tmpl | 0
.../{ => mallard}/Python/constructor.tmpl | 0
.../doctemplates/{ => mallard}/Python/default.tmpl | 0
.../doctemplates/{ => mallard}/Python/enum.tmpl | 0
.../doctemplates/{ => mallard}/Python/field.tmpl | 0
.../{ => mallard}/Python/function.tmpl | 0
.../{ => mallard}/Python/interface.tmpl | 0
.../doctemplates/{ => mallard}/Python/method.tmpl | 0
.../{ => mallard}/Python/namespace.tmpl | 0
.../{ => mallard}/Python/property.tmpl | 0
.../doctemplates/{ => mallard}/Python/record.tmpl | 0
.../doctemplates/{ => mallard}/Python/signal.tmpl | 0
.../doctemplates/{ => mallard}/Python/vfunc.tmpl | 0
giscanner/doctemplates/{ => mallard}/base.tmpl | 0
giscanner/doctemplates/{ => mallard}/class.tmpl | 0
.../doctemplates/{ => mallard}/namespace.tmpl | 0
giscanner/docwriter.py | 33 ++++++--
48 files changed, 80 insertions(+), 57 deletions(-)
---
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am
index 271b55dd..c144fe54 100644
--- a/Makefile-giscanner.am
+++ b/Makefile-giscanner.am
@@ -56,51 +56,51 @@ pkgpyexec_PYTHON = \
templatedir = $(pkglibdir)
nobase_dist_template_DATA = \
- giscanner/doctemplates/base.tmpl \
- giscanner/doctemplates/class.tmpl \
- giscanner/doctemplates/namespace.tmpl \
- giscanner/doctemplates/C/callback.tmpl \
- giscanner/doctemplates/C/class.tmpl \
- giscanner/doctemplates/C/constructor.tmpl \
- giscanner/doctemplates/C/default.tmpl \
- giscanner/doctemplates/C/enum.tmpl \
- giscanner/doctemplates/C/function.tmpl \
- giscanner/doctemplates/C/field.tmpl \
- giscanner/doctemplates/C/interface.tmpl \
- giscanner/doctemplates/C/method.tmpl \
- giscanner/doctemplates/C/namespace.tmpl \
- giscanner/doctemplates/C/property.tmpl \
- giscanner/doctemplates/C/record.tmpl \
- giscanner/doctemplates/C/signal.tmpl \
- giscanner/doctemplates/C/vfunc.tmpl \
- giscanner/doctemplates/Python/callback.tmpl \
- giscanner/doctemplates/Python/class.tmpl \
- giscanner/doctemplates/Python/constructor.tmpl \
- giscanner/doctemplates/Python/default.tmpl \
- giscanner/doctemplates/Python/enum.tmpl \
- giscanner/doctemplates/Python/function.tmpl \
- giscanner/doctemplates/Python/field.tmpl \
- giscanner/doctemplates/Python/interface.tmpl \
- giscanner/doctemplates/Python/method.tmpl \
- giscanner/doctemplates/Python/namespace.tmpl \
- giscanner/doctemplates/Python/property.tmpl \
- giscanner/doctemplates/Python/record.tmpl \
- giscanner/doctemplates/Python/signal.tmpl \
- giscanner/doctemplates/Python/vfunc.tmpl \
- giscanner/doctemplates/Gjs/callback.tmpl \
- giscanner/doctemplates/Gjs/class.tmpl \
- giscanner/doctemplates/Gjs/constructor.tmpl \
- giscanner/doctemplates/Gjs/default.tmpl \
- giscanner/doctemplates/Gjs/enum.tmpl \
- giscanner/doctemplates/Gjs/function.tmpl \
- giscanner/doctemplates/Gjs/field.tmpl \
- giscanner/doctemplates/Gjs/interface.tmpl \
- giscanner/doctemplates/Gjs/method.tmpl \
- giscanner/doctemplates/Gjs/namespace.tmpl \
- giscanner/doctemplates/Gjs/property.tmpl \
- giscanner/doctemplates/Gjs/record.tmpl \
- giscanner/doctemplates/Gjs/signal.tmpl \
- giscanner/doctemplates/Gjs/vfunc.tmpl
+ giscanner/doctemplates/mallard/base.tmpl \
+ giscanner/doctemplates/mallard/class.tmpl \
+ giscanner/doctemplates/mallard/namespace.tmpl \
+ giscanner/doctemplates/mallard/C/callback.tmpl \
+ giscanner/doctemplates/mallard/C/class.tmpl \
+ giscanner/doctemplates/mallard/C/constructor.tmpl \
+ giscanner/doctemplates/mallard/C/default.tmpl \
+ giscanner/doctemplates/mallard/C/enum.tmpl \
+ giscanner/doctemplates/mallard/C/function.tmpl \
+ giscanner/doctemplates/mallard/C/field.tmpl \
+ giscanner/doctemplates/mallard/C/interface.tmpl \
+ giscanner/doctemplates/mallard/C/method.tmpl \
+ giscanner/doctemplates/mallard/C/namespace.tmpl \
+ giscanner/doctemplates/mallard/C/property.tmpl \
+ giscanner/doctemplates/mallard/C/record.tmpl \
+ giscanner/doctemplates/mallard/C/signal.tmpl \
+ giscanner/doctemplates/mallard/C/vfunc.tmpl \
+ giscanner/doctemplates/mallard/Python/callback.tmpl \
+ giscanner/doctemplates/mallard/Python/class.tmpl \
+ giscanner/doctemplates/mallard/Python/constructor.tmpl \
+ giscanner/doctemplates/mallard/Python/default.tmpl \
+ giscanner/doctemplates/mallard/Python/enum.tmpl \
+ giscanner/doctemplates/mallard/Python/function.tmpl \
+ giscanner/doctemplates/mallard/Python/field.tmpl \
+ giscanner/doctemplates/mallard/Python/interface.tmpl \
+ giscanner/doctemplates/mallard/Python/method.tmpl \
+ giscanner/doctemplates/mallard/Python/namespace.tmpl \
+ giscanner/doctemplates/mallard/Python/property.tmpl \
+ giscanner/doctemplates/mallard/Python/record.tmpl \
+ giscanner/doctemplates/mallard/Python/signal.tmpl \
+ giscanner/doctemplates/mallard/Python/vfunc.tmpl \
+ giscanner/doctemplates/mallard/Gjs/callback.tmpl \
+ giscanner/doctemplates/mallard/Gjs/class.tmpl \
+ giscanner/doctemplates/mallard/Gjs/constructor.tmpl \
+ giscanner/doctemplates/mallard/Gjs/default.tmpl \
+ giscanner/doctemplates/mallard/Gjs/enum.tmpl \
+ giscanner/doctemplates/mallard/Gjs/function.tmpl \
+ giscanner/doctemplates/mallard/Gjs/field.tmpl \
+ giscanner/doctemplates/mallard/Gjs/interface.tmpl \
+ giscanner/doctemplates/mallard/Gjs/method.tmpl \
+ giscanner/doctemplates/mallard/Gjs/namespace.tmpl \
+ giscanner/doctemplates/mallard/Gjs/property.tmpl \
+ giscanner/doctemplates/mallard/Gjs/record.tmpl \
+ giscanner/doctemplates/mallard/Gjs/signal.tmpl \
+ giscanner/doctemplates/mallard/Gjs/vfunc.tmpl
_giscanner_la_CFLAGS = \
$(PYTHON_INCLUDES) \
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
similarity index 100%
rename from giscanner/doctemplates/C/callback.tmpl
rename to giscanner/doctemplates/mallard/C/callback.tmpl
diff --git a/giscanner/doctemplates/C/class.tmpl b/giscanner/doctemplates/mallard/C/class.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/class.tmpl
rename to giscanner/doctemplates/mallard/C/class.tmpl
diff --git a/giscanner/doctemplates/C/constructor.tmpl b/giscanner/doctemplates/mallard/C/constructor.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/constructor.tmpl
rename to giscanner/doctemplates/mallard/C/constructor.tmpl
diff --git a/giscanner/doctemplates/C/default.tmpl b/giscanner/doctemplates/mallard/C/default.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/default.tmpl
rename to giscanner/doctemplates/mallard/C/default.tmpl
diff --git a/giscanner/doctemplates/C/enum.tmpl b/giscanner/doctemplates/mallard/C/enum.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/enum.tmpl
rename to giscanner/doctemplates/mallard/C/enum.tmpl
diff --git a/giscanner/doctemplates/C/field.tmpl b/giscanner/doctemplates/mallard/C/field.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/field.tmpl
rename to giscanner/doctemplates/mallard/C/field.tmpl
diff --git a/giscanner/doctemplates/C/function.tmpl b/giscanner/doctemplates/mallard/C/function.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/function.tmpl
rename to giscanner/doctemplates/mallard/C/function.tmpl
diff --git a/giscanner/doctemplates/C/interface.tmpl b/giscanner/doctemplates/mallard/C/interface.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/interface.tmpl
rename to giscanner/doctemplates/mallard/C/interface.tmpl
diff --git a/giscanner/doctemplates/C/method.tmpl b/giscanner/doctemplates/mallard/C/method.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/method.tmpl
rename to giscanner/doctemplates/mallard/C/method.tmpl
diff --git a/giscanner/doctemplates/C/namespace.tmpl b/giscanner/doctemplates/mallard/C/namespace.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/namespace.tmpl
rename to giscanner/doctemplates/mallard/C/namespace.tmpl
diff --git a/giscanner/doctemplates/C/property.tmpl b/giscanner/doctemplates/mallard/C/property.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/property.tmpl
rename to giscanner/doctemplates/mallard/C/property.tmpl
diff --git a/giscanner/doctemplates/C/record.tmpl b/giscanner/doctemplates/mallard/C/record.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/record.tmpl
rename to giscanner/doctemplates/mallard/C/record.tmpl
diff --git a/giscanner/doctemplates/C/signal.tmpl b/giscanner/doctemplates/mallard/C/signal.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/signal.tmpl
rename to giscanner/doctemplates/mallard/C/signal.tmpl
diff --git a/giscanner/doctemplates/C/vfunc.tmpl b/giscanner/doctemplates/mallard/C/vfunc.tmpl
similarity index 100%
rename from giscanner/doctemplates/C/vfunc.tmpl
rename to giscanner/doctemplates/mallard/C/vfunc.tmpl
diff --git a/giscanner/doctemplates/Gjs/callback.tmpl b/giscanner/doctemplates/mallard/Gjs/callback.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/callback.tmpl
rename to giscanner/doctemplates/mallard/Gjs/callback.tmpl
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/mallard/Gjs/class.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/class.tmpl
rename to giscanner/doctemplates/mallard/Gjs/class.tmpl
diff --git a/giscanner/doctemplates/Gjs/constructor.tmpl b/giscanner/doctemplates/mallard/Gjs/constructor.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/constructor.tmpl
rename to giscanner/doctemplates/mallard/Gjs/constructor.tmpl
diff --git a/giscanner/doctemplates/Gjs/default.tmpl b/giscanner/doctemplates/mallard/Gjs/default.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/default.tmpl
rename to giscanner/doctemplates/mallard/Gjs/default.tmpl
diff --git a/giscanner/doctemplates/Gjs/enum.tmpl b/giscanner/doctemplates/mallard/Gjs/enum.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/enum.tmpl
rename to giscanner/doctemplates/mallard/Gjs/enum.tmpl
diff --git a/giscanner/doctemplates/Gjs/field.tmpl b/giscanner/doctemplates/mallard/Gjs/field.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/field.tmpl
rename to giscanner/doctemplates/mallard/Gjs/field.tmpl
diff --git a/giscanner/doctemplates/Gjs/function.tmpl b/giscanner/doctemplates/mallard/Gjs/function.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/function.tmpl
rename to giscanner/doctemplates/mallard/Gjs/function.tmpl
diff --git a/giscanner/doctemplates/Gjs/interface.tmpl b/giscanner/doctemplates/mallard/Gjs/interface.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/interface.tmpl
rename to giscanner/doctemplates/mallard/Gjs/interface.tmpl
diff --git a/giscanner/doctemplates/Gjs/method.tmpl b/giscanner/doctemplates/mallard/Gjs/method.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/method.tmpl
rename to giscanner/doctemplates/mallard/Gjs/method.tmpl
diff --git a/giscanner/doctemplates/Gjs/namespace.tmpl b/giscanner/doctemplates/mallard/Gjs/namespace.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/namespace.tmpl
rename to giscanner/doctemplates/mallard/Gjs/namespace.tmpl
diff --git a/giscanner/doctemplates/Gjs/property.tmpl b/giscanner/doctemplates/mallard/Gjs/property.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/property.tmpl
rename to giscanner/doctemplates/mallard/Gjs/property.tmpl
diff --git a/giscanner/doctemplates/Gjs/record.tmpl b/giscanner/doctemplates/mallard/Gjs/record.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/record.tmpl
rename to giscanner/doctemplates/mallard/Gjs/record.tmpl
diff --git a/giscanner/doctemplates/Gjs/signal.tmpl b/giscanner/doctemplates/mallard/Gjs/signal.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/signal.tmpl
rename to giscanner/doctemplates/mallard/Gjs/signal.tmpl
diff --git a/giscanner/doctemplates/Gjs/vfunc.tmpl b/giscanner/doctemplates/mallard/Gjs/vfunc.tmpl
similarity index 100%
rename from giscanner/doctemplates/Gjs/vfunc.tmpl
rename to giscanner/doctemplates/mallard/Gjs/vfunc.tmpl
diff --git a/giscanner/doctemplates/Python/callback.tmpl b/giscanner/doctemplates/mallard/Python/callback.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/callback.tmpl
rename to giscanner/doctemplates/mallard/Python/callback.tmpl
diff --git a/giscanner/doctemplates/Python/class.tmpl b/giscanner/doctemplates/mallard/Python/class.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/class.tmpl
rename to giscanner/doctemplates/mallard/Python/class.tmpl
diff --git a/giscanner/doctemplates/Python/constructor.tmpl
b/giscanner/doctemplates/mallard/Python/constructor.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/constructor.tmpl
rename to giscanner/doctemplates/mallard/Python/constructor.tmpl
diff --git a/giscanner/doctemplates/Python/default.tmpl b/giscanner/doctemplates/mallard/Python/default.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/default.tmpl
rename to giscanner/doctemplates/mallard/Python/default.tmpl
diff --git a/giscanner/doctemplates/Python/enum.tmpl b/giscanner/doctemplates/mallard/Python/enum.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/enum.tmpl
rename to giscanner/doctemplates/mallard/Python/enum.tmpl
diff --git a/giscanner/doctemplates/Python/field.tmpl b/giscanner/doctemplates/mallard/Python/field.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/field.tmpl
rename to giscanner/doctemplates/mallard/Python/field.tmpl
diff --git a/giscanner/doctemplates/Python/function.tmpl b/giscanner/doctemplates/mallard/Python/function.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/function.tmpl
rename to giscanner/doctemplates/mallard/Python/function.tmpl
diff --git a/giscanner/doctemplates/Python/interface.tmpl
b/giscanner/doctemplates/mallard/Python/interface.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/interface.tmpl
rename to giscanner/doctemplates/mallard/Python/interface.tmpl
diff --git a/giscanner/doctemplates/Python/method.tmpl b/giscanner/doctemplates/mallard/Python/method.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/method.tmpl
rename to giscanner/doctemplates/mallard/Python/method.tmpl
diff --git a/giscanner/doctemplates/Python/namespace.tmpl
b/giscanner/doctemplates/mallard/Python/namespace.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/namespace.tmpl
rename to giscanner/doctemplates/mallard/Python/namespace.tmpl
diff --git a/giscanner/doctemplates/Python/property.tmpl b/giscanner/doctemplates/mallard/Python/property.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/property.tmpl
rename to giscanner/doctemplates/mallard/Python/property.tmpl
diff --git a/giscanner/doctemplates/Python/record.tmpl b/giscanner/doctemplates/mallard/Python/record.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/record.tmpl
rename to giscanner/doctemplates/mallard/Python/record.tmpl
diff --git a/giscanner/doctemplates/Python/signal.tmpl b/giscanner/doctemplates/mallard/Python/signal.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/signal.tmpl
rename to giscanner/doctemplates/mallard/Python/signal.tmpl
diff --git a/giscanner/doctemplates/Python/vfunc.tmpl b/giscanner/doctemplates/mallard/Python/vfunc.tmpl
similarity index 100%
rename from giscanner/doctemplates/Python/vfunc.tmpl
rename to giscanner/doctemplates/mallard/Python/vfunc.tmpl
diff --git a/giscanner/doctemplates/base.tmpl b/giscanner/doctemplates/mallard/base.tmpl
similarity index 100%
rename from giscanner/doctemplates/base.tmpl
rename to giscanner/doctemplates/mallard/base.tmpl
diff --git a/giscanner/doctemplates/class.tmpl b/giscanner/doctemplates/mallard/class.tmpl
similarity index 100%
rename from giscanner/doctemplates/class.tmpl
rename to giscanner/doctemplates/mallard/class.tmpl
diff --git a/giscanner/doctemplates/namespace.tmpl b/giscanner/doctemplates/mallard/namespace.tmpl
similarity index 100%
rename from giscanner/doctemplates/namespace.tmpl
rename to 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]