From f643f601c6dd59d7c67dfc94317a99719cb3d458 Mon Sep 17 00:00:00 2001 From: hpk Date: Tue, 13 Feb 2007 23:20:05 +0100 Subject: [PATCH] [svn r38763] overriding the new a_docref and a_apigenref Page helper methods, getting rid of update_menubar_links --HG-- branch : trunk --- py/apigen/layout.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/py/apigen/layout.py b/py/apigen/layout.py index 9e509f143..1b54d4d79 100644 --- a/py/apigen/layout.py +++ b/py/apigen/layout.py @@ -27,19 +27,24 @@ class LayoutPage(confrest.PyPage): 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): - docrelpath = py.std.os.environ.get('APIGEN_DOCRELPATH', '../py/doc') - if not docrelpath.endswith('/'): - docrelpath += '/' - 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 + docrelpath + item.attr.href + def _getdocrelpath(self, default="../py/doc"): + docrel = py.std.os.environ.get("APIGEN_DOCRELPATH", default) + return docrel.rstrip("/") + "/" + + def a_docref(self, name, relhtmlpath): + docrelpath = self._getdocrelpath() + relnew = self.relpath + docrelpath + relhtmlpath + return super(LayoutPage, self).a_docref(name, relnew) + + def a_apigenref(self, name, relhtmlpath): + # XXX the path construction is probably rather too complicated + # but i reused the same logic that was there + # before. + docrelpath = self._getdocrelpath() + relnew = self.relpath + docrelpath + relhtmlpath + return super(LayoutPage, self).a_apigenref(name, relnew) def setup_scripts_styles(self, copyto=None): for path, name in self.stylesheets: