summaryrefslogtreecommitdiff
path: root/scripts/mkindex.py
diff options
context:
space:
mode:
authorJason Pellerin <jpellerin@gmail.com>2007-05-25 01:37:39 +0000
committerJason Pellerin <jpellerin@gmail.com>2007-05-25 01:37:39 +0000
commit17dbccf4e3ffde7230af46c48ea54f6d071f994b (patch)
tree1bba0d36b69807f8e8f849a729bac2c494c48602 /scripts/mkindex.py
parentdc6d12fe7af41113a1134944dd4b894151e8dc73 (diff)
downloadnose-17dbccf4e3ffde7230af46c48ea54f6d071f994b.tar.gz
Started work on doc links and index organization
Diffstat (limited to 'scripts/mkindex.py')
-rwxr-xr-xscripts/mkindex.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/scripts/mkindex.py b/scripts/mkindex.py
index dc2fd8c..c50ba6b 100755
--- a/scripts/mkindex.py
+++ b/scripts/mkindex.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
from docutils.core import publish_string, publish_parts
+from docutils.readers.standalone import Reader
from nose.config import Config
from nose.plugins.manager import BuiltinPluginManager
import nose
@@ -10,6 +11,20 @@ import os
import re
import time
+def doc_word(node):
+ print "Unknown ref %s" % node.astext()
+ node['refuri'] = 'doc/' \
+ + '_'.join(map(lambda s: s.lower(), node.astext().split(' '))) \
+ + '.html'
+ del node['refname']
+ node.resolved = True
+ return True
+doc_word.priority = 100
+
+class DocReader(Reader):
+ unknown_reference_resolvers = (doc_word,)
+
+
root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
print "Main..."
@@ -18,26 +33,33 @@ 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')
+
+# cut from 'about the name' down (goes to end of page)
+pat = re.compile(r'^(.*?)(About the name.*$)', re.DOTALL)
+txt, coda = pat.search(txt).groups()
+
+docs = publish_parts(txt, reader=DocReader(), writer_name='html')
docs.update({'version': nose.__version__,
'date': time.ctime()})
+docs['coda'] = publish_parts(coda, writer_name='html')['body']
#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')
+cmds = publish_parts(nose.commands.__doc__, reader=DocReader(),
+ 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')
+changes_html = publish_parts(changes, reader=DocReader(), 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')
+news_html = publish_parts(news, reader=DocReader(), writer_name='html')
docs['news'] = news_html['body']
print "Usage..."