[svn r37305] Added some JavaScript to show and hide function information (source and such).
--HG-- branch : trunk
This commit is contained in:
parent
98c1c1809c
commit
6b9e9078c8
|
@ -0,0 +1,7 @@
|
|||
function showhideel(el) {
|
||||
if (el.style.display == 'none') {
|
||||
el.style.display = 'block';
|
||||
} else {
|
||||
el.style.display = 'none';
|
||||
};
|
||||
};
|
|
@ -130,13 +130,16 @@ def create_namespace_tree(dotted_names):
|
|||
ret[ns].append(itempath)
|
||||
return ret
|
||||
|
||||
def wrap_page(project, title, contentel, navel, outputpath, stylesheeturl):
|
||||
def wrap_page(project, title, contentel, navel, outputpath, stylesheeturl,
|
||||
scripturls):
|
||||
page = LayoutPage(project, title, nav=navel, encoding='UTF-8',
|
||||
stylesheeturl=stylesheeturl)
|
||||
stylesheeturl=stylesheeturl, scripturls=scripturls)
|
||||
page.set_content(contentel)
|
||||
here = py.magic.autopath().dirpath()
|
||||
style = here.join('style.css').read()
|
||||
outputpath.join('style.css').write(style)
|
||||
apijs = here.join('api.js').read()
|
||||
outputpath.join('api.js').write(apijs)
|
||||
return page
|
||||
|
||||
# the PageBuilder classes take care of producing the docs (using the stuff
|
||||
|
@ -146,8 +149,10 @@ class AbstractPageBuilder(object):
|
|||
targetpath = self.base.join(reltargetpath)
|
||||
stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
|
||||
self.base.join('style.css').strpath)
|
||||
scripturls = [relpath('%s/' % (targetpath.dirpath(),),
|
||||
self.base.join('api.js').strpath)]
|
||||
page = wrap_page(project, title,
|
||||
tag, nav, self.base, stylesheeturl)
|
||||
tag, nav, self.base, stylesheeturl, scripturls)
|
||||
content = self.linker.call_withbase(reltargetpath, page.unicode)
|
||||
targetpath.ensure()
|
||||
targetpath.write(content.encode("utf8"))
|
||||
|
@ -315,9 +320,11 @@ class ApiPageBuilder(AbstractPageBuilder):
|
|||
|
||||
snippet = H.FunctionDescription(
|
||||
H.FunctionDef(localname, argdesc),
|
||||
valuedesc,
|
||||
H.Docstring(docstring or H.em('no docstring available')),
|
||||
csource,
|
||||
H.div(H.a('show/hide info',
|
||||
onclick='showhideel(this.parentNode.lastChild);'),
|
||||
H.div(valuedesc, csource, style='display: none',
|
||||
class_='funcinfo')),
|
||||
)
|
||||
|
||||
return snippet
|
||||
|
@ -532,7 +539,7 @@ class ApiPageBuilder(AbstractPageBuilder):
|
|||
valuedesc.append(self.build_sig_value_description(name, _type))
|
||||
if retval:
|
||||
retval = self.process_type_link(retval)
|
||||
ret = H.div(H.div('where:'), valuedesc, H.div('return value:'),
|
||||
ret = H.div(H.div('arguments:'), valuedesc, H.div('return value:'),
|
||||
retval or 'None')
|
||||
return ret
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class LayoutPage(Page):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.nav = kwargs.pop('nav')
|
||||
self.scripturls = kwargs.pop('scripturls', [])
|
||||
super(LayoutPage, self).__init__(*args, **kwargs)
|
||||
|
||||
def set_content(self, contentel):
|
||||
|
@ -20,4 +21,7 @@ class LayoutPage(Page):
|
|||
super(LayoutPage, self).fill()
|
||||
self.menubar[:] = []
|
||||
self.menubar.append(self.nav)
|
||||
for scripturl in self.scripturls:
|
||||
self.head.append(py.xml.html.script(type="text/javascript",
|
||||
src=scripturl))
|
||||
|
||||
|
|
|
@ -63,43 +63,49 @@ ul li {
|
|||
}
|
||||
|
||||
.code a {
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #005;
|
||||
color: #005;
|
||||
}
|
||||
|
||||
|
||||
.lineno {
|
||||
text-align: right;
|
||||
color: #555;
|
||||
width: 3em;
|
||||
padding-right: 1em;
|
||||
border: 0px solid black;
|
||||
border-right-width: 1px;
|
||||
text-align: right;
|
||||
color: #555;
|
||||
width: 3em;
|
||||
padding-right: 1em;
|
||||
border: 0px solid black;
|
||||
border-right-width: 1px;
|
||||
}
|
||||
|
||||
.code {
|
||||
padding-left: 1em;
|
||||
white-space: pre;
|
||||
font-family: monospace, Monaco;
|
||||
padding-left: 1em;
|
||||
white-space: pre;
|
||||
font-family: monospace, Monaco;
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: purple;
|
||||
color: purple;
|
||||
}
|
||||
|
||||
.string {
|
||||
color: #777;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.keyword {
|
||||
color: blue;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.alt_keyword {
|
||||
color: green;
|
||||
color: green;
|
||||
}
|
||||
|
||||
|
||||
.funcinfo {
|
||||
border: 1px solid black;
|
||||
color: black;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ class TestApiPageBuilder(AbstractBuilderTest):
|
|||
print html
|
||||
run_string_sequence_test(html, [
|
||||
'href="../style.css"',
|
||||
'src="../api.js"',
|
||||
'href="index.html">pkg',
|
||||
'href="main.html">main',
|
||||
'href="main.SomeClass.html">SomeClass',
|
||||
|
|
Loading…
Reference in New Issue