~ubuntu-branches/ubuntu/saucy/python-docutils/saucy-proposed

« back to all changes in this revision

Viewing changes to docutils/writers/manpage.py

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2012-10-19 18:23:15 UTC
  • mfrom: (1.2.1) (11.1.6 experimental)
  • Revision ID: package-import@ubuntu.com-20121019182315-ln3lvct1pqq7mzgm
Tags: 0.9.1+svn7532-0ubuntu1
* Resynchronize with Debian packaging SVN, remaining change:
  - Use dh_python2 instead of dh_pysupport.
* New snapshot from upstream SVN, fixes build with Python 3.3.
* Add XS-Testsuite header.
* debian/patches/move-data-to-usr-share.diff: unfuzz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
# $Id: manpage.py 7048 2011-06-04 12:35:19Z grubert $
 
2
# $Id$
3
3
# Author: Engelbert Gruber <grubert@users.sourceforge.net>
4
4
# Copyright: This module is put into the public domain.
5
5
 
48
48
 
49
49
import docutils
50
50
from docutils import nodes, writers, languages
51
 
import roman
 
51
try:
 
52
    import roman
 
53
except ImportError:
 
54
    import docutils.utils.roman as roman
52
55
 
53
56
FIELD_LIST_INDENT = 7
54
57
DEFINITION_LIST_INDENT = 7
55
58
OPTION_LIST_INDENT = 7
56
59
BLOCKQOUTE_INDENT = 3.5
 
60
LITERAL_BLOCK_INDENT = 3.5
57
61
 
58
62
# Define two macros so man/roff can calculate the
59
63
# indent/unindent margins by itself
104
108
        self.output = visitor.astext()
105
109
 
106
110
 
107
 
class Table:
 
111
class Table(object):
108
112
    def __init__(self):
109
113
        self._rows = []
110
114
        self._options = ['center']
156
160
 
157
161
    words_and_spaces = re.compile(r'\S+| +|\n')
158
162
    possibly_a_roff_command = re.compile(r'\.\w')
159
 
    document_start = """Man page generated from reStructeredText."""
 
163
    document_start = """Man page generated from reStructuredText."""
160
164
 
161
165
    def __init__(self, document):
162
166
        nodes.NodeVisitor.__init__(self, document)
296
300
        pass
297
301
 
298
302
    def list_start(self, node):
299
 
        class enum_char:
 
303
        class enum_char(object):
300
304
            enum_style = {
301
305
                    'bullet'     : '\\(bu',
302
306
                    'emdash'     : '\\(em',
384
388
        pass
385
389
 
386
390
    def visit_admonition(self, node, name=None):
 
391
        #
 
392
        # Make admonitions a simple block quote
 
393
        # with a strong heading
 
394
        #
 
395
        # Using .IP/.RE doesn't preserve indentation
 
396
        # when admonitions contain bullets, literal,
 
397
        # and/or block quotes.
 
398
        #
387
399
        if name:
388
 
            self.body.append('.IP %s\n' %
389
 
                        self.language.labels.get(name, name))
 
400
            # .. admonition:: has no name
 
401
            self.body.append('.sp\n')
 
402
            name = '%s%s:%s\n' % (
 
403
                self.defs['strong'][0],
 
404
                self.language.labels.get(name, name).upper(),
 
405
                self.defs['strong'][1],
 
406
                )        
 
407
            self.body.append(name)
 
408
        self.visit_block_quote(node)
390
409
 
391
410
    def depart_admonition(self, node):
392
 
        self.body.append('.RE\n')
 
411
        self.depart_block_quote(node)
393
412
 
394
413
    def visit_attention(self, node):
395
414
        self.visit_admonition(node, 'attention')
585
604
            self.body.append('.SH COPYRIGHT\n%s\n'
586
605
                    % self._docinfo['copyright'])
587
606
        self.body.append(self.comment(
588
 
                        'Generated by docutils manpage writer.\n'))
 
607
                        'Generated by docutils manpage writer.'))
589
608
 
590
609
    def visit_emphasis(self, node):
591
610
        self.body.append(self.defs['emphasis'][0])
796
815
        self.body.append(self.defs['literal'][1])
797
816
 
798
817
    def visit_literal_block(self, node):
 
818
        # BUG/HACK: indent alway uses the _last_ indention,
 
819
        # thus we need two of them.
 
820
        self.indent(LITERAL_BLOCK_INDENT)
 
821
        self.indent(0)        
799
822
        self.body.append(self.defs['literal_block'][0])
800
823
        self._in_literal = True
801
824
 
802
825
    def depart_literal_block(self, node):
803
826
        self._in_literal = False
804
827
        self.body.append(self.defs['literal_block'][1])
 
828
        self.dedent()
 
829
        self.dedent()
805
830
 
806
831
    def visit_math(self, node):
807
832
        self.document.reporter.warning('"math" role not supported',