summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <gkiagia@tolabaki.gr>2017-07-30 11:13:45 +0300
committerAlexander Akulich <akulichalexander@gmail.com>2019-11-16 15:14:26 +0300
commit0ac6243b1c7496ca90d830c0776296a1ee062998 (patch)
tree45dc21a3cbee5577ed744c25ab4988a81d92b61a
parentc1a2aaf6c98bbe4b55a32b6462c7c0eb86e55243 (diff)
tools: port all python tools to python3 and replace Cheetah with jinja2 templates
Fixes #17 Signed-off-by: George Kiagiadakis <gkiagia@tolabaki.gr> Signed-off-by: Alexandr Akulich <akulichalexander@gmail.com>
-rw-r--r--Makefile2
-rw-r--r--doc/templates/devhelp.devhelp228
-rw-r--r--doc/templates/errors.html39
-rw-r--r--doc/templates/fullindex.html51
-rw-r--r--doc/templates/generic-types.html37
-rw-r--r--doc/templates/index.html83
-rw-r--r--doc/templates/interface.html541
-rw-r--r--doc/templates/interfaces.html47
-rwxr-xr-xtest/test-specparser.py34
-rwxr-xr-xtools/doc-generator.py83
-rw-r--r--tools/specparser.py71
-rw-r--r--tools/xincludator.py9
12 files changed, 501 insertions, 524 deletions
diff --git a/Makefile b/Makefile
index 1063e4b6..302f1bc1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ all:
GIT = git
GZIP = gzip
TAR = tar
-PYTHON = python
+PYTHON = python3
DOC_RSYNC_FLAGS=-rvzPp --chmod=Dg+s,ug+rwX,o=rX --delete
diff --git a/doc/templates/devhelp.devhelp2 b/doc/templates/devhelp.devhelp2
index cd7fe7a8..48e177b4 100644
--- a/doc/templates/devhelp.devhelp2
+++ b/doc/templates/devhelp.devhelp2
@@ -1,24 +1,22 @@
<?xml version="1.0"?>
-<book xmlns="http://www.devhelp.net/book" title="$spec.title" name="$name" link="index.html">
+<book xmlns="http://www.devhelp.net/book" title="{{ spec.title }}" name="{{ name }}" link="index.html">
<chapters>
-#for $interface in $spec.interfaces
- <sub name="$interface.name" link="$interface.get_url()"/>
-#end for
-#if len($spec.generic_types) > 0
+{% for interface in spec.interfaces %}
+ <sub name="{{ interface.name }}" link="{{ interface.get_url() }}"/>
+{% endfor %}
+{% if spec.generic_types|length > 0 %}
<sub name="Generic Types" link="generic-types.html"/>
-#end if
-#if len($spec.errors) > 0
+{% endif %}
+{% if spec.errors|length > 0 %}
<sub name="Errors" link="errors.html"/>
-#end if
+{% endif %}
<sub name="Full Index" link="fullindex.html"/>
</chapters>
<functions>
-#for $obj in $spec.everything.values() + $spec.types.values() + $spec.errors.values()
-#for $entry in $obj.get_index_entries()
- <keyword type="$obj.devhelp_name" name="$entry" link="$obj.get_url()" #slurp
-#if $obj.is_deprecated: deprecated="true" #slurp
-/>
-#end for
-#end for
+{% for obj in all_values %}
+{% for entry in obj.get_index_entries() %}
+ <keyword type="{{ obj.devhelp_name }}" name="{{ entry }}" link="{{ obj.get_url() }}" {% if obj.is_deprecated %} deprecated="true" {% endif %} />
+{% endfor %}
+{% endfor %}
</functions>
</book>
diff --git a/doc/templates/errors.html b/doc/templates/errors.html
index 94a793e5..5af6cd9b 100644
--- a/doc/templates/errors.html
+++ b/doc/templates/errors.html
@@ -3,6 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Errors</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
</head>
@@ -19,45 +20,45 @@
<a name="summary"></a>
<h3>Errors</h3>
<table class="summary">
- #for $error in $spec.sorted_errors
- #if $error.is_deprecated
+ {% for error in spec.sorted_errors %}
+ {% if error.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$error.get_url()">$error.short_name</a></td>
+ {% endif %}
+ <td><a href="{{ error.get_url() }}">{{ error.short_name }}</a></td>
<td>
- #if $error.is_deprecated: (deprecated)
+ {% if error.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
</div>
- #if $spec.errors_section
- $spec.errors_section.get_docstring()
- #end if
+ {% if spec.errors_section %}
+ {{ spec.errors_section.get_docstring() }}
+ {% endif %}
<div class="outset errors error">
<a name="errors"></a>
<h1>Errors</h1>
- #for $error in $spec.sorted_errors
+ {% for error in spec.sorted_errors %}
<div class="inset error">
- <a name="$error.get_anchor()"></a>
- <span class="permalink">(<a href="$error.get_url()">Permalink</a>)</span>
+ <a name="{{ error.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ error.get_url() }}">Permalink</a>)</span>
<h2>
- $error.short_name
+ {{ error.short_name }}
</h2>
<div class="indent">
- <code>$error.name</code>
+ <code>{{ error.name }}</code>
</div>
- $error.get_added()
- $error.get_deprecated()
- $error.get_docstring()
+ {{ error.get_added() }}
+ {{ error.get_deprecated() }}
+ {{ error.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
</div>
diff --git a/doc/templates/fullindex.html b/doc/templates/fullindex.html
index df66e525..17e9b142 100644
--- a/doc/templates/fullindex.html
+++ b/doc/templates/fullindex.html
@@ -4,56 +4,45 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Full Index</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
</head>
-
-#set $star = []
-#for $item in $spec.everything.values() + $spec.errors.values() + $spec.types.values()
- #echo $star.append(($item.short_name, $item))
- #slurp
-#end for
-#echo $star.sort(key = lambda t: t[0].title())
-#slurp
-## one use iterators...
-#set $groups = [ (l, list(g)) for l, g in (groupby($star, key = lambda t: t[0][0].upper())) ]
-#set $letters = set(map(lambda t: t[0], groups))
-
<body>
<div class="header">
<h1>Full Index</h1>
<a href="index.html">Interface Index</a>
(<a href="interfaces.html">Compact</a>)
- #for $a in map(chr, xrange(ord('A'), ord('Z')+1))
- #if $a in $letters
- | <a href="#$a">$a</a>
- #else
- | $a
- #end if
- #end for
+ {% for a in all_letters %}
+ {% if a in letters %}
+ | <a href="#{{ a }}">{{ a }}</a>
+ {% else %}
+ | {{ a }}
+ {% endif %}
+ {% endfor %}
</div>
<div class="main">
<table class="summary">
- #for l, g in $groups
- <tr><th colspan="3"><a name="$l"></a>$l</th></tr>
- #for $n in $g
- #if $n[1].is_deprecated
+ {% for l, g in groups %}
+ <tr><th colspan="3"><a name="{{ l }}"></a>{{ l }}</th></tr>
+ {% for n in g %}
+ {% if n[1].is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
+ {% endif %}
<td>
- <a href="$n[1].get_url()" title="$n[1].get_title()">$n[0]</a>
- #if $n[1].is_deprecated: (deprecated)
+ <a href="{{ n[1].get_url() }}" title="{{ n[1].get_title() }}">{{ n[0] }}</a>
+ {% if n[1].is_deprecated %} (deprecated) {% endif %}
</td>
- <td>$n[1].get_type_name()</td>
+ <td>{{ n[1].get_type_name() }}</td>
<td>
- #if $n[1].parent.__class__.__name__ == 'Interface': $n[1].parent.name
+ {% if n[1].parent.__class__.__name__ == 'Interface' %}{{ n[1].parent.name }}{% endif %}
</td>
</tr>
- #end for
- #end for
+ {% endfor %}
+ {% endfor %}
<table>
</div>
diff --git a/doc/templates/generic-types.html b/doc/templates/generic-types.html
index 21e98269..1deab3b4 100644
--- a/doc/templates/generic-types.html
+++ b/doc/templates/generic-types.html
@@ -3,6 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Generic Types</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
</head>
@@ -19,40 +20,40 @@
<a name="summary"></a>
<h3>Generic Types</h3>
<table class="summary">
- #for $type in $spec.generic_types
- #if $type.is_deprecated
+ {% for type in spec.generic_types %}
+ {% if type.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$type.get_url()">$type.short_name</a></td>
- <td>$type.get_type_name()</td>
- <td>$type.dbus_type</td>
+ {% endif %}
+ <td><a href="{{ type.get_url() }}">{{ type.short_name }}</a></td>
+ <td>{{ type.get_type_name() }}</td>
+ <td>{{ type.dbus_type }}</td>
<td>
- #if $type.is_deprecated: (deprecated)
+ {% if type.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
</div>
<div class="outset types type">
<a name="types"></a>
<h1>Generic Types</h1>
- #for $type in $spec.generic_types
+ {% for type in spec.generic_types %}
<div class="inset type">
- <a name="$type.get_anchor()"></a>
- <span class="permalink">$type.get_type_name() (<a href="$type.get_url()">Permalink</a>)</span>
+ <a name="{{ type.get_anchor() }}"></a>
+ <span class="permalink">{{ type.get_type_name() }} (<a href="{{ type.get_url() }}">Permalink</a>)</span>
<h2>
- $type.short_name &mdash; $type.dbus_type
+ {{ type.short_name }} &mdash; {{ type.dbus_type }}
</h2>
- $type.get_added()
- $type.get_deprecated()
- $type.get_docstring()
- $type.get_breakdown()
+ {{ type.get_added() }}
+ {{ type.get_deprecated() }}
+ {{ type.get_docstring() }}
+ {{ type.get_breakdown() }}
</div>
- #end for
+ {% endfor %}
</div>
</div>
diff --git a/doc/templates/index.html b/doc/templates/index.html
index 2df515d5..70d79318 100644
--- a/doc/templates/index.html
+++ b/doc/templates/index.html
@@ -2,87 +2,88 @@
<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" "">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <title>$spec.title &mdash; v$spec.version</title>
+ <title>{{ spec.title }} &mdash; v{{ spec.version }}</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
</head>
<body>
<div class="header">
- <h1>$spec.title</h1>
+ <h1>{{ spec.title }}</h1>
<a href="#interfaces">Interfaces</a>
(<a href="interfaces.html">Compact</a>)
-#if len($spec.generic_types) > 0
+{% if spec.generic_types|length > 0 %}
| <a href="generic-types.html">Generic Types</a>
-#end if
-#if len($spec.errors) > 0
+{% endif %}
+{% if spec.errors|length > 0 %}
| <a href="errors.html">Errors</a>
-#end if
+{% endif %}
| <a href="fullindex.html">Full Index</a>
</div>
<div class="main">
- <h3 class="version">Version $spec.version</h3>
+ <h3 class="version">Version {{ spec.version }}</h3>
<div class="legal">
<ul class="copyrights">
- #for c in $spec.copyrights
- <li>$c</li>
- #end for
+ {% for c in spec.copyrights %}
+ <li>{{ c }}</li>
+ {% endfor %}
</ul>
- #for $para in $spec.license
- <p>$para</p>
- #end for
+ {% for l in spec.license %}
+ <p>{{ l }}</p>
+ {% endfor %}
</div>
<a name="interfaces"></a>
<h3>Interfaces</h3>
<ul>
- #def output($items)
- #for $item in $items
- #if $item.__class__.__name__ == 'Section'
- #set $anchor = $item.short_name.replace(' ', '-')
+ {% macro output(items) -%}
+ {% for item in items %}
+ {% if item.__class__.__name__ == 'Section' %}
+ {% set anchor = item.short_name.replace(' ', '-') %}
<li class="chapter">
- <a name="$anchor"></a>
- $item.short_name
- <span class="permalink">(<a href="#$anchor">Permalink</a>)</span>
+ <a name="{{ anchor }}"></a>
+ {{ item.short_name }}
+ <span class="permalink">(<a href="#{{ anchor }}">Permalink</a>)</span>
</li>
- $item.get_docstring()
+ {{ item.get_docstring() }}
<ul>
- $output($item.items)
+ {{ output(item.items) }}
</ul>
- #else
- #if $item.causes_havoc
+ {% else %}
+ {% if item.causes_havoc %}
<li class="causes-havoc">
- #elif $item.is_deprecated
+ {% elif item.is_deprecated %}
<li class="deprecated">
- #else
+ {% else %}
<li>
- #end if
- <a href="$item.get_url()">$item.name</a>
- #if $item.causes_havoc
+ {% endif %}
+ <a href="{{ item.get_url() }}">{{ item.name }}</a>
+ {% if item.causes_havoc %}
(unstable)
- #elif $item.is_deprecated
+ {% elif item.is_deprecated %}
(deprecated)
- #end if
+ {% endif %}
</li>
- #end if
- #end for
- #end def
- $output($spec.items)
+ {% endif %}
+ {% endfor %}
+ {%- endmacro %}
+ {{ output(spec.items) }}
</ul>
-#if len($spec.generic_types) > 0 or len($spec.errors) > 0
+{% if spec.generic_types|length > 0 or spec.errors|length > 0 %}
<a name="other"></a>
<h3>Other</h3>
<ul>
- #if len($spec.generic_types) > 0
+ {% if spec.generic_types|length > 0 %}
<li><a href="generic-types.html">Generic Types</a></li>
- #end if
- #if len($spec.errors) > 0
+ {% endif %}
+ {% if spec.errors|length > 0 %}
<li><a href="errors.html">Errors</a></li>
- #end if
+ {% endif %}
</ul>
-#end if
+{% endif %}
</div>
</body>
diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index 63a24bdf..017ff83a 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -2,7 +2,8 @@
<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" "">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <title>$interface.really_short_name &mdash; $spec.title</title>
+ <title>{{ interface.really_short_name }} &mdash; {{ spec.title }}</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
<script src="jquery.min.js"></script>
@@ -10,201 +11,193 @@
</head>
<body>
<div class="header">
- <h1>Interface <abbr title='$interface.name'>$interface.short_name</abbr></h1>
+ <h1>Interface <abbr title='{{ interface.name }}'>{{ interface.short_name }}</abbr></h1>
<a href="index.html">Interface Index</a>
(<a href="interfaces.html">Compact</a>)
| <a href="#summary">Summary</a>
- #if $interface.client_interests: | <a href="#client-interests">Client Interests</a>
- #if $interface.docstring: | <a href="#description">Description</a>
- #if $interface.methods: | <a href="#methods">Methods</a>
- #if $interface.signals: | <a href="#signals">Signals</a>
- #if $interface.properties: | <a href="#properties">Properties</a>
- #if $interface.tpproperties: | <a href="#tpproperties">Telepathy Properties</a>
- #if $interface.contact_attributes: | <a href="#contact-attributes">Contact Attributes</a>
- #if $interface.handler_capability_tokens: | <a href="#handler-capability-tokens">Handler Capability Tokens</a>
- #if $interface.types: | <a href="#types">Types</a>
+ {% if interface.client_interests %} | <a href="#client-interests">Client Interests</a> {% endif %}
+ {% if interface.docstring %} | <a href="#description">Description</a> {% endif %}
+ {% if interface.methods %} | <a href="#methods">Methods</a> {% endif %}
+ {% if interface.signals %} | <a href="#signals">Signals</a> {% endif %}
+ {% if interface.properties %} | <a href="#properties">Properties</a> {% endif %}
+ {% if interface.contact_attributes %} | <a href="#contact-attributes">Contact Attributes</a> {% endif %}
+ {% if interface.handler_capability_tokens %} | <a href="#handler-capability-tokens">Handler Capability Tokens</a> {% endif %}
+ {% if interface.types %} | <a href="#types">Types</a> {% endif %}
</div>
<div class="main">
- #if $interface.methods or $interface.signals or $interface.properties or $interface.types or $interface.tpproperties
+ {% if interface.methods or interface.signals or interface.properties or interface.types %}
<div class="summary">
<a name="summary"></a>
- #if $interface.client_interests
+ {% if interface.client_interests %}
<h3>Client Interests</h3>
<table class="summary">
- #for $interest in $interface.client_interests
- <td><a href="$interest.get_url()">$interest.name</a></td>
- #end for
+ {% for interest in interface.client_interests %}
+ <td><a href="{{ interest.get_url() }}">{{ interest.name }}</a></td>
+ {% endfor %}
</table>
- #end if
- #if $interface.methods
+ {% endif %}
+ {% if interface.methods %}
<h3>Methods</h3>
<table class="summary">
- #for $method in $interface.methods
- #if $method.is_deprecated
+ {% for method in interface.methods %}
+ {% if method.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$method.get_url()">$method.short_name</a></td>
- <td>($method.get_in_args())</td>
+ {% endif %}
+ <td><a href="{{ method.get_url() }}">{{ method.short_name }}</a></td>
+ <td>({{ method.get_in_args() }})</td>
<td>&#8594;</td>
- <td>$method.get_out_args()</td>
+ <td>{{ method.get_out_args() }}</td>
<td>
- #if $method.is_deprecated: (deprecated)
+ {% if method.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
- #if $interface.signals
+ {% if interface.signals %}
<h3>Signals</h3>
<table class="summary">
- #for $signal in $interface.signals
- #if $signal.is_deprecated
+ {% for signal in interface.signals %}
+ {% if signal.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$signal.get_url()">$signal.short_name</a></td>
- <td>($signal.get_args())</td>
+ {% endif %}
+ <td><a href="{{ signal.get_url() }}">{{ signal.short_name }}</a></td>
+ <td>({{ signal.get_args() }})</td>
<td>
- #if $signal.is_deprecated: (deprecated)
+ {% if signal.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
- #if $interface.properties
+ {% if interface.properties %}
<h3>Properties</h3>
<table class="summary">
- #for $property in $interface.properties
- #if $property.is_deprecated
+ {% for property in interface.properties %}
+ {% if property.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$property.get_url()">$property.short_name</a></td>
+ {% endif %}
+ <td><a href="{{ property.get_url() }}">{{ property.short_name }}</a></td>
<td>
- $property.dbus_type
- #if $property.type: (<a href="$property.get_type_url()" title="$property.get_type_title()">$property.get_type().short_name</a>)
+ {{ property.dbus_type }}
+ {% if property.type %}
+ (<a href="{{ property.get_type_url() }}" title="{{ property.get_type_title() }}">
+ {{ property.get_type().short_name }}</a>)
+ {% endif %}
</td>
- <td>$property.get_access()</td>
- <td>$property.get_flag_summary()</td>
+ <td>{{ property.get_access() }}</td>
+ <td>{{ property.get_flag_summary() }}</td>
<td>
- #if $property.is_deprecated: (deprecated)
+ {% if property.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
- #if $interface.tpproperties
- <h3>Telepathy Properties</h3>
- <table class="summary">
- #for $property in $interface.tpproperties
- <tr class="deprecated">
- <td><a href="$property.get_url()">$property.short_name</a></td>
- <td>
- $property.dbus_type
- #if $property.type: (<a href="$property.get_type_url()" title="$property.get_type_title()">$property.get_type().short_name</a>)
- </td>
- </tr>
- #end for
- </table>
- #end if
-
- #if $interface.contact_attributes
+ {% if interface.contact_attributes %}
<h3>Contact Attributes</h3>
<table class="summary">
- #for $token in $interface.contact_attributes
+ {% for token in interface.contact_attributes %}
<tr class="contact-attribute">
- <td><a href="$token.get_url()">$token.name</a></td>
+ <td><a href="{{ token.get_url() }}">{{ token.name }}</a></td>
<td>
- $token.dbus_type
- #if $token.type: (<a href="$token.get_type_url()" title="$token.get_type_title()">$token.get_type().short_name</a>)
+ {{ token.dbus_type }}
+ {% if token.type %}
+ (<a href="{{ token.get_type_url() }}" title="{{ token.get_type_title() }}">
+ {{ token.get_type().short_name }}</a>)
+ {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
- #if $interface.handler_capability_tokens
+ {% if interface.handler_capability_tokens %}
<h3>Handler Capability Tokens</h3>
<table class="summary">
- #for $token in $interface.handler_capability_tokens
+ {% for token in interface.handler_capability_tokens %}
<tr class="handler-capability-token">
- <td><a href="$token.get_url()">$token.name</a>
- #if $token.is_family
+ <td><a href="{{ token.get_url() }}">{{ token.name }}</a>
+ {% if token.is_family %}
(etc.)
- #end if
+ {% endif %}
</td>
<td>
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
- #if $interface.types
+ {% if interface.types %}
<h3>Types</h3>
<table class="summary">
- #for $type in $interface.types
- #if type.is_deprecated
+ {% for type in interface.types %}
+ {% if type.is_deprecated %}
<tr class="deprecated">
- #else
+ {% else %}
<tr>
- #end if
- <td><a href="$type.get_url()">$type.short_name</a></td>
- <td>$type.get_type_name()</td>
- <td>$type.dbus_type</td>
+ {% endif %}
+ <td><a href="{{ type.get_url() }}">{{ type.short_name }}</a></td>
+ <td>{{ type.get_type_name() }}</td>
+ <td>{{ type.dbus_type }}</td>
<td>
- #if $type.is_deprecated: (deprecated)
+ {% if type.is_deprecated %} (deprecated) {% endif %}
</td>
</tr>
- #end for
+ {% endfor %}
</table>
- #end if
+ {% endif %}
</div>
- #end if
+ {% endif %}
- #if $interface.causes_havoc
+ {% if interface.causes_havoc %}
<div class="annotation havoc"><span class="warning">WARNING:</span>
- This interface is $interface.causes_havoc and is likely to cause havoc
+ This interface is {{ interface.causes_havoc }} and is likely to cause havoc
to your API/ABI if bindings are generated. Do not include this interface
in libraries that care about compatibility.
</div>
- #end if
- $interface.get_added()
- $interface.get_changed()
- $interface.get_deprecated()
+ {% endif %}
+ {{ interface.get_added() }}
+ {{ interface.get_changed() }}
+ {{ interface.get_deprecated() }}
- #if $interface.requires or $interface.xor_requires
+ {% if interface.requires or interface.xor_requires %}
<div class="requires">
Objects implementing this interface must also implement:
<ul>
- #for $req in $interface.get_xor_requires()
+ {% for req in interface.get_xor_requires() %}
<li>
- #echo " <strong>or</strong> ".join(['<a href="' + x.get_url() + '''"
- title="''' + x.get_title() + '">' + x.name + '</a>' for x in req])
+ {% for x in req %}
+ <a href="{{ x.get_url() }}" title="{{ x.get_title() }}">{{ x.name }}</a>
+ {% if not loop.last %} <strong>or</strong> {% endif %}
+ {% endfor %}
</li>
- #end for
- #for $req in $interface.get_requires()
- <li><a href="$req.get_url()" title="$req.get_title()">$req.name</a></li>
- #end for
+ {% endfor %}
+ {% for req in interface.get_requires() %}
+ <li><a href="{{ req.get_url() }}" title="{{ req.get_title() }}">{{ req.name }}</a></li>
+ {% endfor %}
</ul>
</div>
- #end if
+ {% endif %}
- #if $interface.docstring
+ {% if interface.docstring %}
<a name="description"></a>
<h3>Description</h3>
- $interface.get_docstring()
- #end if
+ {{ interface.get_docstring() }}
+ {% endif %}
- #if $interface.client_interests
+ {% if interface.client_interests %}
<div class="outset client-interests client-interest">
<a name="client-interests"></a>
<h1>Client Interests</h1>
@@ -213,133 +206,139 @@
<a href="Connection.html#org.freedesktop.Telepathy.Connection.AddClientInterest">AddClientInterest</a> and
<a href="Connection.html#org.freedesktop.Telepathy.Connection.RemoveClientInterest">RemoveClientInterest</a> methods.
</div>
- #for $interest in $interface.client_interests
+ {% for interest in interface.client_interests %}
<div class="inset client-interest">
- <a name="$interest.get_anchor()"></a>
- <span class="permalink">(<a href="$interest.get_url()">Permalink</a>)</span>
- <h2>$interest.name</h2>
+ <a name="{{ interest.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ interest.get_url() }}">Permalink</a>)</span>
+ <h2>{{ interest.name }}</h2>
- $interest.get_docstring()
+ {{ interest.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.methods
+ {% if interface.methods %}
<div class="outset methods method">
<a name="methods"></a>
<h1>Methods</h1>
- #for $method in $interface.methods
+ {% for method in interface.methods %}
<div class="inset method">
- <a name="$method.get_anchor()"></a>
- <span class="permalink">(<a href="$method.get_url()">Permalink</a>)</span>
- <h2>$method.short_name ($method.get_in_args()) &#8594; $method.get_out_args()</h2>
+ <a name="{{ method.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ method.get_url() }}">Permalink</a>)</span>
+ <h2>{{ method.short_name }} ({{ method.get_in_args() }}) &#8594; {{ method.get_out_args() }}</h2>
- $method.get_added()
- $method.get_changed()
- $method.get_deprecated()
+ {{ method.get_added() }}
+ {{ method.get_changed() }}
+ {{ method.get_deprecated() }}
- #if $method.no_reply
+ {% if method.no_reply %}
<div class="annotation no-reply">The caller should not expect a reply when calling this method.</div>
- #end if
+ {% endif %}
- #if $method.in_args
+ {% if method.in_args %}
<div class="indent">
<h3>Parameters</h3>
<ul>
- #for $arg in $method.in_args
+ {% for arg in method.in_args %}
<li>
- $arg.short_name &mdash; $arg.dbus_type
- #if $arg.get_type(): (<a href="$arg.get_type_url()" title="$arg.get_type_title()">$arg.get_type().short_name</a>)
+ {{ arg.short_name }} &mdash; {{ arg.dbus_type }}
+ {% if arg.get_type() %}
+ (<a href="{{ arg.get_type_url() }}" title="{{ arg.get_type_title() }}">{{ arg.get_type().short_name }}</a>)
+ {% endif %}
</li>
- $arg.get_added()
- $arg.get_changed()
- $arg.get_deprecated()
- $arg.get_docstring()
- #end for
+ {{ arg.get_added() }}
+ {{ arg.get_changed() }}
+ {{ arg.get_deprecated() }}
+ {{ arg.get_docstring() }}
+ {% endfor %}
</ul>
</div>
- #end if
+ {% endif %}
- #if $method.out_args
+ {% if method.out_args %}
<div class="indent">
<h3>Returns</h3>
<ul>
- #for $arg in $method.out_args
+ {% for arg in method.out_args %}
<li>
- $arg.short_name &mdash; $arg.dbus_type
- #if $arg.get_type(): (<a href="$arg.get_type_url()" title="$arg.get_type_title()">$arg.get_type().short_name</a>)
+ {{ arg.short_name }} &mdash; {{ arg.dbus_type }}
+ {% if arg.get_type() %}
+ (<a href="{{ arg.get_type_url() }}" title="{{ arg.get_type_title() }}">{{ arg.get_type().short_name }}</a>)
+ {% endif %}
</li>
- $arg.get_added()
- $arg.get_changed()
- $arg.get_deprecated()
- $arg.get_docstring()
- #end for
+ {{ arg.get_added() }}
+ {{ arg.get_changed() }}
+ {{ arg.get_deprecated() }}
+ {{ arg.get_docstring() }}
+ {% endfor %}
</ul>
</div>
- #end if
+ {% endif %}
- $method.get_docstring()
+ {{ method.get_docstring() }}
- #if $method.possible_errors
+ {% if method.possible_errors %}
<hr/>
<div class="indent">
<h3>Possible Errors</h3>
<ul>
- #for $error in $method.possible_errors
- <li><a href="$error.get_url()" title="$error.get_title()">$error.get_error().short_name</a></li>
- $error.get_added()
- $error.get_changed()
- $error.get_deprecated()
- $error.get_docstring()
- #end for
+ {% for error in method.possible_errors %}
+ <li><a href="{{ error.get_url() }}" title="{{ error.get_title() }}">{{ error.get_error().short_name }}</a></li>
+ {{ error.get_added() }}
+ {{ error.get_changed() }}
+ {{ error.get_deprecated() }}
+ {{ error.get_docstring() }}
+ {% endfor %}
</ul>
</div>
- #end if
+ {% endif %}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.signals
+ {% if interface.signals %}
<div class="outset signals signal">
<a name="signals"></a>
<h1>Signals</h1>
- #for $signal in $interface.signals
+ {% for signal in interface.signals %}
<div class="inset signal">
- <a name="$signal.get_anchor()"></a>
- <span class="permalink">(<a href="$signal.get_url()">Permalink</a>)</span>
- <h2>$signal.short_name ($signal.get_args())</h2>
+ <a name="{{ signal.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ signal.get_url() }}">Permalink</a>)</span>
+ <h2>{{ signal.short_name }} ({{ signal.get_args() }})</h2>
- $signal.get_added()
- $signal.get_changed()
- $signal.get_deprecated()
+ {{ signal.get_added() }}
+ {{ signal.get_changed() }}
+ {{ signal.get_deprecated() }}
- #if $signal.args
+ {% if signal.args %}
<div class="indent">
<h3>Parameters</h3>
<ul>
- #for $arg in $signal.args
+ {% for arg in signal.args %}
<li>
- $arg.short_name &mdash; $arg.dbus_type
- #if $arg.get_type(): (<a href="$arg.get_type_url()" title="$arg.get_type_title()">$arg.get_type().short_name</a>)
+ {{ arg.short_name }} &mdash; {{ arg.dbus_type }}
+ {% if arg.get_type() %}
+ (<a href="{{ arg.get_type_url() }}" title="{{ arg.get_type_title() }}">{{ arg.get_type().short_name }}</a>)
+ {% endif %}
</li>
- $arg.get_added()
- $arg.get_changed()
- $arg.get_deprecated()
- $arg.get_docstring()
- #end for
+ {{ arg.get_added() }}
+ {{ arg.get_changed() }}
+ {{ arg.get_deprecated() }}
+ {{ arg.get_docstring() }}
+ {% endfor %}
</ul>
</div>
- #end if
+ {% endif %}
- $signal.get_docstring()
+ {{ signal.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.properties
+ {% if interface.properties %}
<div class="outset properties property">
<a name="properties"></a>
<h1>Properties</h1>
@@ -348,43 +347,45 @@
href="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">org.freedesktop.DBus.Properties</a>
interface.
</div>
- #for $property in $interface.properties
+ {% for property in interface.properties %}
<div class="inset property">
- <a name="$property.get_anchor()"></a>
- <span class="permalink">(<a href="$property.get_url()">Permalink</a>)</span>
+ <a name="{{ property.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ property.get_url() }}">Permalink</a>)</span>
<h2>
- $property.short_name &mdash; $property.dbus_type
- #if $property.type: (<a href="$property.get_type_url()" title="$property.get_type_title()">$property.get_type().short_name</a>)
+ {{ property.short_name }} &mdash; {{ property.dbus_type }}
+ {% if property.type %}
+ (<a href="{{ property.get_type_url() }}" title="{{ property.get_type_title() }}">{{ property.get_type().short_name }}</a>)
+ {% endif %}
</h2>
- <div class="access">$property.get_access()</div>
+ <div class="access">{{ property.get_access() }}</div>
- #if $property.sometimes_immutable:
+ {% if property.sometimes_immutable %}
<div class="annotation immutable">Depending on the protocol, this
property may be <strong>immutable</strong> which means that it can never
- #if $interface.is_channel_related:
+ {% if interface.is_channel_related %}
change once the channel has been created. Immutable properties SHOULD
appear in the channel detail list
- of <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.NewChannels">NewChannels</a>
+ of <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.NewChannel">NewChannel</a>
signals.
- #else
+ {% else %}
change.
- #end if
+ {% endif %}
</div>
- #elif $property.immutable:
+ {% elif property.immutable %}
<div class="annotation immutable">This property is
<strong>immutable</strong> which means that it can never
- #if $interface.is_channel_related:
+ {% if interface.is_channel_related %}
change once the channel has been created. Immutable properties SHOULD
appear in the channel detail list
- of <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.NewChannels">NewChannels</a>
+ of <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.NewChannel">NewChannel</a>
signals.
- #else
+ {% else %}
change.
- #end if
+ {% endif %}
</div>
- #end if
+ {% endif %}
- #if $property.sometimes_requestable:
+ {% if property.sometimes_requestable %}
<div class="annotation requestable">Depending on the protocol, this
property may be <strong>requestable</strong>, which means that it may be
allowed in the properties hash of a channel request such as in the
@@ -396,9 +397,9 @@
and <a href="Channel_Dispatcher.html">ChannelDispatcher</a>.
If supported on this protocol, the property should appear in either the
Fixed_Properties or Allowed_Properties of
- a <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.RequestableChannelClasses">RequestableChannelClass</a>
+ a <a href="Connection.html#org.freedesktop.Telepathy.Connection.RequestableChannelClasses">RequestableChannelClass</a>
advertised by the CM.</div>
- #elif $property.requestable:
+ {% elif property.requestable %}
<div class="annotation requestable">This property
is <strong>requestable</strong>, which means that it is allowed
in the properties hash of a channel request such as in the
@@ -410,40 +411,40 @@
and <a href="Channel_Dispatcher.html">ChannelDispatcher</a>.
The property should also appear in either the Fixed_Properties
or Allowed_Properties of
- a <a href="Connection_Interface_Requests.html#org.freedesktop.Telepathy.Connection.Interface.Requests.RequestableChannelClasses">RequestableChannelClass</a>
+ a <a href="Connection.html#org.freedesktop.Telepathy.Connection.RequestableChannelClasses">RequestableChannelClass</a>
advertised by the CM.</div>
- #end if
+ {% endif %}
- $property.get_added()
- $property.get_changed()
- $property.get_deprecated()
+ {{ property.get_added() }}
+ {{ property.get_changed() }}
+ {{ property.get_deprecated() }}
- #if not $property.immutable:
- #if $property.emits_changed == $property.EMITS_CHANGED_UPDATES
+ {% if not property.immutable %}
+ {% if property.emits_changed == property.EMITS_CHANGED_UPDATES %}
<div class="annotation emits-changed emits-changed-updates">
When this property changes, the
<code>org.freedesktop.DBus.Properties.PropertiesChanged</code>
signal is emitted with the new value.
</div>
- #elif $property.emits_changed == $property.EMITS_CHANGED_INVALIDATES
+ {% elif property.emits_changed == property.EMITS_CHANGED_INVALIDATES %}
<div class="annotation emits-changed emits-changed-invalidates">
When this property changes, the
<code>org.freedesktop.DBus.Properties.PropertiesChanged</code>
signal is emitted, but the new value is not sent.
</div>
- #elif $property.emits_changed == $property.EMITS_CHANGED_NONE
+ {% elif property.emits_changed == property.EMITS_CHANGED_NONE %}
<div class="annotation emits-changed emits-changed-none">
The <code>org.freedesktop.DBus.Properties.PropertiesChanged</code>
signal is <strong>not</strong> emitted when this property changes.
</div>
- #end if
- #end if
+ {% endif %}
+ {% endif %}
- #if $property.is_connection_parameter:
+ {% if property.is_connection_parameter %}
<div class="annotation connection-parameter">
<p><span class='note'>Note:</span> Connections implementing this
property SHOULD provide a corresponding parameter named
- <tt>$property.name</tt> with the <a
+ <tt>{{ property.name }}</tt> with the <a
href="Connection_Manager.html#Conn_Mgr_Param_Flags">DBus_Property</a>
flag. Clients SHOULD update this property by
calling <a
@@ -453,41 +454,15 @@
href="Account.html#org.freedesktop.Telepathy.Account.AccountPropertyChanged">AccountPropertyChanged</a>.
</p>
</div>
- #end if
+ {% endif %}
- $property.get_docstring()
- </div>
- #end for
- </div>
- #end if
-
- #if $interface.tpproperties
- <div class="outset tpproperties tpproperty">
- <a name="tpproperties"></a>
- <h1>Telepathy Properties</h1>
- <div>
- Accessed using the <a
- href="Properties_Interface.html">org.freedesktop.Telepathy.Properties</a>
- interface.
- </div>
- #for $property in $interface.tpproperties
- <div class="inset tpproperty">
- <a name="$property.get_anchor()"></a>
- <span class="permalink">(<a href="$property.get_url()">Permalink</a>)</span>
- <h2>
- $property.short_name &mdash; $property.dbus_type
- #if $property.type: (<a href="$property.get_type_url()" title="$property.get_type_title()">$property.get_type().short_name</a>)
- </h2>
- $property.get_added()
- $property.get_changed()
- $property.get_deprecated()
- $property.get_docstring()
+ {{ property.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.contact_attributes
+ {% if interface.contact_attributes %}
<div class="outset contact-attributes">
<a name="contact-attributes"></a>
<h1>Contact Attributes</h1>
@@ -495,70 +470,72 @@
Attributes that a contact can have, accessed with the
org.freedesktop.Telepathy.Connection.Interface.Contacts interface.
</div>
- #for $token in $interface.contact_attributes
+ {% for token in interface.contact_attributes %}
<div class="inset contact-attribute">
- <a name="$token.get_anchor()"></a>
- <span class="permalink">(<a href="$token.get_url()">Permalink</a>)</span>
+ <a name="{{ token.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ token.get_url() }}">Permalink</a>)</span>
<h2>
- $token.name &mdash; $token.dbus_type
- #if $token.type: (<a href="$token.get_type_url()" title="$token.get_type_title()">$token.get_type().short_name</a>)
+ {{ token.name }} &mdash; {{ token.dbus_type }}
+ {% if token.type %}
+ (<a href="{{ token.get_type_url() }}" title="{{ token.get_type_title() }}">{{ token.get_type().short_name }}</a>)
+ {% endif %}
</h2>
- $token.get_added()
- $token.get_changed()
- $token.get_deprecated()
- $token.get_docstring()
+ {{ token.get_added() }}
+ {{ token.get_changed() }}
+ {{ token.get_deprecated() }}
+ {{ token.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.handler_capability_tokens
+ {% if interface.handler_capability_tokens %}
<div class="outset handler-capability-tokens">
<a name="handler-capability-tokens"></a>
<h1>Handler Capability Tokens</h1>
<div>
Tokens representing capabilities that a Client.Handler can have.
</div>
- #for $token in $interface.handler_capability_tokens
+ {% for token in interface.handler_capability_tokens %}
<div class="inset handler-capability-token">
- <a name="$token.get_anchor()"></a>
- <span class="permalink">(<a href="$token.get_url()">Permalink</a>)</span>
+ <a name="{{ token.get_anchor() }}"></a>
+ <span class="permalink">(<a href="{{ token.get_url() }}">Permalink</a>)</span>
<h2>
- $token.name
- #if $token.is_family
+ {{ token.name }}
+ {% if token.is_family %}
(etc.)
- #end if
+ {% endif %}
</h2>
- $token.get_added()
- $token.get_changed()
- $token.get_deprecated()
- $token.get_docstring()
+ {{ token.get_added() }}
+ {{ token.get_changed() }}
+ {{ token.get_deprecated() }}
+ {{ token.get_docstring() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
- #if $interface.types
+ {% if interface.types %}
<div class="outset types type">
<a name="types"></a>
<h1>Types</h1>
- #for $type in $interface.types
+ {% for type in interface.types %}
<div class="inset type">
- <a name="$type.get_anchor()"></a>
- <span class="permalink">$type.get_type_name() (<a href="$type.get_url()">Permalink</a>)</span>
+ <a name="{{ type.get_anchor() }}"></a>
+ <span class="permalink">{{ type.get_type_name() }} (<a href="{{ type.get_url() }}">Permalink</a>)</span>
<h2>
- $type.short_name &mdash; $type.dbus_type
+ {{ type.short_name }} &mdash; {{ type.dbus_type }}
</h2>
- $type.get_added()
- $type.get_changed()
- $type.get_deprecated()
- $type.get_docstring()
- $type.get_breakdown()
+ {{ type.get_added() }}
+ {{ type.get_changed() }}
+ {{ type.get_deprecated() }}
+ {{ type.get_docstring() }}
+ {{ type.get_breakdown() }}
</div>
- #end for
+ {% endfor %}
</div>
- #end if
+ {% endif %}
</div>
diff --git a/doc/templates/interfaces.html b/doc/templates/interfaces.html
index d3c5fee6..d4b04990 100644
--- a/doc/templates/interfaces.html
+++ b/doc/templates/interfaces.html
@@ -2,59 +2,60 @@
<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" "">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <title>$spec.title &mdash; v$spec.version</title>
+ <title>{{ spec.title }} &mdash; v{{ spec.version }}</title>
+ <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="shortcut icon" type="image/png" media="all" href="favicon.png" />
</head>
<body>
<div class="header">
- <h1>$spec.title</h1>
+ <h1>{{ spec.title }}</h1>
<a href="index.html">Full</a>
-#if len($spec.generic_types) > 0
+{% if spec.generic_types|length > 0 %}
| <a href="generic-types.html">Generic Types</a>
-#end if
-#if len($spec.errors) > 0
+{% endif %}
+{% if spec.errors|length > 0 %}
| <a href="errors.html">Errors</a>
-#end if
+{% endif %}
| <a href="fullindex.html">Full Index</a>
</div>
<div class="main">
- <b>Version $spec.version</b>
+ <b>Version {{ spec.version }}</b>
<a name="interfaces"></a>
<h3>Interfaces</h3>
<ul>
- #for $interface in $spec.interfaces
- #if $interface.causes_havoc
+ {% for interface in spec.interfaces %}
+ {% if interface.causes_havoc %}
<li class="causes-havoc">
- #elif $interface.is_deprecated
+ {% elif interface.is_deprecated %}
<li class="deprecated">
- #else
+ {% else %}
<li>
- #end if
- <a href="$interface.get_url()">$interface.name</a>
- #if $interface.causes_havoc
+ {% endif %}
+ <a href="{{ interface.get_url() }}">{{ interface.name }}</a>
+ {% if interface.causes_havoc %}
(unstable)
- #elif $interface.is_deprecated
+ {% elif interface.is_deprecated %}
(deprecated)
- #end if
+ {% endif %}
</li>
- #end for
+ {% endfor %}
</ul>
-#if len($spec.generic_types) > 0 or len($spec.errors) > 0
+{% if spec.generic_types|length > 0 or spec.errors|length > 0 %}
<a name="other"></a>
<h3>Other</h3>
<ul>
- #if len($spec.generic_types) > 0
+ {% if spec.generic_types|length > 0 %}
<li><a href="generic-types.html">Generic Types</a></li>
- #end if
- #if len($spec.errors) > 0
+ {% endif %}
+ {% if spec.errors|length > 0 %}
<li><a href="errors.html">Errors</a></li>
- #end if
+ {% endif %}
</ul>
-#end if
+{% endif %}
</div>
</body>
diff --git a/test/test-specparser.py b/test/test-specparser.py
index 164b4df8..e1c4a4cd 100755
--- a/test/test-specparser.py
+++ b/test/test-specparser.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import sys
import os.path
@@ -19,19 +19,21 @@ Spec(telepathy-spec tools test case)
>>> spec.interfaces
[Interface(org.freedesktop.Telepathy.SpecAutoGenTest)]
->>> spec.errors
-{u'org.freedesktop.Telepathy.SpecAutoGenTest.OtherError': Error(org.freedesktop.Telepathy.SpecAutoGenTest.OtherError), u'org.freedesktop.Telepathy.SpecAutoGenTest.MiscError': Error(org.freedesktop.Telepathy.SpecAutoGenTest.MiscError)}
+>>> sorted(spec.errors.items())
+[('org.freedesktop.Telepathy.SpecAutoGenTest.MiscError', Error(org.freedesktop.Telepathy.SpecAutoGenTest.MiscError)), ('org.freedesktop.Telepathy.SpecAutoGenTest.OtherError', Error(org.freedesktop.Telepathy.SpecAutoGenTest.OtherError))]
>>> spec.generic_types
[]
->>> spec.types
-{u'Adjective': Enum(Adjective), u'Test_Flags': Flags(Test_Flags), u'UV': Struct(UV)}
+>>> sorted(spec.types)
+['Adjective', 'Test_Flags', 'UV']
+>>> [ spec.types[x] for x in sorted(spec.types) ]
+[Enum(Adjective), Flags(Test_Flags), Struct(UV)]
>>> i = spec.interfaces[0]
>>> i
Interface(org.freedesktop.Telepathy.SpecAutoGenTest)
->>> print i.causes_havoc
+>>> print(i.causes_havoc)
None
>>> i.methods
@@ -48,7 +50,7 @@ AttributeError: 'Method' object has no attribute 'args'
>>> i.methods[0].possible_errors
[PossibleError(org.freedesktop.Telepathy.SpecAutoGenTest.MiscError), PossibleError(org.freedesktop.Telepathy.SpecAutoGenTest.OtherError)]
->>> map (lambda e: e.get_error (), i.methods[0].possible_errors)
+>>> list(map (lambda e: e.get_error (), i.methods[0].possible_errors))
[Error(org.freedesktop.Telepathy.SpecAutoGenTest.MiscError), Error(org.freedesktop.Telepathy.SpecAutoGenTest.OtherError)]
>>> i.signals
@@ -63,8 +65,8 @@ AttributeError: 'Method' object has no attribute 'args'
>>> i.properties[0].type
''
>>> i.properties[0].dbus_type
-u'b'
->>> print i.properties[0].get_type ()
+'b'
+>>> print(i.properties[0].get_type())
None
>>> i.types
@@ -72,21 +74,21 @@ None
>>> i.types[0].values
[EnumValue(Adjective.Leveraging), EnumValue(Adjective.Synergistic)]
->>> map (lambda v: (v.short_name, v.value), i.types[0].values)
-[(u'Leveraging', u'0'), (u'Synergistic', u'1')]
+>>> list(map (lambda v: (v.short_name, v.value), i.types[0].values))
+[('Leveraging', '0'), ('Synergistic', '1')]
>>> i.types[1].values
[EnumValue(Test_Flags.LowBit), EnumValue(Test_Flags.HighBit)]
->>> map (lambda v: (v.short_name, v.value), i.types[1].values)
-[(u'LowBit', u'1'), (u'HighBit', u'128')]
+>>> list(map (lambda v: (v.short_name, v.value), i.types[1].values))
+[('LowBit', '1'), ('HighBit', '128')]
>>> sorted(spec.everything.items())
-[(u'org.freedesktop.Telepathy.SpecAutoGenTest', ClientInterest(org.freedesktop.Telepathy.SpecAutoGenTest)), (u'org.freedesktop.Telepathy.SpecAutoGenTest.DoStuff', Method(org.freedesktop.Telepathy.SpecAutoGenTest.DoStuff)), (u'org.freedesktop.Telepathy.SpecAutoGenTest.Introspective', Property(org.freedesktop.Telepathy.SpecAutoGenTest.Introspective:b)), (u'org.freedesktop.Telepathy.SpecAutoGenTest.StuffHappened', Signal(org.freedesktop.Telepathy.SpecAutoGenTest.StuffHappened)), (u'org.freedesktop.Telepathy.SpecAutoGenTest.wobbly', AwkwardTelepathyProperty(org.freedesktop.Telepathy.SpecAutoGenTest.wobbly:b)), (u'org.freedesktop.Telepathy.SpecAutoGenTest/badgers', ClientInterest(org.freedesktop.Telepathy.SpecAutoGenTest/badgers))]
+[('org.freedesktop.Telepathy.SpecAutoGenTest', ClientInterest(org.freedesktop.Telepathy.SpecAutoGenTest)), ('org.freedesktop.Telepathy.SpecAutoGenTest.DoStuff', Method(org.freedesktop.Telepathy.SpecAutoGenTest.DoStuff)), ('org.freedesktop.Telepathy.SpecAutoGenTest.Introspective', Property(org.freedesktop.Telepathy.SpecAutoGenTest.Introspective:b)), ('org.freedesktop.Telepathy.SpecAutoGenTest.StuffHappened', Signal(org.freedesktop.Telepathy.SpecAutoGenTest.StuffHappened)), ('org.freedesktop.Telepathy.SpecAutoGenTest.wobbly', AwkwardTelepathyProperty(org.freedesktop.Telepathy.SpecAutoGenTest.wobbly:b)), ('org.freedesktop.Telepathy.SpecAutoGenTest/badgers', ClientInterest(org.freedesktop.Telepathy.SpecAutoGenTest/badgers))]
->>> map (lambda o: i.added, spec.everything.values ())
+>>> list(map (lambda o: i.added, spec.everything.values ()))
[None, None, None, None, None, None]
->>> map (lambda o: i.deprecated, spec.everything.values ())
+>>> list(map (lambda o: i.deprecated, spec.everything.values ()))
[None, None, None, None, None, None]
"""
diff --git a/tools/doc-generator.py b/tools/doc-generator.py
index 6117a6ca..5a45e349 100755
--- a/tools/doc-generator.py
+++ b/tools/doc-generator.py
@@ -1,8 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# doc-generator.py
#
-# Generates HTML documentation from the parsed spec using Cheetah templates.
+# Generates HTML documentation from the parsed spec
#
# Copyright (C) 2009 Collabora Ltd.
#
@@ -27,12 +27,13 @@ import sys
import os
import os.path
import shutil
+import itertools
try:
- from Cheetah.Template import Template
-except ImportError, e:
- print >> sys.stderr, e
- print >> sys.stderr, "Install `python-cheetah'?"
+ from jinja2 import Template
+except ImportError as e:
+ print(e, file=sys.stderr)
+ print("Install `jinja2'?", file=sys.stderr)
sys.exit(-1)
import specparser
@@ -68,54 +69,58 @@ def load_template(filename):
file = open(os.path.join(template_path, filename))
template_def = file.read()
file.close()
- except IOError, e:
- print >> sys.stderr, "Could not load template file `%s'" % filename
- print >> sys.stderr, e
+ except IOError as e:
+ print("Could not load template file `%s'" % filename, file=sys.stderr)
+ print(e, file=sys.stderr)
sys.exit(-1)
return template_def
+def render_template(name, context, target=None):
+ if target is None:
+ target = name
+ template_def = load_template(name)
+ t = Template(template_def).render(context)
+ with open(os.path.join(output_path, target), 'w') as out:
+ out.write(t)
+
spec = specparser.parse(spec_file, namespace, allow_externals=allow_externals)
# write out HTML files for each of the interfaces
-# Not using render_template here to avoid recompiling it n times.
-namespace = { 'spec': spec }
-template_def = load_template('interface.html')
-t = Template(template_def, namespaces = [namespace])
-for interface in spec.interfaces:
- namespace['interface'] = interface
+all_values = list(spec.everything.values()) + list(spec.errors.values()) + list(spec.types.values())
- # open the output file
- out = open(os.path.join(output_path, '%s.html'
- % interface.name_for_bindings), 'w')
- print >> out, unicode(t).encode('utf-8')
- out.close()
+star = [ (item.short_name, item) for item in all_values ]
+star.sort(key = lambda t: t[0].title())
+groups = [ (l, list(g)) for l, g in (itertools.groupby(star, key = lambda t: t[0][0].upper())) ]
+letters = set(map(lambda t: t[0], groups))
+all_letters = list(map(chr, range(ord('A'), ord('Z')+1)))
-def render_template(name, namespaces, target=None):
- if target is None:
- target = name
+context = { 'spec': spec, 'star': star, 'groups': groups,
+ 'letters': letters, 'all_letters': all_letters }
+render_template('fullindex.html', context)
- namespace = { 'spec': spec }
- template_def = load_template(name)
- t = Template(template_def, namespaces=namespaces)
- out = open(os.path.join(output_path, target), 'w')
- print >> out, unicode(t).encode('utf-8')
- out.close()
+context = { 'spec': spec, 'name': project, 'all_values': all_values }
+render_template('devhelp.devhelp2', context, target=('%s.devhelp2' % project))
-namespaces = { 'spec': spec }
+# Not using render_template here to avoid recompiling it n times.
+context = { 'spec': spec }
+template_def = load_template('interface.html')
+t = Template(template_def)
+for interface in spec.interfaces:
+ context['interface'] = interface
+ # open the output file
+ with open(os.path.join(output_path, '%s.html'
+ % interface.name_for_bindings), 'w') as out:
+ out.write(t.render(context))
+context = { 'spec': spec }
if len(spec.generic_types) > 0:
- render_template('generic-types.html', namespaces)
+ render_template('generic-types.html', context)
if len(spec.errors) > 0:
- render_template('errors.html', namespaces)
-render_template('interfaces.html', namespaces)
-render_template('fullindex.html', namespaces)
-
-dh_namespaces = { 'spec': spec, 'name': project }
-render_template('devhelp.devhelp2', dh_namespaces,
- target=('%s.devhelp2' % project))
+ render_template('errors.html', context)
+render_template('interfaces.html', context)
# write out the TOC last, because this is the file used as the target in the
# Makefile.
-render_template('index.html', namespaces)
+render_template('index.html', context)
diff --git a/tools/specparser.py b/tools/specparser.py
index 3ad1f9a3..472d0987 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# specparser.py
#
@@ -24,6 +25,7 @@
import sys
import xml.dom.minidom
+import functools
import xincludator
@@ -51,14 +53,14 @@ class Xzibit(Exception):
self.child = child
def __str__(self):
- print """
+ print ("""
Nested <%s>s are forbidden.
Parent:
%s...
Child:
%s...
""" % (self.parent.nodeName, self.parent.toxml()[:100],
- self.child.toxml()[:100])
+ self.child.toxml()[:100]))
def getText(dom):
try:
@@ -70,17 +72,17 @@ def getText(dom):
return ''
def getChildrenByName(dom, namespace, name):
- return filter(lambda n: n.nodeType == n.ELEMENT_NODE and \
+ return list(filter(lambda n: n.nodeType == n.ELEMENT_NODE and \
n.namespaceURI == namespace and \
n.localName == name,
- dom.childNodes)
+ dom.childNodes))
def getChildrenByNameAndAttribute(dom, namespace, name, attribute, value):
- return filter(lambda n: n.nodeType == n.ELEMENT_NODE and \
+ return list(filter(lambda n: n.nodeType == n.ELEMENT_NODE and \
n.namespaceURI == namespace and \
n.localName == name and \
n.getAttribute(attribute) == value,
- dom.childNodes)
+ dom.childNodes))
def getOnlyChildByName(dom, namespace, name):
kids = getChildrenByName(dom, namespace, name)
@@ -228,7 +230,7 @@ class Base(object):
self._convert_to_html(node)
- return node.toxml().encode('ascii', 'xmlcharrefreplace')
+ return node.toxml()
def get_added(self):
return self._get_generic_with_ver(self.added, 'added',
@@ -264,7 +266,7 @@ class Base(object):
self._convert_to_html(node)
- return node.toxml().encode('ascii', 'xmlcharrefreplace')
+ return node.toxml()
def _convert_to_html(self, node):
spec = self.get_spec()
@@ -342,10 +344,10 @@ class Base(object):
try:
e = spec.errors[error_ns + getText(n)]
except KeyError:
- print >> sys.stderr, """
+ print("""
WARNING: Error '%s' not known in error namespace '%s'
(<tp:error-ref> in %s)
- """.strip() % (getText(n), error_ns[:-1], self)
+ """.strip() % (getText(n), error_ns[:-1], self), file=sys.stderr)
continue
n.tagName = 'a'
@@ -359,10 +361,10 @@ WARNING: Error '%s' not known in error namespace '%s'
try:
o = spec.lookup(key, namespace=root_namespace)
except KeyError:
- print >> sys.stderr, """
+ print("""
WARNING: Key '%s' not known in namespace '%s'
(<tp:member-ref> in %s)
- """.strip() % (key, root_namespace, self)
+ """.strip() % (key, root_namespace, self), file=sys.stderr)
continue
n.tagName = 'a'
@@ -382,10 +384,10 @@ WARNING: Key '%s' not known in namespace '%s'
try:
o = spec.lookup(key, namespace=namespace)
except KeyError:
- print >> sys.stderr, """
+ print("""
WARNING: Key '%s' not known in namespace '%s'
(<tp:dbus-ref> in %s)
- """.strip() % (key, namespace, self)
+ """.strip() % (key, namespace, self), file=sys.stderr)
continue
n.tagName = 'a'
@@ -415,10 +417,10 @@ WARNING: Key '%s' not known in namespace '%s'
except KeyError:
o = spec.lookup(key, None)
except KeyError:
- print >> sys.stderr, """
+ print("""
WARNING: Key '%s' not known in namespace '%s'
(<tp:dbus-ref> in %s)
- """.strip() % (key, namespace, self)
+ """.strip() % (key, namespace, self), file=sys.stderr)
continue
n.tagName = 'a'
@@ -498,10 +500,10 @@ class PossibleError(Base):
return spec.errors[self.name]
except KeyError:
if not spec.allow_externals:
- print >> sys.stderr, """
+ print("""
WARNING: Error not known: '%s'
(<tp:possible-error> in %s)
- """.strip() % (self.name, self.parent)
+ """.strip() % (self.name, self.parent), file=sys.stderr)
return External(self.name)
@@ -528,8 +530,8 @@ class Method(DBusConstruct):
dom.getElementsByTagName('arg'))
# separate arguments as input and output arguments
- self.in_args = filter(lambda a: a.direction == Arg.DIRECTION_IN, args)
- self.out_args = filter(lambda a: a.direction == Arg.DIRECTION_OUT, args)
+ self.in_args = list(filter(lambda a: a.direction == Arg.DIRECTION_IN, args))
+ self.out_args = list(filter(lambda a: a.direction == Arg.DIRECTION_OUT, args))
for arg in args:
if arg.direction == Arg.DIRECTION_IN or \
@@ -637,10 +639,11 @@ class HasEmitsChangedAnnotation(object):
try:
return self.__MAPPING[emits_changed]
except KeyError:
- print >> sys.stderr, """
+ print("""
WARNING: <annotation name='%s'/> has unknown value '%s'
(in %s)
- """.strip() % (self.__ANNOTATION, emits_changed, self)
+ """.strip() % (self.__ANNOTATION, emits_changed, self),
+ file=sys.stderr)
return self.EMITS_CHANGED_UNKNOWN;
class Property(DBusConstruct, Typed, HasEmitsChangedAnnotation):
@@ -707,10 +710,11 @@ class AwkwardTelepathyProperty(Typed):
def __init__(self, parent, namespace, dom):
Typed.__init__(self, parent, namespace, dom)
- print >> sys.stderr, """
+ print("""
WARNING: Old-style Telepathy properties are deprecated!
(<tp:property> in %s)
- """.strip() % (parent)
+ """.strip() % (parent),
+ file=sys.stderr)
def get_type_name(self):
return 'Telepathy Property'
@@ -861,10 +865,10 @@ class Interface(Base, HasEmitsChangedAnnotation):
return spec.lookup(r)
except KeyError:
if not spec.allow_externals:
- print >> sys.stderr, """
+ print("""
WARNING: Interface not known: '%s'
(<tp:requires> in %s)
- """.strip() % (r, self)
+ """.strip() % (r, self), file=sys.stderr)
return External(r)
@@ -912,10 +916,11 @@ WARNING: Interface not known: '%s'
]
if unexpected:
- print >> sys.stderr, """
+ print("""
WARNING: Unknown element(s): %s
(in interface '%s')
- """.strip() % (', '.join([x.tagName for x in unexpected]), self.name)
+ """.strip() % (', '.join([x.tagName for x in unexpected]), self.name),
+ file=sys.stderr)
class Error(Base):
def get_url(self):
@@ -1287,7 +1292,7 @@ class Spec(SectionBase):
key=lambda e: e.name)
# build a list of generic types
- self.generic_types = reduce (lambda a, b: a + b,
+ self.generic_types = functools.reduce (lambda a, b: a + b,
map(lambda l: parse_types(self, l),
dom.getElementsByTagNameNS(XMLNS_TP, 'generic-types')),
[])
@@ -1333,12 +1338,12 @@ class Spec(SectionBase):
except IndexError:
self.version = None
- self.copyrights = map(getText,
- getChildrenByName(node, XMLNS_TP, 'copyright'))
+ self.copyrights = list(map(getText,
+ getChildrenByName(node, XMLNS_TP, 'copyright')))
try:
license = getChildrenByName(node, XMLNS_TP, 'license')[0]
- self.license = map(getText, license.getElementsByTagName('p'))
+ self.license = list(map(getText, license.getElementsByTagName('p')))
except IndexError:
self.license = []
@@ -1385,7 +1390,7 @@ def build_dict(parent, type_, namespace, nodes):
return dict(build_tuple(n) for n in nodes)
def build_list(parent, type_, namespace, nodes):
- return map(lambda node: type_(parent, namespace, node), nodes)
+ return list(map(lambda node: type_(parent, namespace, node), nodes))
def parse_types(parent, dom, namespace = None):
"""Parse all of the types of type nodes mentioned in 't' from the node
diff --git a/tools/xincludator.py b/tools/xincludator.py
index 63e106ac..9fcbc03f 100644
--- a/tools/xincludator.py
+++ b/tools/xincludator.py
@@ -1,17 +1,14 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
-from sys import argv, stdout, stderr
-import codecs, locale
+from sys import argv, stdout
import os
import xml.dom.minidom
-stdout = codecs.getwriter('utf-8')(stdout)
-
NS_XI = 'http://www.w3.org/2001/XInclude'
def xincludate(dom, base, dropns = []):
remove_attrs = []
- for i in xrange(dom.documentElement.attributes.length):
+ for i in range(dom.documentElement.attributes.length):
attr = dom.documentElement.attributes.item(i)
if attr.prefix == 'xmlns':
if attr.localName in dropns: