[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)
|
ret[ns].append(itempath)
|
||||||
return ret
|
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',
|
page = LayoutPage(project, title, nav=navel, encoding='UTF-8',
|
||||||
stylesheeturl=stylesheeturl)
|
stylesheeturl=stylesheeturl, scripturls=scripturls)
|
||||||
page.set_content(contentel)
|
page.set_content(contentel)
|
||||||
here = py.magic.autopath().dirpath()
|
here = py.magic.autopath().dirpath()
|
||||||
style = here.join('style.css').read()
|
style = here.join('style.css').read()
|
||||||
outputpath.join('style.css').write(style)
|
outputpath.join('style.css').write(style)
|
||||||
|
apijs = here.join('api.js').read()
|
||||||
|
outputpath.join('api.js').write(apijs)
|
||||||
return page
|
return page
|
||||||
|
|
||||||
# the PageBuilder classes take care of producing the docs (using the stuff
|
# the PageBuilder classes take care of producing the docs (using the stuff
|
||||||
|
@ -146,8 +149,10 @@ class AbstractPageBuilder(object):
|
||||||
targetpath = self.base.join(reltargetpath)
|
targetpath = self.base.join(reltargetpath)
|
||||||
stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
|
stylesheeturl = relpath('%s/' % (targetpath.dirpath(),),
|
||||||
self.base.join('style.css').strpath)
|
self.base.join('style.css').strpath)
|
||||||
|
scripturls = [relpath('%s/' % (targetpath.dirpath(),),
|
||||||
|
self.base.join('api.js').strpath)]
|
||||||
page = wrap_page(project, title,
|
page = wrap_page(project, title,
|
||||||
tag, nav, self.base, stylesheeturl)
|
tag, nav, self.base, stylesheeturl, scripturls)
|
||||||
content = self.linker.call_withbase(reltargetpath, page.unicode)
|
content = self.linker.call_withbase(reltargetpath, page.unicode)
|
||||||
targetpath.ensure()
|
targetpath.ensure()
|
||||||
targetpath.write(content.encode("utf8"))
|
targetpath.write(content.encode("utf8"))
|
||||||
|
@ -315,9 +320,11 @@ class ApiPageBuilder(AbstractPageBuilder):
|
||||||
|
|
||||||
snippet = H.FunctionDescription(
|
snippet = H.FunctionDescription(
|
||||||
H.FunctionDef(localname, argdesc),
|
H.FunctionDef(localname, argdesc),
|
||||||
valuedesc,
|
|
||||||
H.Docstring(docstring or H.em('no docstring available')),
|
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
|
return snippet
|
||||||
|
@ -532,7 +539,7 @@ class ApiPageBuilder(AbstractPageBuilder):
|
||||||
valuedesc.append(self.build_sig_value_description(name, _type))
|
valuedesc.append(self.build_sig_value_description(name, _type))
|
||||||
if retval:
|
if retval:
|
||||||
retval = self.process_type_link(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')
|
retval or 'None')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class LayoutPage(Page):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.nav = kwargs.pop('nav')
|
self.nav = kwargs.pop('nav')
|
||||||
|
self.scripturls = kwargs.pop('scripturls', [])
|
||||||
super(LayoutPage, self).__init__(*args, **kwargs)
|
super(LayoutPage, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def set_content(self, contentel):
|
def set_content(self, contentel):
|
||||||
|
@ -20,4 +21,7 @@ class LayoutPage(Page):
|
||||||
super(LayoutPage, self).fill()
|
super(LayoutPage, self).fill()
|
||||||
self.menubar[:] = []
|
self.menubar[:] = []
|
||||||
self.menubar.append(self.nav)
|
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 {
|
.code a {
|
||||||
color: blue;
|
color: blue;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
color: #005;
|
color: #005;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lineno {
|
.lineno {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: #555;
|
color: #555;
|
||||||
width: 3em;
|
width: 3em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
border: 0px solid black;
|
border: 0px solid black;
|
||||||
border-right-width: 1px;
|
border-right-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code {
|
.code {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
font-family: monospace, Monaco;
|
font-family: monospace, Monaco;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment {
|
.comment {
|
||||||
color: purple;
|
color: purple;
|
||||||
}
|
}
|
||||||
|
|
||||||
.string {
|
.string {
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
.keyword {
|
.keyword {
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alt_keyword {
|
.alt_keyword {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.funcinfo {
|
||||||
|
border: 1px solid black;
|
||||||
|
color: black;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ class TestApiPageBuilder(AbstractBuilderTest):
|
||||||
print html
|
print html
|
||||||
run_string_sequence_test(html, [
|
run_string_sequence_test(html, [
|
||||||
'href="../style.css"',
|
'href="../style.css"',
|
||||||
|
'src="../api.js"',
|
||||||
'href="index.html">pkg',
|
'href="index.html">pkg',
|
||||||
'href="main.html">main',
|
'href="main.html">main',
|
||||||
'href="main.SomeClass.html">SomeClass',
|
'href="main.SomeClass.html">SomeClass',
|
||||||
|
|
Loading…
Reference in New Issue