[Telepathy-commits] [telepathy-spec/master] Add a TOC
Davyd Madeley
davyd at madeley.id.au
Mon Mar 23 12:29:17 PDT 2009
---
doc/templates/index.html | 17 +++++++++++++++++
tools/doc-generator.py | 36 +++++++++++++++++++++++++-----------
tools/specparser.py | 6 ++++++
3 files changed, 48 insertions(+), 11 deletions(-)
create mode 100644 doc/templates/index.html
diff --git a/doc/templates/index.html b/doc/templates/index.html
new file mode 100644
index 0000000..d58d9bc
--- /dev/null
+++ b/doc/templates/index.html
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-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>FIXME - get this from the XML</title>
+ <link rel="stylesheet" href="style.css" type="text/css"/>
+ </head>
+ <body>
+ <h1>FIXME - get this from the XML</h1>
+
+ <ul>
+ #for $interface in $interfaces.values()
+ <li><a href="$interface.get_url()">$interface.name</a></li>
+ #end for
+ </ul>
+ </body>
+</html>
diff --git a/tools/doc-generator.py b/tools/doc-generator.py
index e938ee1..e9109a8 100755
--- a/tools/doc-generator.py
+++ b/tools/doc-generator.py
@@ -12,23 +12,27 @@ except ImportError, e:
import specparser
-interfaces = specparser.parse (sys.argv[1])
-
-# load the template
template_path = os.path.join (os.path.dirname (sys.argv[0]),
'../doc/templates')
output_path = os.path.join (os.path.dirname (sys.argv[0]),
'../doc/spec')
-try:
- file = open (os.path.join (template_path, 'interface.html'))
- template_def = file.read ()
- file.close ()
-except IOError, e:
- print >> sys.stderr, "Could not load template file `interface.html'"
- print >> sys.stderr, e
- sys.exit (-1)
+def load_template (filename):
+ try:
+ 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
+ sys.exit (-1)
+ return template_def
+
+interfaces = specparser.parse (sys.argv[1])
+
+# write out HTML files for each of the interfaces
+template_def = load_template ('interface.html')
for interface in interfaces.values ():
namespace = { 'interface': interface }
t = Template (template_def, namespaces = [namespace])
@@ -37,3 +41,13 @@ for interface in interfaces.values ():
out = open (os.path.join (output_path, '%s.html' % interface.name), 'w')
print >> out, t
out.close ()
+
+# write out a TOC
+template_def = load_template ('index.html')
+namespace = { 'interfaces': interfaces }
+t = Template (template_def, namespaces = [namespace])
+
+# open the output file
+out = open (os.path.join (output_path, 'index.html'), 'w')
+print >> out, t
+out.close ()
diff --git a/tools/specparser.py b/tools/specparser.py
index 11adc39..806a02d 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -34,6 +34,9 @@ class base (object):
def get_short_name (self):
return self.name.rsplit ('.', 1)[1]
+ def get_url (self):
+ return "%s#%s" % (self.get_interface ().get_url (), self.name)
+
def __repr__ (self):
return '%s(%s)' % (self.__class__.__name__, self.name)
@@ -129,6 +132,9 @@ class Interface (base):
def get_interface (self):
return self
+
+ def get_url (self):
+ return "%s.html" % self.name
class Error (base): pass
--
1.5.6.5
More information about the telepathy-commits
mailing list