[py-svn] r37066 - in py/dist/py/apigen: . testing
guido at codespeak.net
guido at codespeak.net
Sat Jan 20 17:37:40 CET 2007
Author: guido
Date: Sat Jan 20 17:37:38 2007
New Revision: 37066
Modified:
py/dist/py/apigen/htmlgen.py
py/dist/py/apigen/testing/test_apigen_example.py
Log:
Fixed stylesheet links.
Modified: py/dist/py/apigen/htmlgen.py
==============================================================================
--- py/dist/py/apigen/htmlgen.py (original)
+++ py/dist/py/apigen/htmlgen.py Sat Jan 20 17:37:38 2007
@@ -5,6 +5,7 @@
from py.__.apigen.source import html as source_html
from py.__.apigen.tracer.description import is_private
from py.__.apigen.rest.genrest import split_of_last_part
+from py.__.apigen.linker import relpath
sorted = py.builtin.sorted
html = py.xml.html
@@ -234,7 +235,7 @@
if child.ext in ['.pyc', '.pyo']:
continue
files.append(child)
- return dirs, files
+ return sorted(dirs), sorted(files)
def build_source_navigation(linker, projroot, fspath, outputpath):
nav = H.Navigation()
@@ -264,10 +265,10 @@
# we're a file, build our parent's children only
dirpath = fspath.dirpath()
diritems, fileitems = source_dirs_files(dirpath)
- for dir in sorted(diritems):
+ for dir in diritems:
nav.append(build_navitem_html(linker, dir.basename, dir.strpath,
indent, False))
- for file in sorted(fileitems):
+ for file in fileitems:
selected = (fspath.check(file=True) and
file.basename == fspath.basename)
nav.append(build_navitem_html(linker, file.basename, file.strpath,
@@ -316,7 +317,9 @@
# skip hidden dirs and files
continue
elif fspath.check(dir=True):
- reloutputpath = 'source/%s/index.html' % (relfspath,)
+ if relfspath != '':
+ relfspath += '/'
+ reloutputpath = 'source/%sindex.html' % (relfspath,)
else:
reloutputpath = "source/%s.html" % (relfspath,)
outputpath = outputbase.join(reloutputpath)
@@ -348,8 +351,10 @@
else:
tag, nav = build_source_nonpython_page(linker, projroot, fspath,
outputpath)
+ stylesheeturl = relpath('%s/' % (outputpath.dirpath(),),
+ '%s' % (outputbase.join('style.css'),))
page = wrap_page(project, 'sources for %s' % (fspath.basename,),
- tag, nav, outputbase)
+ tag, nav, outputbase, stylesheeturl)
outputpath.ensure()
reltargetpath = outputpath.relto(outputbase)
content = linker.call_withbase(reltargetpath, page.unicode)
@@ -382,10 +387,12 @@
def build_class_api_pages(linker, data, project, outputbase):
""" build the full api pages for a set of classes """
for dotted_name, tag, nav, reltargetpath in data:
+ targetpath = outputbase.ensure(reltargetpath)
+ stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
+ outputbase.join('style.css').strpath)
page = wrap_page(project, 'api documentation for %s' % (dotted_name,),
- tag, nav, outputbase)
+ tag, nav, outputbase, stylesheeturl)
content = linker.call_withbase(reltargetpath, page.unicode)
- targetpath = outputbase.ensure(reltargetpath)
targetpath.write(content.encode("utf8"))
def prepare_method_api_pages(linker, dsa, base, namespace_tree,
@@ -407,10 +414,12 @@
def build_method_api_pages(linker, data, project, outputbase):
for dotted_name, tag, nav, reltargetpath in data:
+ targetpath = outputbase.join(reltargetpath)
+ stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
+ outputbase.join('style.css').strpath)
page = wrap_page(project, 'api documentation for %s' % (dotted_name,),
- tag, nav, outputbase)
+ tag, nav, outputbase, stylesheeturl)
content = linker.call_withbase(reltargetpath, page.unicode)
- targetpath = outputbase.join(reltargetpath)
targetpath.ensure()
targetpath.write(content.encode("utf8"))
@@ -431,10 +440,12 @@
def build_function_api_pages(linker, data, project, outputbase):
for dotted_name, tag, nav, reltargetpath in data:
+ targetpath = outputbase.join(reltargetpath)
+ stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
+ outputbase.join('style.css').strpath)
page = wrap_page(project, 'api documentation for %s' % (dotted_name,),
- tag, nav, outputbase)
+ tag, nav, outputbase, stylesheeturl)
content = linker.call_withbase(reltargetpath, page.unicode)
- targetpath = outputbase.join(reltargetpath)
targetpath.ensure()
targetpath.write(content.encode("utf8"))
@@ -462,16 +473,18 @@
for dotted_name, tag, nav, reltargetpath in data:
if dotted_name == '':
dotted_name = 'project root'
+ targetpath = outputbase.join(reltargetpath)
+ stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
+ outputbase.join('style.css').strpath)
page = wrap_page(project, 'index of %s namespace' % (dotted_name,),
- tag, nav, outputbase)
+ tag, nav, outputbase, stylesheeturl)
content = linker.call_withbase(reltargetpath, page.unicode)
- targetpath = outputbase.join(reltargetpath)
targetpath.ensure()
targetpath.write(content.encode("utf8"))
-def wrap_page(project, title, contentel, navel, outputpath):
+def wrap_page(project, title, contentel, navel, outputpath, stylesheeturl):
page = LayoutPage(project, title, nav=navel, encoding='UTF-8',
- stylesheeturl='style.css',)
+ stylesheeturl=stylesheeturl)
page.set_content(contentel)
here = py.magic.autopath().dirpath()
style = here.join('style.css').read()
Modified: py/dist/py/apigen/testing/test_apigen_example.py
==============================================================================
--- py/dist/py/apigen/testing/test_apigen_example.py (original)
+++ py/dist/py/apigen/testing/test_apigen_example.py Sat Jan 20 17:37:38 2007
@@ -139,6 +139,7 @@
print html
# note that the root and the first level both have the same name (pkg)
# in our example project (XXX fixme!!)
+ assert 'href="../style.css"' in html
assert 'href="index.html">pkg' in html
assert 'href="pkg.html">pkg' in html
assert 'href="pkg.SomeClass.html">SomeClass' in html
@@ -160,6 +161,8 @@
clsfile = base.join('api/pkg.SomeSubClass.html')
assert clsfile.check()
html = clsfile.read()
+ print html
+ assert 'href="../style.css"' in html
assert 'href="pkg.SomeClass.html">pkg.SomeClass' in html
_checkhtml(html)
@@ -178,7 +181,8 @@
assert funcsource.check(file=True)
html = funcsource.read()
print html
- #assert '<a href="../index.html">py</a>' in html
+ assert 'href="../../style.css"' in html
+ assert '<a href="../index.html">root</a>' in html
assert '<a href="index.html">pkg</a>' in html
assert '<a href="someclass.py.html">someclass.py</a>' in html
assert '<a href="somesubclass.py.html">somesubclass.py</a>' in html
@@ -315,8 +319,7 @@
self.fs_root.join('pkg'), base)
html = nav.unicode(indent=0)
print html.encode('UTF-8')
- # XXX fix the double slash!!
- assert 'href="source//index.html">root' in html
+ assert 'href="source/index.html">root' in html
assert 'href="source/pkg/index.html">pkg' in html
assert 'href="source/pkg/func.py.html">func.py' in html
assert 'href="source/pkg/someclass.py.html">someclass.py' in html
More information about the pytest-commit
mailing list