summaryrefslogtreecommitdiff
path: root/scripts/mkindex.py
blob: dc2fd8c0ecc8517e07f9da880e9fb376748fecd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python

from docutils.core import publish_string, publish_parts
from nose.config import Config
from nose.plugins.manager import BuiltinPluginManager
import nose
import nose.commands
import nose.tools
import os
import re
import time

root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

print "Main..."
tpl = open(os.path.join(root, 'index.html.tpl'), 'r').read()

pat = re.compile(r'^.*(Basic usage)', re.DOTALL)
txt = nose.__doc__.replace(':: python','::')
txt = pat.sub(r'\1', txt)
docs = publish_parts(txt, writer_name='html')
docs.update({'version': nose.__version__,
             'date': time.ctime()})

#print "Tools..."
#tools = publish_parts(nose.tools.__doc__, writer_name='html')
#docs['tools'] = tools['body']

print "Commands..."
cmds = publish_parts(nose.commands.__doc__, writer_name='html')
docs['commands'] = cmds['body']

print "Changelog..."
changes = open(os.path.join(root, 'CHANGELOG'), 'r').read()
changes_html = publish_parts(changes, writer_name='html')
docs['changelog'] = changes_html['body']

print "News..."
news = open(os.path.join(root, 'NEWS'), 'r').read()
news_html = publish_parts(news, writer_name='html')
docs['news'] = news_html['body']

print "Usage..."
conf = Config(plugins=BuiltinPluginManager())
usage_txt = conf.help(nose.main.__doc__).replace(
    'mkindex.py', 'nosetests')
docs['usage'] = '<pre>%s</pre>' % usage_txt

out = tpl % docs

index = open(os.path.join(root, 'index.html'), 'w')
index.write(out)
index.close()

readme = open(os.path.join(root, 'README.txt'), 'w')
readme.write(nose.__doc__)
readme.close()