2007-01-24 22:24:01 +08:00
|
|
|
""" layout definition for generating api/source documents
|
|
|
|
|
|
|
|
this is the place where customization can be done
|
|
|
|
"""
|
|
|
|
|
|
|
|
import py
|
2007-02-02 23:49:58 +08:00
|
|
|
from py.__.doc import confrest
|
|
|
|
from py.__.apigen import linker
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-02-03 05:47:21 +08:00
|
|
|
here = py.magic.autopath().dirpath()
|
|
|
|
|
2007-02-02 23:49:58 +08:00
|
|
|
class LayoutPage(confrest.PyPage):
|
2007-01-24 22:24:01 +08:00
|
|
|
""" this provides the layout and style information """
|
|
|
|
|
2007-02-03 05:47:21 +08:00
|
|
|
stylesheets = [(here.join('../doc/style.css'), 'style.css'),
|
|
|
|
(here.join('style.css'), 'apigen_style.css')]
|
|
|
|
scripts = [(here.join('api.js'), 'api.js')]
|
2007-02-02 23:49:58 +08:00
|
|
|
|
2007-01-24 22:24:01 +08:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
self.nav = kwargs.pop('nav')
|
2007-02-02 23:49:58 +08:00
|
|
|
self.relpath = kwargs.pop('relpath')
|
2007-01-24 22:24:01 +08:00
|
|
|
super(LayoutPage, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
def set_content(self, contentel):
|
|
|
|
self.contentspace.append(contentel)
|
|
|
|
|
|
|
|
def fill(self):
|
|
|
|
super(LayoutPage, self).fill()
|
2007-02-04 23:47:33 +08:00
|
|
|
self.update_menubar_links(self.menubar)
|
2007-02-02 23:49:58 +08:00
|
|
|
self.body.insert(0, self.nav)
|
|
|
|
|
2007-02-04 23:47:33 +08:00
|
|
|
def update_menubar_links(self, node):
|
|
|
|
for item in node:
|
|
|
|
if not isinstance(item, py.xml.Tag):
|
|
|
|
continue
|
|
|
|
if (item.__class__.__name__ == 'a' and hasattr(item.attr, 'href')
|
|
|
|
and not item.attr.href.startswith('http://')):
|
|
|
|
item.attr.href = self.relpath + '../py/doc/' + item.attr.href
|
|
|
|
|
2007-02-02 23:49:58 +08:00
|
|
|
def setup_scripts_styles(self, copyto=None):
|
|
|
|
for path, name in self.stylesheets:
|
|
|
|
if copyto:
|
|
|
|
copyto.join(name).write(path.read())
|
|
|
|
self.head.append(py.xml.html.link(type='text/css',
|
|
|
|
rel='stylesheet',
|
|
|
|
href=self.relpath + name))
|
|
|
|
for path, name in self.scripts:
|
|
|
|
if copyto:
|
|
|
|
copyto.join(name).write(path.read())
|
2007-01-25 05:58:21 +08:00
|
|
|
self.head.append(py.xml.html.script(type="text/javascript",
|
2007-02-02 23:49:58 +08:00
|
|
|
src=self.relpath + name))
|
2007-01-24 22:24:01 +08:00
|
|
|
|