File: showdoc

package info (click to toggle)
python-docutils 0.7-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,732 kB
  • ctags: 4,443
  • sloc: python: 36,034; lisp: 3,402; sh: 111; makefile: 106
file content (33 lines) | stat: -rwxr-xr-x 940 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/env python

"""
This is a tool for exploring module documentation trees generated by
``docutils.readers.python.moduleparser.parse_module()`` from test data in
docutils/test/test_readers/test_python/test_parser or stdin.

Usage::

    showdoc <key> <index>

    showdoc < <module.py>

Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is
the index of the list ``totest[key]``.  If no arguments are given, stdin is
used for input.
"""

import sys
from docutils.readers.python.moduleparser import parse_module
import test_parser

if len(sys.argv) > 1:
    key, caseno = sys.argv[1:]
    print 'totest["%s"][%s][0]:\n' % (key, caseno)
    input_text = test_parser.totest[key][int(caseno)][0]
    input_source = "test_parser.totest['%s'][%s][0]" % (key, caseno)
else:
    input_text = sys.stdin.read()
    input_source = '<stdin>'
print input_text
module = parse_module(input_text, input_source)
print module,