diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-01-31 11:14:19 -0500 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-02-01 19:47:41 -0500 |
commit | eed71caaf397b596a0e98c7eaf13525d74fe06da (patch) | |
tree | e38d1426826226da7743dbaf6a9e2c44e9bf8181 | |
parent | 5559be3d6458f2c83173fe4735daa83c9532e837 (diff) | |
download | gobject-introspection-eed71caaf397b596a0e98c7eaf13525d74fe06da.tar.gz |
doctool: Switch to a computed page_style for all page templates
This is a quick cleanup before we inherit from a common template
for all pages.
35 files changed, 37 insertions, 45 deletions
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am index c43b5bdf..9865eced 100644 --- a/Makefile-giscanner.am +++ b/Makefile-giscanner.am @@ -55,18 +55,22 @@ pkgpyexec_PYTHON = \ templatedir = $(pkglibdir) nobase_template_DATA = \ giscanner/doctemplates/C/mallard-C-class.tmpl \ + giscanner/doctemplates/C/mallard-C-constructor.tmpl \ giscanner/doctemplates/C/mallard-C-default.tmpl \ giscanner/doctemplates/C/mallard-C-enum.tmpl \ giscanner/doctemplates/C/mallard-C-function.tmpl \ + giscanner/doctemplates/C/mallard-C-method.tmpl \ giscanner/doctemplates/C/mallard-C-namespace.tmpl \ giscanner/doctemplates/C/mallard-C-property.tmpl \ giscanner/doctemplates/C/mallard-C-record.tmpl \ giscanner/doctemplates/C/mallard-C-signal.tmpl \ giscanner/doctemplates/C/mallard-C-vfunc.tmpl \ giscanner/doctemplates/Python/mallard-Python-class.tmpl \ + giscanner/doctemplates/Python/mallard-Python-constructor.tmpl \ giscanner/doctemplates/Python/mallard-Python-default.tmpl \ giscanner/doctemplates/Python/mallard-Python-enum.tmpl \ giscanner/doctemplates/Python/mallard-Python-function.tmpl \ + giscanner/doctemplates/Python/mallard-Python-method.tmpl \ giscanner/doctemplates/Python/mallard-Python-namespace.tmpl \ giscanner/doctemplates/Python/mallard-Python-property.tmpl \ giscanner/doctemplates/Python/mallard-Python-record.tmpl \ diff --git a/giscanner/doctemplates/C/mallard-C-class.tmpl b/giscanner/doctemplates/C/mallard-C-class.tmpl index b0f703f9..5081f857 100644 --- a/giscanner/doctemplates/C/mallard-C-class.tmpl +++ b/giscanner/doctemplates/C/mallard-C-class.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="class" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:api="http://projectmallard.org/experimental/api/" xmlns:ui="http://projectmallard.org/experimental/ui/"> diff --git a/giscanner/doctemplates/C/mallard-C-constructor.tmpl b/giscanner/doctemplates/C/mallard-C-constructor.tmpl new file mode 100644 index 00000000..f373dfbe --- /dev/null +++ b/giscanner/doctemplates/C/mallard-C-constructor.tmpl @@ -0,0 +1 @@ +<%inherit file="mallard-C-function.tmpl"/> diff --git a/giscanner/doctemplates/C/mallard-C-default.tmpl b/giscanner/doctemplates/C/mallard-C-default.tmpl index 8326343e..c6ce1760 100644 --- a/giscanner/doctemplates/C/mallard-C-default.tmpl +++ b/giscanner/doctemplates/C/mallard-C-default.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${namespace.name}.${node.name}" type="topic" - style="" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-enum.tmpl b/giscanner/doctemplates/C/mallard-C-enum.tmpl index b59f27e6..393fae4f 100644 --- a/giscanner/doctemplates/C/mallard-C-enum.tmpl +++ b/giscanner/doctemplates/C/mallard-C-enum.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="enum" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-function.tmpl b/giscanner/doctemplates/C/mallard-C-function.tmpl index 051fb0b0..853a7619 100644 --- a/giscanner/doctemplates/C/mallard-C-function.tmpl +++ b/giscanner/doctemplates/C/mallard-C-function.tmpl @@ -1,11 +1,4 @@ <?xml version="1.0"?> -<% -page_style = 'function' -if node.is_constructor: - page_style = 'constructor' -elif node.is_method: - page_style = 'method' -%> <page id="${page_id}" type="topic" style="${page_style}" diff --git a/giscanner/doctemplates/C/mallard-C-method.tmpl b/giscanner/doctemplates/C/mallard-C-method.tmpl new file mode 100644 index 00000000..f373dfbe --- /dev/null +++ b/giscanner/doctemplates/C/mallard-C-method.tmpl @@ -0,0 +1 @@ +<%inherit file="mallard-C-function.tmpl"/> diff --git a/giscanner/doctemplates/C/mallard-C-namespace.tmpl b/giscanner/doctemplates/C/mallard-C-namespace.tmpl index 284ba238..5d39dbcb 100644 --- a/giscanner/doctemplates/C/mallard-C-namespace.tmpl +++ b/giscanner/doctemplates/C/mallard-C-namespace.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="index" type="guide" - style="namespace" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-property.tmpl b/giscanner/doctemplates/C/mallard-C-property.tmpl index a4719952..68f09ec8 100644 --- a/giscanner/doctemplates/C/mallard-C-property.tmpl +++ b/giscanner/doctemplates/C/mallard-C-property.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${namespace.name}.${node.name}" type="topic" - style="property" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-record.tmpl b/giscanner/doctemplates/C/mallard-C-record.tmpl index 1c7223a8..f0c80dc0 100644 --- a/giscanner/doctemplates/C/mallard-C-record.tmpl +++ b/giscanner/doctemplates/C/mallard-C-record.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="record" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-signal.tmpl b/giscanner/doctemplates/C/mallard-C-signal.tmpl index 69ecaad4..33ed5c2d 100644 --- a/giscanner/doctemplates/C/mallard-C-signal.tmpl +++ b/giscanner/doctemplates/C/mallard-C-signal.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${namespace.name}.${node.name}" type="topic" - style="signal" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/C/mallard-C-vfunc.tmpl b/giscanner/doctemplates/C/mallard-C-vfunc.tmpl index a35c7b52..3a00d992 100644 --- a/giscanner/doctemplates/C/mallard-C-vfunc.tmpl +++ b/giscanner/doctemplates/C/mallard-C-vfunc.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${page_id}" type="topic" - style="vfunc" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:api="http://projectmallard.org/experimental/api/" xmlns:ui="http://projectmallard.org/experimental/ui/"> diff --git a/giscanner/doctemplates/Python/mallard-Python-class.tmpl b/giscanner/doctemplates/Python/mallard-Python-class.tmpl index 6edf25db..6eef692e 100644 --- a/giscanner/doctemplates/Python/mallard-Python-class.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-class.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="class" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:api="http://projectmallard.org/experimental/api/" xmlns:ui="http://projectmallard.org/experimental/ui/"> diff --git a/giscanner/doctemplates/Python/mallard-Python-constructor.tmpl b/giscanner/doctemplates/Python/mallard-Python-constructor.tmpl new file mode 100644 index 00000000..0b740414 --- /dev/null +++ b/giscanner/doctemplates/Python/mallard-Python-constructor.tmpl @@ -0,0 +1 @@ +<%inherit file="mallard-Python-function.tmpl"/> diff --git a/giscanner/doctemplates/Python/mallard-Python-default.tmpl b/giscanner/doctemplates/Python/mallard-Python-default.tmpl index 87791059..7bc55d8d 100644 --- a/giscanner/doctemplates/Python/mallard-Python-default.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-default.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${page_id}" type="topic" - style="" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-enum.tmpl b/giscanner/doctemplates/Python/mallard-Python-enum.tmpl index 9e44ede9..55ebdf51 100644 --- a/giscanner/doctemplates/Python/mallard-Python-enum.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-enum.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="enum" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-function.tmpl b/giscanner/doctemplates/Python/mallard-Python-function.tmpl index 5ccc800a..405f2c3c 100644 --- a/giscanner/doctemplates/Python/mallard-Python-function.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-function.tmpl @@ -1,11 +1,4 @@ <?xml version="1.0"?> -<% -page_style = 'function' -if node.is_constructor: - page_style = 'constructor' -elif node.is_method: - page_style = 'method' -%> <page id="${page_id}" type="topic" style="${page_style}" diff --git a/giscanner/doctemplates/Python/mallard-Python-method.tmpl b/giscanner/doctemplates/Python/mallard-Python-method.tmpl new file mode 100644 index 00000000..0b740414 --- /dev/null +++ b/giscanner/doctemplates/Python/mallard-Python-method.tmpl @@ -0,0 +1 @@ +<%inherit file="mallard-Python-function.tmpl"/> diff --git a/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl b/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl index 935cd440..4ccf452e 100644 --- a/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="index" type="guide" - style="namespace" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-property.tmpl b/giscanner/doctemplates/Python/mallard-Python-property.tmpl index 7ef72ccb..47187a73 100644 --- a/giscanner/doctemplates/Python/mallard-Python-property.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-property.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${namespace.name}.${node.parent.name}-${node.name}" type="topic" - style="property" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-record.tmpl b/giscanner/doctemplates/Python/mallard-Python-record.tmpl index 1b00e3be..f6abd116 100644 --- a/giscanner/doctemplates/Python/mallard-Python-record.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-record.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${node.namespace.name}.${node.name}" type="guide" - style="record" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-signal.tmpl b/giscanner/doctemplates/Python/mallard-Python-signal.tmpl index f26934fb..7bfaf9c5 100644 --- a/giscanner/doctemplates/Python/mallard-Python-signal.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-signal.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${namespace.name}.${node.parent.name}-${node.name}" type="topic" - style="signal" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl b/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl index 0c93abbc..2437e56a 100644 --- a/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="${page_id}" type="topic" - style="vfunc" + style="${page_style}" xmlns="http://projectmallard.org/1.0/" xmlns:api="http://projectmallard.org/experimental/api/" xmlns:ui="http://projectmallard.org/experimental/ui/"> diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py index 8a29f249..58689227 100644 --- a/giscanner/mallardwriter.py +++ b/giscanner/mallardwriter.py @@ -56,7 +56,7 @@ def make_page_id(node): else: return '%s.%s' % (namespace.name, node.name) -def make_template_name(node, language): +def get_node_kind(node): if isinstance(node, ast.Namespace): node_kind = 'namespace' elif isinstance(node, (ast.Class, ast.Interface)): @@ -64,7 +64,12 @@ def make_template_name(node, language): elif isinstance(node, ast.Record): node_kind = 'record' elif isinstance(node, ast.Function): - node_kind = 'function' + if node.is_method: + node_kind = 'method' + elif node.is_constructor: + node_kind = 'constructor' + else: + node_kind = 'function' elif isinstance(node, ast.Enum): node_kind = 'enum' elif isinstance(node, ast.Property) and node.parent is not None: @@ -76,7 +81,7 @@ def make_template_name(node, language): else: node_kind = 'default' - return 'mallard-%s-%s.tmpl' % (language, node_kind) + return node_kind class TemplatedScanner(object): def __init__(self, specs): @@ -487,13 +492,15 @@ class MallardWriter(object): def _render_node(self, node, output): namespace = self._transformer.namespace - template_name = make_template_name(node, self._language) + node_kind = get_node_kind(node) + template_name = 'mallard-%s-%s.tmpl' % (self._language, node_kind) page_id = make_page_id(node) template = self._lookup.get_template(template_name) result = template.render(namespace=namespace, node=node, page_id=page_id, + page_style=node_kind, formatter=self._formatter) output_file_name = os.path.join(os.path.abspath(output), diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Callback.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Callback.page index 22d30c24..b79b93aa 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Callback.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Callback.page @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="DocExamples.Callback" type="topic" - style="" + style="default" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.method.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.method.page index 1c52955e..2015098f 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.method.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.method.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.Obj.method" type="topic" style="method" diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.new.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.new.page index c20d8c5f..0e010cf3 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.new.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.new.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.Obj.new" type="topic" style="constructor" diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.static_method.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.static_method.page index f0c917f5..ebf23d55 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.static_method.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj.static_method.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.Obj.static_method" type="topic" style="function" diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.array_function.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.array_function.page index a147b6bb..2b19e8d0 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.array_function.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.array_function.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.array_function" type="topic" style="function" diff --git a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.callback_function.page b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.callback_function.page index 19d10b2e..89e00a65 100644 --- a/tests/doctool/DocExamples-1.0-C-expected/DocExamples.callback_function.page +++ b/tests/doctool/DocExamples-1.0-C-expected/DocExamples.callback_function.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.callback_function" type="topic" style="function" diff --git a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Callback.page b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Callback.page index 22d30c24..b79b93aa 100644 --- a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Callback.page +++ b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Callback.page @@ -1,7 +1,7 @@ <?xml version="1.0"?> <page id="DocExamples.Callback" type="topic" - style="" + style="default" xmlns="http://projectmallard.org/1.0/" xmlns:ui="http://projectmallard.org/experimental/ui/"> <info> diff --git a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.method.page b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.method.page index 3f51bf32..748add82 100644 --- a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.method.page +++ b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.method.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.Obj.method" type="topic" style="method" diff --git a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.static_method.page b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.static_method.page index 2577eb89..efbdc41a 100644 --- a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.static_method.page +++ b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.static_method.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.Obj.static_method" type="topic" style="function" diff --git a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.array_function.page b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.array_function.page index dd686f84..3c8e86cd 100644 --- a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.array_function.page +++ b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.array_function.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.array_function" type="topic" style="function" diff --git a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.callback_function.page b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.callback_function.page index a834cfb5..58323eba 100644 --- a/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.callback_function.page +++ b/tests/doctool/DocExamples-1.0-Python-expected/DocExamples.callback_function.page @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <page id="DocExamples.callback_function" type="topic" style="function" |