Files
pytest2/py/apigen/layout.py
guido a6fd3c241e [svn r38439] Fixed a list of things suggested by hpk: changed method order in class pages,
changed page titles, added links to the api and source index from the nav bar
(also in py/doc html), changed function views, made it possible to remove an
item from the navigation, changed header 'properties' to 'class attributes and
properties', removed duplicate stack traces (in a somewhat unsatisfying way,
needs revisiting later I think).

--HG--
branch : trunk
2007-02-11 03:04:36 +01:00

54 lines
1.9 KiB
Python

""" layout definition for generating api/source documents
this is the place where customization can be done
"""
import py
from py.__.doc import confrest
from py.__.apigen import linker
here = py.magic.autopath().dirpath()
class LayoutPage(confrest.PyPage):
""" this provides the layout and style information """
stylesheets = [(here.join('../doc/style.css'), 'style.css'),
(here.join('style.css'), 'apigen_style.css')]
scripts = [(here.join('api.js'), 'api.js')]
def __init__(self, *args, **kwargs):
self.nav = kwargs.pop('nav')
self.relpath = kwargs.pop('relpath')
super(LayoutPage, self).__init__(*args, **kwargs)
self.project.logo.attr.id = 'logo'
def set_content(self, contentel):
self.contentspace.append(contentel)
def fill(self):
super(LayoutPage, self).fill()
self.update_menubar_links(self.menubar)
self.body.insert(0, self.nav)
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
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())
self.head.append(py.xml.html.script(type="text/javascript",
src=self.relpath + name))