restore gen_stats_docs.py
This commit is contained in:
parent
8fc07e6e89
commit
5b73194a0d
|
@ -0,0 +1,75 @@
|
||||||
|
f = open('../src/session_stats.cpp')
|
||||||
|
|
||||||
|
out = open('stats_counters.rst', 'w+')
|
||||||
|
|
||||||
|
def print_field(str, width):
|
||||||
|
return '%s%s' % (str, ' ' * (width - len(str)))
|
||||||
|
|
||||||
|
def render_section(names, description, types):
|
||||||
|
max_name_len = max(len(max(names, key=len)), len('name'))
|
||||||
|
max_type_len = max(len(max(types, key=len)), len('type'))
|
||||||
|
|
||||||
|
if description == '':
|
||||||
|
for n in names:
|
||||||
|
print 'WARNING: no description for "%s"' % n
|
||||||
|
|
||||||
|
# add link targets for the rest of the manual to reference
|
||||||
|
for n in names:
|
||||||
|
print >>out, '.. _%s:\n' % n
|
||||||
|
|
||||||
|
if len(names) > 0:
|
||||||
|
print >>out, '.. raw:: html\n'
|
||||||
|
for n in names:
|
||||||
|
print >>out, '\t<a name="%s"></a>' % n
|
||||||
|
print >>out, ''
|
||||||
|
|
||||||
|
separator = '+-' + ('-' * max_name_len) + '-+-' + ('-' * max_type_len) + '-+'
|
||||||
|
|
||||||
|
# build a table for the settings, their type and default value
|
||||||
|
print >>out, separator
|
||||||
|
print >>out, '| %s | %s |' % (print_field('name', max_name_len), print_field('type', max_type_len))
|
||||||
|
print >>out, separator.replace('-', '=')
|
||||||
|
for i in range(len(names)):
|
||||||
|
print >>out, '| %s | %s |' % (print_field(names[i], max_name_len), print_field(types[i], max_type_len))
|
||||||
|
print >>out, separator
|
||||||
|
print >>out
|
||||||
|
print >>out, description
|
||||||
|
print >>out, ''
|
||||||
|
|
||||||
|
mode = ''
|
||||||
|
|
||||||
|
description = ''
|
||||||
|
names = []
|
||||||
|
types = []
|
||||||
|
|
||||||
|
for l in f:
|
||||||
|
l = l.strip()
|
||||||
|
|
||||||
|
if l.startswith('// '):
|
||||||
|
if len(names) > 0:
|
||||||
|
render_section(names, description, types)
|
||||||
|
description = ''
|
||||||
|
names = []
|
||||||
|
types = []
|
||||||
|
|
||||||
|
description += '\n' + l[3:]
|
||||||
|
|
||||||
|
if '#define' in l: continue
|
||||||
|
|
||||||
|
if 'METRIC(' in l:
|
||||||
|
args = l.split('(')[1].split(')')[0].split(',')
|
||||||
|
|
||||||
|
# args: category, name, type
|
||||||
|
|
||||||
|
names.append(args[0].strip() + '.' + args[1].strip())
|
||||||
|
|
||||||
|
# strip type_ prefix of type_gauge and type_counter
|
||||||
|
args[2] = args[2].strip()[5:]
|
||||||
|
types.append(args[2])
|
||||||
|
|
||||||
|
if len(names) > 0:
|
||||||
|
render_section(names, decsription, types)
|
||||||
|
|
||||||
|
out.close()
|
||||||
|
f.close()
|
||||||
|
|
|
@ -55,10 +55,10 @@ all: html
|
||||||
settings.rst: ../include/libtorrent/settings_pack.hpp
|
settings.rst: ../include/libtorrent/settings_pack.hpp
|
||||||
python gen_settings_doc.py
|
python gen_settings_doc.py
|
||||||
|
|
||||||
#stats_counters.rst: ../src/session_stats.cpp
|
stats_counters.rst: ../src/session_stats.cpp
|
||||||
# python gen_stats_doc.py
|
python gen_stats_doc.py
|
||||||
|
|
||||||
manual.rst: settings.rst stats_counters.rst
|
manual.rst: stats_counters.rst
|
||||||
touch manual.rst
|
touch manual.rst
|
||||||
|
|
||||||
troubleshooting_thumb.png: troubleshooting.png
|
troubleshooting_thumb.png: troubleshooting.png
|
||||||
|
@ -70,7 +70,7 @@ troubleshooting.png: troubleshooting.dot
|
||||||
todo.html:gen_todo.py ../src/*.cpp ../include/libtorrent/*.hpp
|
todo.html:gen_todo.py ../src/*.cpp ../include/libtorrent/*.hpp
|
||||||
python gen_todo.py
|
python gen_todo.py
|
||||||
|
|
||||||
$(REFERENCE_TARGETS:=.rst):gen_reference_doc.py ../include/libtorrent/*.hpp ../include/libtorrent/kademlia/*.hpp manual.rst settings.rst
|
$(REFERENCE_TARGETS:=.rst):gen_reference_doc.py ../include/libtorrent/*.hpp ../include/libtorrent/kademlia/*.hpp manual.rst settings.rst session_stats.rst
|
||||||
python gen_reference_doc.py
|
python gen_reference_doc.py
|
||||||
|
|
||||||
%.epub:%.rst
|
%.epub:%.rst
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
// TODO: 3 does this need to be exported?
|
|
||||||
struct TORRENT_EXTRA_EXPORT counters
|
struct TORRENT_EXTRA_EXPORT counters
|
||||||
{
|
{
|
||||||
enum stats_counter_t
|
enum stats_counter_t
|
||||||
|
|
Loading…
Reference in New Issue