diff --git a/py/apigen/html.py b/py/apigen/html.py
index d6b3b6e7a..9149e9dfc 100644
--- a/py/apigen/html.py
+++ b/py/apigen/html.py
@@ -134,22 +134,32 @@ class H(html):
super(H.PythonSource, self).__init__(
H.div(*sourceels))
- class SourceBlock(html.div):
- style = html.Style(margin_top='1em', margin_bottom='1em')
+ class SourceBlock(html.table):
def __init__(self):
- self.linenotable = lntable = H.table(style='float: left')
+ tbody = H.tbody()
+ row = H.tr()
+ tbody.append(row)
+ linenocell = H.td(style='width: 1%')
+ row.append(linenocell)
+ linecell = H.td()
+ row.append(linecell)
+
+ self.linenotable = lntable = H.table()
self.linenotbody = lntbody = H.tbody()
lntable.append(lntbody)
+ linenocell.append(lntable)
self.linetable = ltable = H.table()
self.linetbody = ltbody = H.tbody()
ltable.append(ltbody)
-
- super(H.SourceBlock, self).__init__(lntable, ltable)
+ linecell.append(ltable)
+
+ super(H.SourceBlock, self).__init__(tbody, class_='codeblock')
def add_line(self, lineno, els):
self.linenotbody.append(H.tr(H.td(lineno, class_='lineno')))
- self.linetbody.append(H.tr(H.td(class_='code', *els)))
+ self.linetbody.append(H.tr(H.td(H.pre(class_='code', *els),
+ class_='codecell')))
class NonPythonSource(Content):
def __init__(self, *args):
diff --git a/py/apigen/htmlgen.py b/py/apigen/htmlgen.py
index 15a447e48..459ab4a9b 100644
--- a/py/apigen/htmlgen.py
+++ b/py/apigen/htmlgen.py
@@ -247,7 +247,7 @@ class SourcePageBuilder(AbstractPageBuilder):
enc = source_html.get_module_encoding(fspath.strpath)
source = fspath.read()
sep = get_linesep(source)
- colored = enumerate_and_color(source.split(sep), 0, enc)
+ colored = [enumerate_and_color(source.split(sep), 0, enc)]
tag = H.PythonSource(colored)
nav = self.build_navigation(fspath)
return tag, nav
diff --git a/py/apigen/style.css b/py/apigen/style.css
index 0b3154028..b9daaf691 100644
--- a/py/apigen/style.css
+++ b/py/apigen/style.css
@@ -12,16 +12,25 @@ div.sidebar {
font-size: 0.9em;
width: 155px;
vertical-align: top;
- margin-top: 0.5em;
position: absolute;
- position: fixed;
top: 130px;
left: 4px;
bottom: 4px;
overflow: auto;
}
-div.sidebar .selected a {
+/* trick to not make IE ignore something (>) */
+body > .sidebar {
+ position: fixed;
+}
+
+div.sidebar a, div.sidebar a:visited, div.sidebar a:hover {
+ color: blue;
+ text-decoration: none;
+}
+
+div.sidebar .selected a, div.sidebar .selected a:visited,
+div.sidebar .selected a:hover {
color: white;
background-color: #3ba6ec;
}
@@ -52,6 +61,11 @@ h2.funcdef:hover {
text-decoration: underline;
}
+.codeblock {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
.code a {
color: blue;
font-weight: bold;
@@ -69,14 +83,20 @@ h2.funcdef:hover {
border-right-width: 1px;
}
-.code {
+.codecell {
line-height: 1.4em;
height: 1.4em;
padding-left: 1em;
- white-space: pre;
+}
+
+pre.code {
+ line-height: 1.3em;
+ height: 1.3em;
+ background-color: white;
+ margin: 0px;
+ padding: 0px;
+ border: 0px;
font-family: monospace, Monaco;
- margin-top: 0.5em;
- margin-bottom: 0.5em;
}
.comment {
diff --git a/py/apigen/testing/test_htmlgen.py b/py/apigen/testing/test_htmlgen.py
index 9790afea8..9ca27652c 100644
--- a/py/apigen/testing/test_htmlgen.py
+++ b/py/apigen/testing/test_htmlgen.py
@@ -65,56 +65,86 @@ def test_deindent():
def test_enumerate_and_color():
colored = htmlgen.enumerate_and_color(['def foo():', ' print "bar"'], 0,
'ascii')
- div = py.xml.html.div(*colored).unicode(indent=0)
+ div = py.xml.html.div(colored).unicode(indent=0)
print repr(div)
- assert_eq_string(div,
+ assert_eq_string(div,
u'
'
- '
'
+ ''
+ ''
+ ''
+ ''
+ ''
+ ' | '
+ ''
''
''
- ''
+ ' | '
+ ''
'def foo():'
+ ' '
' | '
- ''
+ ' | '
+ ''
' print'
' "bar"'
+ ' '
' | '
''
' '
+ ' | '
+ '
'
+ ''
+ '
'
'')
def test_enumerate_and_color_multiline():
colored = htmlgen.enumerate_and_color(['code = """\\', 'foo bar', '"""'],
0, 'ascii')
- div = py.xml.html.div(*colored).unicode(indent=0)
+ div = py.xml.html.div(colored).unicode(indent=0)
print repr(div)
- assert_eq_string (div,
+ assert_eq_string (div,
u''
- '
'
+ ''
+ ''
+ ''
+ ''
+ ''
+ ' | '
+ ''
''
''
- ''
+ ' | '
+ ''
'code = """\\'
+ ' '
' | '
- ''
+ ' | '
+ ''
'foo bar'
+ ' '
' | '
- ''
+ ' | '
+ ''
'"""'
+ ' '
' | '
''
' '
+ ' | '
+ '
'
+ ''
+ '
'
'')
def test_show_property():
diff --git a/py/apigen/todo.txt b/py/apigen/todo.txt
index c123a09fb..be36e68d0 100644
--- a/py/apigen/todo.txt
+++ b/py/apigen/todo.txt
@@ -15,6 +15,12 @@
* get konqueror to display indents in source code better?
(currently it doesn't look like more than a single space)
+ Hrmph, fonts look just fine to me :( what machine is this (new laptop btw?)?
+ you seem to have a font problem... If you really want me to fix it for your
+ machine, please give me access...
+
+ I also made sure IE looks (somewhat) good...
+
* function view:
def __init__(self, rawcode):
@@ -44,3 +50,12 @@
note that both relpath's are related to how we map docs and
apigen into the URL namespace.
+ Currently handled by using an env var (APIGEN_DOCRELPATH), since
+ to make it possible to run py.test --apigen on the full py lib _and_
+ set the option, it would have to be global (yuck), and apigen used
+ an env var already anyway... Of course it can easily be changed to an
+ option if you like that better...
+
+ There's now also a script bin/_docgen.py that runs all the tests
+ and builds the py lib docs + api ones in one go.
+