3 |
3 |
4 from genshi.template import TemplateLoader |
4 from genshi.template import TemplateLoader |
5 from genshi import Markup |
5 from genshi import Markup |
6 loader = TemplateLoader('doc/tmpl', auto_reload=True) |
6 loader = TemplateLoader('doc/tmpl', auto_reload=True) |
7 |
7 |
|
8 |
|
9 from glob import glob |
|
10 import re |
|
11 import os.path |
8 import inspect |
12 import inspect |
|
13 from pkg_resources import parse_version |
|
14 |
9 from docutils.core import publish_doctree |
15 from docutils.core import publish_doctree |
10 import docutils |
16 import docutils |
11 |
17 |
12 #-- |
18 #-- |
13 from docutils import core |
19 from docutils import core |
14 from docutils.writers.html4css1 import Writer,HTMLTranslator |
20 from docutils.writers.html4css1 import Writer,HTMLTranslator |
|
21 |
|
22 from iro.view.xmlrpc import TwistedInterface as Current |
|
23 from iro import __version__ |
|
24 from createerm import createSchemaPlot, tables, tables_cls |
15 |
25 |
16 class NoHeaderHTMLTranslator(HTMLTranslator): |
26 class NoHeaderHTMLTranslator(HTMLTranslator): |
17 def __init__(self, document): |
27 def __init__(self, document): |
18 HTMLTranslator.__init__(self,document) |
28 HTMLTranslator.__init__(self,document) |
19 self.body_prefix = [] |
29 self.body_prefix = [] |
167 title=self.tablename[0].upper()+self.tablename[1:] |
174 title=self.tablename[0].upper()+self.tablename[1:] |
168 Link.__init__(self,name,title) |
175 Link.__init__(self,name,title) |
169 |
176 |
170 self.description = Markup(core.publish_string(cls.__doc__,writer=_w)) |
177 self.description = Markup(core.publish_string(cls.__doc__,writer=_w)) |
171 |
178 |
|
179 class File: |
|
180 def __init__(self,path): |
|
181 self.version = re.search("/iro-(.*).tar.gz",path).group(1) |
|
182 self.name = os.path.basename(path) |
|
183 |
172 |
184 |
173 def main(): |
185 def main(): |
174 sites=[Site("index.html","Iro"), |
186 sites=[Site("index.html","Iro"), |
175 Site("current.html","API Documentation"), |
187 Site("current.html","API Documentation"), |
176 Site("database.html","Datenbase Schema"), |
188 Site("database.html","Datenbase Schema"), |
177 Site("about.html","About us"), |
189 Site("about.html","About us"), |
178 ] |
190 ] |
179 |
191 |
|
192 files=[File(f) for f in glob("web/files/*tar.gz")] |
|
193 files.sort(key=lambda a:parse_version(a.version),reverse=True) |
|
194 code ="files/iro-%s.tar.gz"%__version__ |
|
195 |
180 current_methods = dict(inspect.getmembers(Current())) |
196 current_methods = dict(inspect.getmembers(Current())) |
181 current=[ Method(i,current_methods) for i in Current().listMethods() if i != "listMethods" ] |
197 current=[ Method(i,current_methods) for i in Current().listMethods() if i != "listMethods" ] |
182 |
198 |
183 t = [Table(tables_cls[str(f)]) for f in tables] |
199 t = [Table(tables_cls[str(f)]) for f in tables] |
184 createSchemaPlot('doc/images/db-schema.svg') |
200 createSchemaPlot('web/images/db-schema.svg') |
|
201 |
|
202 gd = {"sites":sites, |
|
203 "current":current, |
|
204 "tables": t, |
|
205 "code":code, |
|
206 "files":files |
|
207 } |
185 |
208 |
186 for site in sites: |
209 for site in sites: |
187 print("generiere %s" % site.name) |
210 print("generiere %s" % site.name) |
188 tmpl = loader.load(site.name) |
211 tmpl = loader.load(site.name) |
189 def a(s): |
212 def a(s): |
190 if s == site: |
213 if s == site: |
191 return {"class":"menu active"} |
214 return {"class":"menu active"} |
192 stream = tmpl.generate(sites=sites, active=a, current=current, tables=t) |
215 stream = tmpl.generate(active=a, **gd) |
193 with open('doc/'+site.name, "w") as g: |
216 with open('web/'+site.name, "w") as g: |
194 g.write(stream.render('html', doctype='html')) |
217 g.write(stream.render('html', doctype='html')) |
195 |
218 |
196 if __name__ == '__main__': |
219 if __name__ == '__main__': |
197 main() |
220 main() |