diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-01-31 11:46:13 -0500 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-02-01 19:47:41 -0500 |
commit | 9c68ba7c6f8b6b7367ccad1877d28cd526045961 (patch) | |
tree | 115590a1b08d8bbc100b75ef9d12c2a9315521ff /giscanner | |
parent | bfeac67a02b618e1e771db3e05601bde9b0fb5d8 (diff) | |
download | gobject-introspection-9c68ba7c6f8b6b7367ccad1877d28cd526045961.tar.gz |
doctool: Use a base template for all pages
Diffstat (limited to 'giscanner')
20 files changed, 104 insertions, 239 deletions
diff --git a/giscanner/doctemplates/C/mallard-C-class.tmpl b/giscanner/doctemplates/C/mallard-C-class.tmpl index 3a208447..b1be35e4 100644 --- a/giscanner/doctemplates/C/mallard-C-class.tmpl +++ b/giscanner/doctemplates/C/mallard-C-class.tmpl @@ -1,18 +1,8 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index" group="class"/> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -% if node.version: -<p>Since ${node.version}</p> -% endif +<%! page_type="guide" %>\ +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> +${parent.content()} +${self.since_version()} <synopsis ui:expanded="no"> <title>Hierarchy</title> <tree> @@ -45,4 +35,4 @@ ${formatter.format(node, node.doc)} <links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist"> <title>Other</title> </links> -</page> +</%block> diff --git a/giscanner/doctemplates/C/mallard-C-default.tmpl b/giscanner/doctemplates/C/mallard-C-default.tmpl index d2c41056..991f29be 100644 --- a/giscanner/doctemplates/C/mallard-C-default.tmpl +++ b/giscanner/doctemplates/C/mallard-C-default.tmpl @@ -1,11 +1 @@ -<?xml version="1.0"?> -<page id="${namespace.name}.${node.name}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +<%inherit file="mallard-base.tmpl"/> diff --git a/giscanner/doctemplates/C/mallard-C-enum.tmpl b/giscanner/doctemplates/C/mallard-C-enum.tmpl index 7283366d..cfe71c15 100644 --- a/giscanner/doctemplates/C/mallard-C-enum.tmpl +++ b/giscanner/doctemplates/C/mallard-C-enum.tmpl @@ -1,12 +1,2 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index"/> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +<%! page_type="guide" %>\ +<%inherit file="mallard-base.tmpl"/> diff --git a/giscanner/doctemplates/C/mallard-C-function.tmpl b/giscanner/doctemplates/C/mallard-C-function.tmpl index d433aa56..f93fc31d 100644 --- a/giscanner/doctemplates/C/mallard-C-function.tmpl +++ b/giscanner/doctemplates/C/mallard-C-function.tmpl @@ -1,11 +1,5 @@ -<?xml version="1.0"?> -<page id="${page_id}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> % if node.parent is not None: <link type="guide" xref="${namespace.name}.${node.parent.name}" group="${page_style}"/> % else: @@ -33,8 +27,8 @@ % endif % endfor </api:function> - </info> - <title>${formatter.format_page_name(node)}</title> +</%block> +<%block name="content"> <synopsis><code mime="text/x-csrc"> ${node.retval.type.ctype} ${node.symbol} (\ % if node.is_method: @@ -64,8 +58,7 @@ ${formatter.format_type(arg.type) | x} ${arg.argname}\ %endif % endfor </code></synopsis> -${formatter.format(node, node.doc)} - +${parent.content()} % if node.parameters or node.retval: <table> % for arg, ix in zip(node.parameters, range(len(node.parameters))): @@ -82,7 +75,5 @@ ${formatter.format(node, node.doc)} % endif </table> % endif -% if node.version: -<p>Since ${node.version}</p> -% endif -</page> +${self.since_version()} +</%block> diff --git a/giscanner/doctemplates/C/mallard-C-namespace.tmpl b/giscanner/doctemplates/C/mallard-C-namespace.tmpl index 39d02619..372cd33f 100644 --- a/giscanner/doctemplates/C/mallard-C-namespace.tmpl +++ b/giscanner/doctemplates/C/mallard-C-namespace.tmpl @@ -1,12 +1,6 @@ -<?xml version="1.0"?> -<page id="index" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - </info> - <title>${formatter.format_page_name(node)}</title> +<%! page_type="guide" %>\ +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> <links type="topic" ui:expanded="yes" groups="class" style="linklist"> <title>Classes</title> </links> @@ -16,4 +10,4 @@ <links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist"> <title>Other</title> </links> -</page> +</%block> diff --git a/giscanner/doctemplates/C/mallard-C-property.tmpl b/giscanner/doctemplates/C/mallard-C-property.tmpl index a253160d..cceb62de 100644 --- a/giscanner/doctemplates/C/mallard-C-property.tmpl +++ b/giscanner/doctemplates/C/mallard-C-property.tmpl @@ -1,13 +1,5 @@ -<?xml version="1.0"?> -<page id="${namespace.name}.${node.name}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> <link type="guide" xref="${namespace.name}.${node.parent.name}" group="property"/> <title type="link" role="topic">${node.name}</title> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +</%block> diff --git a/giscanner/doctemplates/C/mallard-C-record.tmpl b/giscanner/doctemplates/C/mallard-C-record.tmpl index 7283366d..991f29be 100644 --- a/giscanner/doctemplates/C/mallard-C-record.tmpl +++ b/giscanner/doctemplates/C/mallard-C-record.tmpl @@ -1,12 +1 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index"/> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +<%inherit file="mallard-base.tmpl"/> diff --git a/giscanner/doctemplates/C/mallard-C-signal.tmpl b/giscanner/doctemplates/C/mallard-C-signal.tmpl index 49ee9852..cceb62de 100644 --- a/giscanner/doctemplates/C/mallard-C-signal.tmpl +++ b/giscanner/doctemplates/C/mallard-C-signal.tmpl @@ -1,13 +1,5 @@ -<?xml version="1.0"?> -<page id="${namespace.name}.${node.name}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="${namespace.name}.${node.parent.name}" group="signal"/> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> + <link type="guide" xref="${namespace.name}.${node.parent.name}" group="property"/> <title type="link" role="topic">${node.name}</title> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +</%block> diff --git a/giscanner/doctemplates/C/mallard-C-vfunc.tmpl b/giscanner/doctemplates/C/mallard-C-vfunc.tmpl index 3363ea8c..b27b2cef 100644 --- a/giscanner/doctemplates/C/mallard-C-vfunc.tmpl +++ b/giscanner/doctemplates/C/mallard-C-vfunc.tmpl @@ -1,18 +1,11 @@ -<?xml version="1.0"?> -<page id="${page_id}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> <link type="guide" xref="${namespace.name}.${node.parent.name}" group="vfunc"/> - </info> - <title>${formatter.format_page_name(node)}</title> +</%block> +<%block name="content"> <synopsis><code mime="text/x-csrc"> </code></synopsis> -${formatter.format(node, node.doc)} - +${parent.content()} % if node.parameters or node.retval: <table> % for arg, ix in zip(node.parameters, range(len(node.parameters))): @@ -29,7 +22,5 @@ ${formatter.format(node, node.doc)} % endif </table> % endif -% if node.version: -<p>Since ${node.version}</p> -% endif -</page> +${self.since_version()} +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-class.tmpl b/giscanner/doctemplates/Python/mallard-Python-class.tmpl index 800d241f..3f0d67a1 100644 --- a/giscanner/doctemplates/Python/mallard-Python-class.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-class.tmpl @@ -1,16 +1,6 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index" group="class"/> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} - +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> + ${parent.content()} <synopsis><code> from gi.repository import ${namespace.name} @@ -26,9 +16,7 @@ ${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}( )\ </code></synopsis> -% if node.version: -<p>Since ${node.version}</p> -% endif + ${self.since_version()} <synopsis> <title>Hierarchy</title> <tree> @@ -63,4 +51,4 @@ ${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}( <links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist"> <title>Other</title> </links> -</page> +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-default.tmpl b/giscanner/doctemplates/Python/mallard-Python-default.tmpl index 1d202109..991f29be 100644 --- a/giscanner/doctemplates/Python/mallard-Python-default.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-default.tmpl @@ -1,11 +1 @@ -<?xml version="1.0"?> -<page id="${page_id}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - </info> - <title>${formatter.format_page_name(node)}</title> -${formatter.format(node, node.doc)} -</page> +<%inherit file="mallard-base.tmpl"/> diff --git a/giscanner/doctemplates/Python/mallard-Python-enum.tmpl b/giscanner/doctemplates/Python/mallard-Python-enum.tmpl index c1a4d8c5..09f4d9a8 100644 --- a/giscanner/doctemplates/Python/mallard-Python-enum.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-enum.tmpl @@ -1,13 +1,5 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index"/> - </info> - <title>${formatter.format_page_name(node)}</title> +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> ${formatter.format(node, node.doc)} % if node.members: <table> @@ -19,5 +11,4 @@ % endfor </table> % endif - -</page> +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-function.tmpl b/giscanner/doctemplates/Python/mallard-Python-function.tmpl index 1976a1ca..683ca835 100644 --- a/giscanner/doctemplates/Python/mallard-Python-function.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-function.tmpl @@ -1,11 +1,5 @@ -<?xml version="1.0"?> -<page id="${page_id}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> % if node.parent is not None: <link type="guide" xref="${namespace.name}.${node.parent.name}" group="${page_style}"/> % else: @@ -33,8 +27,8 @@ % endif % endfor </api:function> - </info> - <title>${formatter.format_page_name(node)}</title> +</%block> +<%block name="content"> <synopsis><code mime="text/x-python"> % if len(node.parameters) != 0: @accepts(\ @@ -51,7 +45,7 @@ ${', '.join((arg.argname for arg in node.parameters))}\ ): # Python wrapper for ${node.symbol}() </code></synopsis> -${formatter.format(node, node.doc)} +${parent.content()} % if node.parameters or node.retval: <table> @@ -69,7 +63,5 @@ ${formatter.format(node, node.doc)} % endif </table> % endif -% if node.version: -<p>Since ${node.version}</p> -% endif -</page> +${self.since_version()} +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl b/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl index 97bd7132..372cd33f 100644 --- a/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-namespace.tmpl @@ -1,19 +1,13 @@ -<?xml version="1.0"?> -<page id="index" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - </info> - <title>${formatter.format_page_name(node)}</title> - <links type="topic" ui:expanded="yes" groups="class"> +<%! page_type="guide" %>\ +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> + <links type="topic" ui:expanded="yes" groups="class" style="linklist"> <title>Classes</title> </links> - <links type="topic" ui:expanded="yes" groups="function"> + <links type="topic" ui:expanded="yes" groups="function" style="linklist"> <title>Functions</title> </links> - <links type="topic" ui:expanded="yes" groups="#first #default #last"> + <links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist"> <title>Other</title> </links> -</page> +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-property.tmpl b/giscanner/doctemplates/Python/mallard-Python-property.tmpl index 7f4138cd..db78f2b9 100644 --- a/giscanner/doctemplates/Python/mallard-Python-property.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-property.tmpl @@ -1,16 +1,11 @@ -<?xml version="1.0"?> -<page id="${namespace.name}.${node.parent.name}-${node.name}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> <link type="guide" xref="${namespace.name}.${node.parent.name}" group="property"/> <title type="link" role="topic">${node.name}</title> - </info> - <title>${formatter.format_page_name(node)}</title> +</%block> +<%block name="content"> <synopsis><code mime="text/x-python"> "${node.name}" ${formatter.format_type(node.type)} : ${formatter.format_property_flags(node)} </code></synopsis> -${formatter.format(node, node.doc)} -</page> +${parent.content()} +</%block> diff --git a/giscanner/doctemplates/Python/mallard-Python-record.tmpl b/giscanner/doctemplates/Python/mallard-Python-record.tmpl index 43bea043..cfe71c15 100644 --- a/giscanner/doctemplates/Python/mallard-Python-record.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-record.tmpl @@ -1,12 +1,2 @@ -<?xml version="1.0"?> -<page id="${node.namespace.name}.${node.name}" - type="guide" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="index"/> - </info> - <title>${formatter.format_page_name(node)}</title> - <p>${node.doc}</p> -</page> +<%! page_type="guide" %>\ +<%inherit file="mallard-base.tmpl"/> diff --git a/giscanner/doctemplates/Python/mallard-Python-signal.tmpl b/giscanner/doctemplates/Python/mallard-Python-signal.tmpl index 8dda89be..a430d9b9 100644 --- a/giscanner/doctemplates/Python/mallard-Python-signal.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-signal.tmpl @@ -1,14 +1,9 @@ -<?xml version="1.0"?> -<page id="${namespace.name}.${node.parent.name}-${node.name}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> +<%inherit file="mallard-base.tmpl"/> +<%block name="info"> <link type="guide" xref="${namespace.name}.${node.parent.name}" group="signal"/> <title type="link" role="topic">${node.name}</title> - </info> - <title>${formatter.format_page_name(node)}</title> +</%block> +<%block name="content"> <synopsis><code mime="text/x-python"> def callback(${formatter.to_underscores(node.parent.name).lower()}, \ % for arg, ix in zip(node.parameters, range(len(node.parameters))): @@ -46,7 +41,6 @@ ${formatter.format(node, node.doc)} </tr> % endif </table> -% if node.version: -<p>Since ${node.version}</p> -% endif -</page> +${self.since_version()} +</%block> + diff --git a/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl b/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl index 86dc685b..65af0058 100644 --- a/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl +++ b/giscanner/doctemplates/Python/mallard-Python-vfunc.tmpl @@ -1,15 +1,5 @@ -<?xml version="1.0"?> -<page id="${page_id}" - type="topic" - style="${page_style}" - xmlns="http://projectmallard.org/1.0/" - xmlns:api="http://projectmallard.org/experimental/api/" - xmlns:ui="http://projectmallard.org/experimental/ui/"> - <info> - <link type="guide" xref="${namespace.name}.${node.parent.name}" group="vfunc"/> - <title type="link" role="topic">${node.name}</title> - </info> - <title>${formatter.format_page_name(node)}</title> +<%inherit file="mallard-base.tmpl"/> +<%block name="content"> <synopsis><code mime="text/x-python"> % if len(node.parameters) != 0: @accepts(\ @@ -22,7 +12,7 @@ do_${node.name}(self, \ ${', '.join((arg.argname for arg in node.parameters))}\ ): </code></synopsis> -${formatter.format(node, node.doc)} +${parent.content()} % if node.parameters or node.retval: <table> @@ -40,7 +30,5 @@ ${formatter.format(node, node.doc)} % endif </table> % endif -% if node.version: -<p>Since ${node.version}</p> -% endif -</page> +${self.since_version()} +</%block> diff --git a/giscanner/doctemplates/mallard-base.tmpl b/giscanner/doctemplates/mallard-base.tmpl new file mode 100644 index 00000000..07eb4468 --- /dev/null +++ b/giscanner/doctemplates/mallard-base.tmpl @@ -0,0 +1,23 @@ +<%! page_type="topic" %>\ +<?xml version="1.0"?> +<page id="${page_id}" + type="${self.attr.page_type}" + style="${page_style}" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/experimental/ui/"> + <info> + <%block name="info"> + <link type="guide" xref="index"/> + </%block> + </info> + <title><%block name="title">${formatter.format_page_name(node)}</%block></title> + <%block name="content"> + ${formatter.format(node, node.doc)} + </%block> + <%def name="since_version()"> + % if node.version: + <p>Since ${node.version}</p> + % endif + </%def> +</page> diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py index ccd65f0d..f40bf881 100644 --- a/giscanner/mallardwriter.py +++ b/giscanner/mallardwriter.py @@ -462,9 +462,10 @@ class MallardWriter(object): else: srcdir = os.path.dirname(__file__) - template_dir = os.path.join(srcdir, 'doctemplates', self._language) + template_dir = os.path.join(srcdir, 'doctemplates') + language_dir = os.path.join(template_dir, self._language) - return TemplateLookup(directories=[template_dir], + return TemplateLookup(directories=[template_dir, language_dir], module_directory=tempfile.mkdtemp(), output_encoding='utf-8') |