summaryrefslogtreecommitdiff
path: root/paste/docsupport
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-06-01 05:53:45 +0000
committerianb <devnull@localhost>2005-06-01 05:53:45 +0000
commite0c48244c2dfeb21732f4aaca320e757e1365cfb (patch)
treebcb6f3910d75f4e949e751f3de9d1cda5969ef4f /paste/docsupport
parent60eca315c23c73bc36182ba460fbcc5c27c227d9 (diff)
downloadpaste-e0c48244c2dfeb21732f4aaca320e757e1365cfb.tar.gz
Added indexing of configuration and WSGI keys
Diffstat (limited to 'paste/docsupport')
-rw-r--r--paste/docsupport/extract.py34
-rw-r--r--paste/docsupport/metadata_real.py2
2 files changed, 36 insertions, 0 deletions
diff --git a/paste/docsupport/extract.py b/paste/docsupport/extract.py
index 24c6a09..bcf06be 100644
--- a/paste/docsupport/extract.py
+++ b/paste/docsupport/extract.py
@@ -8,6 +8,7 @@ import types
import inspect
from cStringIO import StringIO
import textwrap
+import re
import findmodules
from paste.docsupport import metadata
@@ -195,6 +196,7 @@ class DocContext(object):
self.indent_level = 0
self.names = []
self.need_break = False
+ self.indexes = {}
def push_name(self, name):
self.names.append(name)
@@ -269,6 +271,12 @@ class DocContext(object):
assert self.indent_level >= 0, (
"Too many endkeys or dedents (indent %s)" % self.indent_level)
+ def addindex(self, index_type, name, description=None):
+ full_name = '%s.%s' % (index_type, name)
+ self.write('.. _%s:\n\n' % full_name)
+ self.indexes.setdefault(index_type, []).append(
+ (name, description))
+
def write(self, s):
if self.need_break:
self.out.write('\n\n%s\n\n' % ('-'*40))
@@ -304,10 +312,36 @@ class DocContext(object):
else:
print >> sys.stderr, 'No extractor applies to %r\n' % obj
+ def close(self):
+ self.writeindexes()
+
+ def writeindexes(self):
+ index_types = self.indexes.keys()
+ index_types.sort()
+ for index_type in index_types:
+ self.writeindex(index_type, self.indexes[index_type])
+
+ def writeindex(self, index_type, indexes):
+ indexes.sort()
+ self.writeheader('Index: %s' % index_type)
+ for n, (name, description) in enumerate(indexes):
+ self.write('* `%s <#%s>`_\n'
+ % (description or name,
+ self.munge_link(index_type + '.' + name)))
+ self.write('\n')
+ self.endheader()
+
+ def munge_link(self, link):
+ link = link.lower()
+ link = re.sub(r'[ ._-]+', '-', link)
+ link = re.sub(r'[^a-z0-9-]', '', link)
+ return link
+
def build_doc(package):
context = DocContext()
for module in findmodules.find_modules(package):
context.extract(module)
+ context.close()
return context.out.getvalue()
if __name__ == '__main__':
diff --git a/paste/docsupport/metadata_real.py b/paste/docsupport/metadata_real.py
index b636013..e5777e9 100644
--- a/paste/docsupport/metadata_real.py
+++ b/paste/docsupport/metadata_real.py
@@ -64,6 +64,7 @@ class WSGIKey(DocItem):
super(WSGIKey, self).__init__()
def writeto(self, context):
+ context.addindex('wsgikey', self.name)
context.writekey(self.name, type='WSGI Environment Key')
context.writedoc(self.doc)
self.writeobj(self.interface, context)
@@ -84,6 +85,7 @@ class Config(DocItem):
name = context.last_name
if name.startswith('_config_'):
name = name[len('_config_'):]
+ context.addindex('config', name)
name = "``%s``" % name
if self.default is not NoDefault:
name += ' (default: ``%r``)' % self.default