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')
|
|
|
|
super(LayoutPage, self).__init__(*args, **kwargs)
|
2007-02-14 07:56:57 +08:00
|
|
|
self.relpath = self.get_relpath()
|
2007-02-11 10:04:36 +08:00
|
|
|
self.project.logo.attr.id = 'logo'
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-02-14 07:56:57 +08:00
|
|
|
def get_relpath(self):
|
|
|
|
return linker.relpath(self.targetpath.strpath,
|
2009-02-27 18:18:27 +08:00
|
|
|
self.project.apigenpath.strpath) + '/'
|
2007-02-14 07:56:57 +08:00
|
|
|
|
2007-01-24 22:24:01 +08:00
|
|
|
def set_content(self, contentel):
|
|
|
|
self.contentspace.append(contentel)
|
|
|
|
|
|
|
|
def fill(self):
|
|
|
|
super(LayoutPage, self).fill()
|
2007-02-02 23:49:58 +08:00
|
|
|
self.body.insert(0, self.nav)
|
|
|
|
|
|
|
|
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
|
|
|
|