polish documentation. reference table of content specifically

This commit is contained in:
Arvid Norberg
2015-03-13 05:42:18 +00:00
parent 6c1df7eb55
commit a76b2a40b0
8 changed files with 86 additions and 41 deletions

View File

@@ -61,6 +61,7 @@ static_links = \
anon_index = 0
category_mapping = {
'ed25519.hpp': 'ed25519',
'session.hpp': 'Session',
'add_torrent_params.hpp': 'Session',
'session_status.hpp': 'Session',
@@ -828,16 +829,16 @@ def print_link(name, target):
link_targets.append(target)
return "`%s`__" % name
def dump_link_targets():
def dump_link_targets(indent = ''):
global link_targets
ret = '\n'
for l in link_targets:
ret += '__ %s\n' % l
ret += '%s__ %s\n' % (indent, l)
link_targets = []
return ret
def heading(string, c):
return '\n' + string + '\n' + (c * len(string)) + '\n'
def heading(string, c, indent = ''):
return '\n' + indent + string + '\n' + indent + (c * len(string)) + '\n'
def render_enums(out, enums, print_declared_reference):
for e in enums:
@@ -873,45 +874,65 @@ def render_enums(out, enums, print_declared_reference):
print >>out, dump_link_targets()
sections = \
{
'Core': 0,
'Session': 0,
'Settings': 0,
'Bencoding': 1,
'Bdecoding': 1,
'Filter': 1,
'Error Codes': 1,
'Create Torrents': 1,
'ed25519': 2,
'String': 2,
'Utility': 2,
'Storage': 2,
'Custom Storage': 2,
'Plugins': 2,
'Alerts': 3
}
def print_toc(out, categories, s):
for cat in categories:
if (s != 2 and cat not in sections) or \
(cat in sections and sections[cat] != s): continue
print >>out, '\t.. rubric:: %s\n' % cat
if 'overview' in categories[cat]:
print >>out, '\t| overview__'
category_filename = categories[cat]['filename'].replace('.rst', '.html')
for c in categories[cat]['classes']:
print >>out, '\t| ' + print_link(c['name'], symbols[c['name']])
for f in categories[cat]['functions']:
for n in f['names']:
print >>out, '\t| ' + print_link(n, symbols[n])
for e in categories[cat]['enums']:
print >>out, '\t| ' + print_link(e['name'], symbols[e['name']])
print >>out, ''
if 'overview' in categories[cat]:
print >>out, '\t__ %s#overview' % categories[cat]['filename'].replace('.rst', '.html')
print >>out, dump_link_targets('\t')
out = open('reference.rst', 'w+')
out.write('''==================================
libtorrent reference documentation
==================================
.. raw:: html
<div style="column-count: 4; -webkit-column-count: 4; -moz-column-count: 4">
out.write('''=======================
reference documentation
=======================
''')
for cat in categories:
print >>out, '%s' % heading(cat, '-')
for i in range(4):
if 'overview' in categories[cat]:
print >>out, '| overview__'
out.write('.. container:: main-toc\n\n')
print_toc(out, categories, i)
category_filename = categories[cat]['filename'].replace('.rst', '.html')
for c in categories[cat]['classes']:
print >>out, '| ' + print_link(c['name'], symbols[c['name']])
for f in categories[cat]['functions']:
for n in f['names']:
print >>out, '| ' + print_link(n, symbols[n])
for e in categories[cat]['enums']:
print >>out, '| ' + print_link(e['name'], symbols[e['name']])
print >>out, ''
if 'overview' in categories[cat]:
print >>out, '__ %s#overview' % categories[cat]['filename'].replace('.rst', '.html')
print >>out, dump_link_targets()
out.write('''
.. raw:: html
</div>
''')
out.close()
for cat in categories:

View File

@@ -19,6 +19,8 @@ REFERENCE_TARGETS = \
reference-RSS \
reference-Filter \
reference-Settings \
reference-Bdecoding \
reference-ed25519 \
manual-ref
TARGETS = index \

View File

@@ -35,6 +35,23 @@ h3 { text-transform: uppercase; }
div.section p, div.section ul, div.section dl {
}
div.main-toc {
column-count: 4;
-webkit-column-count: 4;
-moz-column-count: 4;
border: 1px solid #999;
padding: 5px;
margin-bottom: 10px;
}
.rubric
{
margin-top: 5px;
margin-bottom: 5px;
font-size: 120%;
font-weight: bold;
}
table.docinfo {
text-align: left;
float: right;
@@ -57,7 +74,7 @@ table.docinfo td {
table.docinfo tr.field td, table.docinfo tr.field th {display: none;}
h1.title { display: none; }
#h1.title { display: none; }
dt {
font-size: 100%;