doc/rst2man.py
author Patrick Mezard <pmezard@gmail.com>
Sun, 13 Dec 2009 18:06:24 +0100
changeset 10061 9e2ab10728a2
parent 10007 9945a39d171f
child 10282 08a0f04b56bd
permissions -rwxr-xr-x
Make {file_copies} usable as a --template key Before this, to display file copies in templates, you had to write something like {file_copies%filecopy}. For some reason, the {file_copy} subtemplate was used by default but not defined by default in changeset_templater, while styles were already using it. Here we define {file_copy} in changeset_templater, and change the templater to handle formatting strings like {file_copies%filecopy} with already expanded keys (in this case {file_copies}), for backward compatibility.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     1
#!/usr/bin/env python
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     3
# $Id: manpage.py 6110 2009-08-31 14:40:33Z grubert $
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     4
# Author: Engelbert Gruber <grubert@users.sourceforge.net>
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     5
# Copyright: This module is put into the public domain.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     6
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     7
"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     8
Simple man page writer for reStructuredText.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     9
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    10
Man pages (short for "manual pages") contain system documentation on unix-like
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
    11
systems. The pages are grouped in numbered sections:
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    12
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    13
 1 executable programs and shell commands
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    14
 2 system calls
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    15
 3 library functions
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    16
 4 special files
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    17
 5 file formats
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    18
 6 games
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    19
 7 miscellaneous
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    20
 8 system administration
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    21
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    22
Man pages are written *troff*, a text file formatting system.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    23
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    24
See http://www.tldp.org/HOWTO/Man-Page for a start.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    25
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    26
Man pages have no subsection only parts.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    27
Standard parts
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    28
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    29
  NAME ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    30
  SYNOPSIS ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    31
  DESCRIPTION ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    32
  OPTIONS ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    33
  FILES ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    34
  SEE ALSO ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    35
  BUGS ,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    36
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    37
and
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    38
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    39
  AUTHOR .
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    40
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    41
A unix-like system keeps an index of the DESCRIPTIONs, which is accesable
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    42
by the command whatis or apropos.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    43
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    44
"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    45
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    46
__docformat__ = 'reStructuredText'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    47
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    48
import sys
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    49
import os
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    50
import time
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    51
import re
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    52
from types import ListType
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    53
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    54
import docutils
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    55
from docutils import nodes, utils, writers, languages
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    56
import roman
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    57
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    58
FIELD_LIST_INDENT = 7
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    59
DEFINITION_LIST_INDENT = 7
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    60
OPTION_LIST_INDENT = 7
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    61
BLOCKQOUTE_INDENT = 3.5
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    62
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    63
# Define two macros so man/roff can calculate the
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    64
# indent/unindent margins by itself
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    65
MACRO_DEF = (r""".
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    66
.nr rst2man-indent-level 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    67
.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    68
.de1 rstReportMargin
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    69
\\$1 \\n[an-margin]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    70
level \\n[rst2man-indent-level]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    71
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    72
-
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    73
\\n[rst2man-indent0]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    74
\\n[rst2man-indent1]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    75
\\n[rst2man-indent2]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    76
..
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    77
.de1 INDENT
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    78
.\" .rstReportMargin pre:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    79
. RS \\$1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    80
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    81
. nr rst2man-indent-level +1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    82
.\" .rstReportMargin post:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    83
..
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    84
.de UNINDENT
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    85
. RE
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    86
.\" indent \\n[an-margin]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    87
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    88
.nr rst2man-indent-level -1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    89
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    90
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    91
..
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    92
""")
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    93
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    94
class Writer(writers.Writer):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    95
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    96
    supported = ('manpage')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    97
    """Formats this writer supports."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    98
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    99
    output = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   100
    """Final translated form of `document`."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   101
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   102
    def __init__(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   103
        writers.Writer.__init__(self)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   104
        self.translator_class = Translator
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   105
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   106
    def translate(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   107
        visitor = self.translator_class(self.document)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   108
        self.document.walkabout(visitor)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   109
        self.output = visitor.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   110
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   111
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   112
class Table:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   113
    def __init__(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   114
        self._rows = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   115
        self._options = ['center', ]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   116
        self._tab_char = '\t'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   117
        self._coldefs = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   118
    def new_row(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   119
        self._rows.append([])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   120
    def append_separator(self, separator):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   121
        """Append the separator for table head."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   122
        self._rows.append([separator])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   123
    def append_cell(self, cell_lines):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   124
        """cell_lines is an array of lines"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   125
        start = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   126
        if len(cell_lines)>0 and cell_lines[0] == '.sp\n':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   127
            start = 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   128
        self._rows[-1].append(cell_lines[start:])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   129
        if len(self._coldefs) < len(self._rows[-1]):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   130
            self._coldefs.append('l')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   131
    def _minimize_cell(self, cell_lines):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   132
        """Remove leading and trailing blank and ``.sp`` lines"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   133
        while (cell_lines and cell_lines[0] in ('\n', '.sp\n')):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   134
            del cell_lines[0]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   135
        while (cell_lines and cell_lines[-1] in ('\n', '.sp\n')):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   136
            del cell_lines[-1]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   137
    def as_list(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   138
        text = ['.TS\n']
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   139
        text.append(' '.join(self._options) + ';\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   140
        text.append('|%s|.\n' % ('|'.join(self._coldefs)))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   141
        for row in self._rows:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   142
            # row = array of cells. cell = array of lines.
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   143
            text.append('_\n')       # line above
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   144
            text.append('T{\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   145
            for i in range(len(row)):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   146
                cell = row[i]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   147
                self._minimize_cell(cell)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   148
                text.extend(cell)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   149
                if not text[-1].endswith('\n'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   150
                    text[-1] += '\n'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   151
                if i < len(row)-1:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   152
                    text.append('T}'+self._tab_char+'T{\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   153
                else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   154
                    text.append('T}\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   155
        text.append('_\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   156
        text.append('.TE\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   157
        return text
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   158
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   159
class Translator(nodes.NodeVisitor):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   160
    """"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   161
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   162
    words_and_spaces = re.compile(r'\S+| +|\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   163
    document_start = """Man page generated from reStructeredText."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   164
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   165
    def __init__(self, document):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   166
        nodes.NodeVisitor.__init__(self, document)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   167
        self.settings = settings = document.settings
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   168
        lcode = settings.language_code
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   169
        self.language = languages.get_language(lcode)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   170
        self.head = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   171
        self.body = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   172
        self.foot = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   173
        self.section_level = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   174
        self.context = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   175
        self.topic_class = ''
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   176
        self.colspecs = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   177
        self.compact_p = 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   178
        self.compact_simple = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   179
        # the list style "*" bullet or "#" numbered
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   180
        self._list_char = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   181
        # writing the header .TH and .SH NAME is postboned after
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   182
        # docinfo.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   183
        self._docinfo = {
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   184
                "title" : "", "title_upper": "",
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   185
                "subtitle" : "",
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   186
                "manual_section" : "", "manual_group" : "",
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   187
                "author" : [],
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   188
                "date" : "",
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   189
                "copyright" : "",
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   190
                "version" : "",
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   191
                    }
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   192
        self._docinfo_keys = []     # a list to keep the sequence as in source.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   193
        self._docinfo_names = {}    # to get name from text not normalized.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   194
        self._in_docinfo = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   195
        self._active_table = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   196
        self._in_literal = False
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   197
        self.header_written = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   198
        self._line_block = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   199
        self.authors = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   200
        self.section_level = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   201
        self._indent = [0]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   202
        # central definition of simple processing rules
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   203
        # what to output on : visit, depart
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   204
        # Do not use paragraph requests ``.PP`` because these set indentation.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   205
        # use ``.sp``. Remove superfluous ``.sp`` in ``astext``.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   206
        #
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   207
        # Fonts are put on a stack, the top one is used.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   208
        # ``.ft P`` or ``\\fP`` pop from stack.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   209
        # ``B`` bold, ``I`` italic, ``R`` roman should be available.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   210
        # Hopefully ``C`` courier too.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   211
        self.defs = {
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   212
                'indent' : ('.INDENT %.1f\n', '.UNINDENT\n'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   213
                'definition_list_item' : ('.TP', ''),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   214
                'field_name' : ('.TP\n.B ', '\n'),
9628
816564f5dea9 rst2man: highlight inline literals in bold
Martin Geisler <mg@lazybytes.net>
parents: 9627
diff changeset
   215
                'literal' : ('\\fB', '\\fP'),
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   216
                'literal_block' : ('.sp\n.nf\n.ft C\n', '\n.ft P\n.fi\n'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   217
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   218
                'option_list_item' : ('.TP\n', ''),
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   219
9627
4515761ea531 rst2man: avoid italic for references
Martin Geisler <mg@lazybytes.net>
parents: 9418
diff changeset
   220
                'reference' : (r'\%', r'\:'),
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   221
                'emphasis': ('\\fI', '\\fP'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   222
                'strong' : ('\\fB', '\\fP'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   223
                'term' : ('\n.B ', '\n'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   224
                'title_reference' : ('\\fI', '\\fP'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   225
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   226
                'topic-title' : ('.SS ', ),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   227
                'sidebar-title' : ('.SS ', ),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   228
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   229
                'problematic' : ('\n.nf\n', '\n.fi\n'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   230
                    }
10007
9945a39d171f rst2man: s/dont/don't/ in comment
Christian Ebert <blacktrash@gmx.net>
parents: 10006
diff changeset
   231
        # NOTE don't specify the newline before a dot-command, but ensure
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   232
        # it is there.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   233
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   234
    def comment_begin(self, text):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   235
        """Return commented version of the passed text WITHOUT end of
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   236
        line/comment."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   237
        prefix = '.\\" '
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   238
        out_text = ''.join(
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   239
            [(prefix + in_line + '\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   240
            for in_line in text.split('\n')])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   241
        return out_text
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   242
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   243
    def comment(self, text):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   244
        """Return commented version of the passed text."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   245
        return self.comment_begin(text)+'.\n'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   246
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   247
    def ensure_eol(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   248
        """Ensure the last line in body is terminated by new line."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   249
        if self.body[-1][-1] != '\n':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   250
            self.body.append('\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   251
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   252
    def astext(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   253
        """Return the final formatted document as a string."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   254
        if not self.header_written:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   255
            # ensure we get a ".TH" as viewers require it.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   256
            self.head.append(self.header())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   257
        # filter body
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   258
        for i in xrange(len(self.body)-1,0,-1):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   259
            # remove superfluous vertical gaps.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   260
            if self.body[i] == '.sp\n':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   261
                if self.body[i-1][:4] in ('.BI ','.IP '):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   262
                    self.body[i] = '.\n'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   263
                elif (self.body[i-1][:3] == '.B ' and
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   264
                    self.body[i-2][:4] == '.TP\n'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   265
                    self.body[i] = '.\n'
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   266
                elif (self.body[i-1] == '\n' and
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   267
                    self.body[i-2][0] != '.' and
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   268
                    (self.body[i-3][:7] == '.TP\n.B '
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   269
                        or self.body[i-3][:4] == '\n.B ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   270
                     ):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   271
                    self.body[i] = '.\n'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   272
        return ''.join(self.head + self.body + self.foot)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   273
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   274
    def deunicode(self, text):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   275
        text = text.replace(u'\xa0', '\\ ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   276
        text = text.replace(u'\u2020', '\\(dg')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   277
        return text
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   278
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   279
    def visit_Text(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   280
        text = node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   281
        text = text.replace('\\','\\e')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   282
        replace_pairs = [
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   283
            (u'-', ur'\-'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   284
            (u'\'', ur'\(aq'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   285
            (u'´', ur'\''),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   286
            (u'`', ur'\(ga'),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   287
            ]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   288
        for (in_char, out_markup) in replace_pairs:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   289
            text = text.replace(in_char, out_markup)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   290
        # unicode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   291
        text = self.deunicode(text)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   292
        if self._in_literal:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   293
            # prevent interpretation of "." at line start
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   294
            if text[0] == '.':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   295
                text = '\\&' + text
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   296
            text = text.replace('\n.', '\n\\&.')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   297
        self.body.append(text)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   298
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   299
    def depart_Text(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   300
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   301
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   302
    def list_start(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   303
        class enum_char:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   304
            enum_style = {
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   305
                    'bullet'     : '\\(bu',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   306
                    'emdash'     : '\\(em',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   307
                     }
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   308
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   309
            def __init__(self, style):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   310
                self._style = style
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   311
                if node.has_key('start'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   312
                    self._cnt = node['start'] - 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   313
                else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   314
                    self._cnt = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   315
                self._indent = 2
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   316
                if style == 'arabic':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   317
                    # indentation depends on number of childrens
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   318
                    # and start value.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   319
                    self._indent = len(str(len(node.children)))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   320
                    self._indent += len(str(self._cnt)) + 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   321
                elif style == 'loweralpha':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   322
                    self._cnt += ord('a') - 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   323
                    self._indent = 3
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   324
                elif style == 'upperalpha':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   325
                    self._cnt += ord('A') - 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   326
                    self._indent = 3
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   327
                elif style.endswith('roman'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   328
                    self._indent = 5
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   329
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   330
            def next(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   331
                if self._style == 'bullet':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   332
                    return self.enum_style[self._style]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   333
                elif self._style == 'emdash':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   334
                    return self.enum_style[self._style]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   335
                self._cnt += 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   336
                # TODO add prefix postfix
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   337
                if self._style == 'arabic':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   338
                    return "%d." % self._cnt
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   339
                elif self._style in ('loweralpha', 'upperalpha'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   340
                    return "%c." % self._cnt
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   341
                elif self._style.endswith('roman'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   342
                    res = roman.toRoman(self._cnt) + '.'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   343
                    if self._style.startswith('upper'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   344
                        return res.upper()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   345
                    return res.lower()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   346
                else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   347
                    return "%d." % self._cnt
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   348
            def get_width(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   349
                return self._indent
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   350
            def __repr__(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   351
                return 'enum_style-%s' % list(self._style)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   352
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   353
        if node.has_key('enumtype'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   354
            self._list_char.append(enum_char(node['enumtype']))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   355
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   356
            self._list_char.append(enum_char('bullet'))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   357
        if len(self._list_char) > 1:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   358
            # indent nested lists
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   359
            self.indent(self._list_char[-2].get_width())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   360
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   361
            self.indent(self._list_char[-1].get_width())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   362
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   363
    def list_end(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   364
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   365
        self._list_char.pop()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   366
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   367
    def header(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   368
        tmpl = (".TH %(title_upper)s %(manual_section)s"
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   369
                " \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n"
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   370
                ".SH NAME\n"
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   371
                "%(title)s \- %(subtitle)s\n")
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   372
        return tmpl % self._docinfo
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   373
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   374
    def append_header(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   375
        """append header with .TH and .SH NAME"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   376
        # NOTE before everything
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   377
        # .TH title_upper section date source manual
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   378
        if self.header_written:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   379
            return
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   380
        self.body.append(self.header())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   381
        self.body.append(MACRO_DEF)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   382
        self.header_written = 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   383
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   384
    def visit_address(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   385
        self.visit_docinfo_item(node, 'address')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   386
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   387
    def depart_address(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   388
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   389
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   390
    def visit_admonition(self, node, name=None):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   391
        if name:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   392
            self.body.append('.IP %s\n' %
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   393
                        self.language.labels.get(name, name))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   394
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   395
    def depart_admonition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   396
        self.body.append('.RE\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   397
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   398
    def visit_attention(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   399
        self.visit_admonition(node, 'attention')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   400
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   401
    depart_attention = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   402
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   403
    def visit_docinfo_item(self, node, name):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   404
        if name == 'author':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   405
            self._docinfo[name].append(node.astext())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   406
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   407
            self._docinfo[name] = node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   408
        self._docinfo_keys.append(name)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   409
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   410
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   411
    def depart_docinfo_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   412
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   413
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   414
    def visit_author(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   415
        self.visit_docinfo_item(node, 'author')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   416
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   417
    depart_author = depart_docinfo_item
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   419
    def visit_authors(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   420
        # _author is called anyway.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   421
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   422
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   423
    def depart_authors(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   424
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   425
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   426
    def visit_block_quote(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   427
        # BUG/HACK: indent alway uses the _last_ indention,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   428
        # thus we need two of them.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   429
        self.indent(BLOCKQOUTE_INDENT)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   430
        self.indent(0)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   431
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   432
    def depart_block_quote(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   433
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   434
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   435
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   436
    def visit_bullet_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   437
        self.list_start(node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   438
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   439
    def depart_bullet_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   440
        self.list_end()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   441
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   442
    def visit_caption(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   443
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   444
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   445
    def depart_caption(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   446
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   447
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   448
    def visit_caution(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   449
        self.visit_admonition(node, 'caution')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   450
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   451
    depart_caution = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   452
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   453
    def visit_citation(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   454
        num,text = node.astext().split(None,1)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   455
        num = num.strip()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   456
        self.body.append('.IP [%s] 5\n' % num)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   457
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   458
    def depart_citation(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   459
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   460
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   461
    def visit_citation_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   462
        self.body.append('['+node.astext()+']')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   463
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   464
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   465
    def visit_classifier(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   466
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   467
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   468
    def depart_classifier(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   469
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   470
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   471
    def visit_colspec(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   472
        self.colspecs.append(node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   473
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   474
    def depart_colspec(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   475
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   476
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   477
    def write_colspecs(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   478
        self.body.append("%s.\n" % ('L '*len(self.colspecs)))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   479
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   480
    def visit_comment(self, node,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   481
                      sub=re.compile('-(?=-)').sub):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   482
        self.body.append(self.comment(node.astext()))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   483
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   484
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   485
    def visit_contact(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   486
        self.visit_docinfo_item(node, 'contact')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   487
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   488
    depart_contact = depart_docinfo_item
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   489
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   490
    def visit_container(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   491
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   492
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   493
    def depart_container(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   494
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   495
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   496
    def visit_compound(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   497
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   498
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   499
    def depart_compound(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   500
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   501
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   502
    def visit_copyright(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   503
        self.visit_docinfo_item(node, 'copyright')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   504
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   505
    def visit_danger(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   506
        self.visit_admonition(node, 'danger')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   507
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   508
    depart_danger = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   509
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   510
    def visit_date(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   511
        self.visit_docinfo_item(node, 'date')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   512
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   513
    def visit_decoration(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   514
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   515
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   516
    def depart_decoration(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   517
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   518
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   519
    def visit_definition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   520
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   521
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   522
    def depart_definition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   523
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   524
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   525
    def visit_definition_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   526
        self.indent(DEFINITION_LIST_INDENT)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   527
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   528
    def depart_definition_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   529
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   530
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   531
    def visit_definition_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   532
        self.body.append(self.defs['definition_list_item'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   533
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   534
    def depart_definition_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   535
        self.body.append(self.defs['definition_list_item'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   536
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   537
    def visit_description(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   538
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   539
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   540
    def depart_description(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   541
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   542
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   543
    def visit_docinfo(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   544
        self._in_docinfo = 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   545
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   546
    def depart_docinfo(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   547
        self._in_docinfo = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   548
        # NOTE nothing should be written before this
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   549
        self.append_header()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   550
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   551
    def visit_doctest_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   552
        self.body.append(self.defs['literal_block'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   553
        self._in_literal = True
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   554
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   555
    def depart_doctest_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   556
        self._in_literal = False
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   557
        self.body.append(self.defs['literal_block'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   558
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   559
    def visit_document(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   560
        # no blank line between comment and header.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   561
        self.body.append(self.comment(self.document_start).rstrip()+'\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   562
        # writing header is postboned
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   563
        self.header_written = 0
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   564
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   565
    def depart_document(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   566
        if self._docinfo['author']:
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   567
            self.body.append('.SH AUTHOR\n%s\n'
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   568
                    % ', '.join(self._docinfo['author']))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   569
        skip = ('author', 'copyright', 'date',
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   570
                'manual_group', 'manual_section',
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   571
                'subtitle',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   572
                'title', 'title_upper', 'version')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   573
        for name in self._docinfo_keys:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   574
            if name == 'address':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   575
                self.body.append("\n%s:\n%s%s.nf\n%s\n.fi\n%s%s" % (
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   576
                                    self.language.labels.get(name, name),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   577
                                    self.defs['indent'][0] % 0,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   578
                                    self.defs['indent'][0] % BLOCKQOUTE_INDENT,
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   579
                                    self._docinfo[name],
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   580
                                    self.defs['indent'][1],
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   581
                                    self.defs['indent'][1],
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   582
                                    ) )
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   583
            elif not name in skip:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   584
                if name in self._docinfo_names:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   585
                    label = self._docinfo_names[name]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   586
                else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   587
                    label = self.language.labels.get(name, name)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   588
                self.body.append("\n%s: %s\n" % (label, self._docinfo[name]) )
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   589
        if self._docinfo['copyright']:
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   590
            self.body.append('.SH COPYRIGHT\n%s\n'
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   591
                    % self._docinfo['copyright'])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   592
        self.body.append( self.comment(
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   593
                        'Generated by docutils manpage writer.\n' ) )
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   594
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   595
    def visit_emphasis(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   596
        self.body.append(self.defs['emphasis'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   597
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   598
    def depart_emphasis(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   599
        self.body.append(self.defs['emphasis'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   600
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   601
    def visit_entry(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   602
        # a cell in a table row
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   603
        if 'morerows' in node:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   604
            self.document.reporter.warning('"table row spanning" not supported',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   605
                    base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   606
        if 'morecols' in node:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   607
            self.document.reporter.warning(
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   608
                    '"table cell spanning" not supported', base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   609
        self.context.append(len(self.body))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   610
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   611
    def depart_entry(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   612
        start = self.context.pop()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   613
        self._active_table.append_cell(self.body[start:])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   614
        del self.body[start:]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   615
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   616
    def visit_enumerated_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   617
        self.list_start(node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   618
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   619
    def depart_enumerated_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   620
        self.list_end()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   621
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   622
    def visit_error(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   623
        self.visit_admonition(node, 'error')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   624
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   625
    depart_error = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   626
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   627
    def visit_field(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   628
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   629
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   630
    def depart_field(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   631
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   632
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   633
    def visit_field_body(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   634
        if self._in_docinfo:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   635
            name_normalized = self._field_name.lower().replace(" ","_")
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   636
            self._docinfo_names[name_normalized] = self._field_name
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   637
            self.visit_docinfo_item(node, name_normalized)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   638
            raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   639
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   640
    def depart_field_body(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   641
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   642
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   643
    def visit_field_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   644
        self.indent(FIELD_LIST_INDENT)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   645
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   646
    def depart_field_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   647
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   648
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   649
    def visit_field_name(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   650
        if self._in_docinfo:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   651
            self._field_name = node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   652
            raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   653
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   654
            self.body.append(self.defs['field_name'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   655
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   656
    def depart_field_name(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   657
        self.body.append(self.defs['field_name'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   658
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   659
    def visit_figure(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   660
        self.indent(2.5)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   661
        self.indent(0)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   662
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   663
    def depart_figure(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   664
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   665
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   666
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   667
    def visit_footer(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   668
        self.document.reporter.warning('"footer" not supported',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   669
                base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   670
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   671
    def depart_footer(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   672
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   673
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   674
    def visit_footnote(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   675
        num,text = node.astext().split(None,1)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   676
        num = num.strip()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   677
        self.body.append('.IP [%s] 5\n' % self.deunicode(num))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   678
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   679
    def depart_footnote(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   680
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   681
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   682
    def footnote_backrefs(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   683
        self.document.reporter.warning('"footnote_backrefs" not supported',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   684
                base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   685
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   686
    def visit_footnote_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   687
        self.body.append('['+self.deunicode(node.astext())+']')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   688
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   689
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   690
    def depart_footnote_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   691
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   692
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   693
    def visit_generated(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   694
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   695
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   696
    def depart_generated(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   697
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   698
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   699
    def visit_header(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   700
        raise NotImplementedError, node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   701
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   702
    def depart_header(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   703
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   704
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   705
    def visit_hint(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   706
        self.visit_admonition(node, 'hint')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   707
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   708
    depart_hint = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   709
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   710
    def visit_subscript(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   711
        self.body.append('\\s-2\\d')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   712
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   713
    def depart_subscript(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   714
        self.body.append('\\u\\s0')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   715
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   716
    def visit_superscript(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   717
        self.body.append('\\s-2\\u')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   718
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   719
    def depart_superscript(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   720
        self.body.append('\\d\\s0')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   721
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   722
    def visit_attribution(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   723
        self.body.append('\\(em ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   724
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   725
    def depart_attribution(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   726
        self.body.append('\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   727
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   728
    def visit_image(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   729
        self.document.reporter.warning('"image" not supported',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   730
                base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   731
        text = []
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   732
        if 'alt' in node.attributes:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   733
            text.append(node.attributes['alt'])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   734
        if 'uri' in node.attributes:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   735
            text.append(node.attributes['uri'])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   736
        self.body.append('[image: %s]\n' % ('/'.join(text)))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   737
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   738
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   739
    def visit_important(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   740
        self.visit_admonition(node, 'important')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   741
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   742
    depart_important = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   743
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   744
    def visit_label(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   745
        # footnote and citation
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   746
        if (isinstance(node.parent, nodes.footnote)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   747
            or isinstance(node.parent, nodes.citation)):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   748
            raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   749
        self.document.reporter.warning('"unsupported "label"',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   750
                base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   751
        self.body.append('[')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   752
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   753
    def depart_label(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   754
        self.body.append(']\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   755
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   756
    def visit_legend(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   757
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   758
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   759
    def depart_legend(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   760
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   761
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   762
    # WHAT should we use .INDENT, .UNINDENT ?
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   763
    def visit_line_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   764
        self._line_block += 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   765
        if self._line_block == 1:
10006
9c142ed9c405 rst2man: separate inline blocks from previous paragraphs
Christian Ebert <blacktrash@gmx.net>
parents: 9793
diff changeset
   766
            self.body.append('.sp\n')
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   767
            self.body.append('.nf\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   768
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   769
            self.body.append('.in +2\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   770
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   771
    def depart_line_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   772
        self._line_block -= 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   773
        if self._line_block == 0:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   774
            self.body.append('.fi\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   775
            self.body.append('.sp\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   776
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   777
            self.body.append('.in -2\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   778
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   779
    def visit_line(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   780
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   781
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   782
    def depart_line(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   783
        self.body.append('\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   784
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   785
    def visit_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   786
        # man 7 man argues to use ".IP" instead of ".TP"
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   787
        self.body.append('.IP %s %d\n' % (
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   788
                self._list_char[-1].next(),
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   789
                self._list_char[-1].get_width(),) )
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   790
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   791
    def depart_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   792
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   793
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   794
    def visit_literal(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   795
        self.body.append(self.defs['literal'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   796
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   797
    def depart_literal(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   798
        self.body.append(self.defs['literal'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   799
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   800
    def visit_literal_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   801
        self.body.append(self.defs['literal_block'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   802
        self._in_literal = True
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   803
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   804
    def depart_literal_block(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   805
        self._in_literal = False
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   806
        self.body.append(self.defs['literal_block'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   807
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   808
    def visit_meta(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   809
        raise NotImplementedError, node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   810
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   811
    def depart_meta(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   812
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   813
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   814
    def visit_note(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   815
        self.visit_admonition(node, 'note')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   816
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   817
    depart_note = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   818
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   819
    def indent(self, by=0.5):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   820
        # if we are in a section ".SH" there already is a .RS
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   821
        step = self._indent[-1]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   822
        self._indent.append(by)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   823
        self.body.append(self.defs['indent'][0] % step)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   824
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   825
    def dedent(self):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   826
        self._indent.pop()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   827
        self.body.append(self.defs['indent'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   828
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   829
    def visit_option_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   830
        self.indent(OPTION_LIST_INDENT)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   831
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   832
    def depart_option_list(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   833
        self.dedent()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   834
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   835
    def visit_option_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   836
        # one item of the list
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   837
        self.body.append(self.defs['option_list_item'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   838
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   839
    def depart_option_list_item(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   840
        self.body.append(self.defs['option_list_item'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   841
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   842
    def visit_option_group(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   843
        # as one option could have several forms it is a group
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   844
        # options without parameter bold only, .B, -v
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   845
        # options with parameter bold italic, .BI, -f file
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   846
        #
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   847
        # we do not know if .B or .BI
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   848
        self.context.append('.B')           # blind guess
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   849
        self.context.append(len(self.body)) # to be able to insert later
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   850
        self.context.append(0)              # option counter
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   851
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   852
    def depart_option_group(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   853
        self.context.pop()  # the counter
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   854
        start_position = self.context.pop()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   855
        text = self.body[start_position:]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   856
        del self.body[start_position:]
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   857
        self.body.append('%s%s\n' % (self.context.pop(), ''.join(text)))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   858
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   859
    def visit_option(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   860
        # each form of the option will be presented separately
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   861
        if self.context[-1]>0:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   862
            self.body.append(', ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   863
        if self.context[-3] == '.BI':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   864
            self.body.append('\\')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   865
        self.body.append(' ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   866
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   867
    def depart_option(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   868
        self.context[-1] += 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   869
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   870
    def visit_option_string(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   871
        # do not know if .B or .BI
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   872
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   873
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   874
    def depart_option_string(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   875
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   876
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   877
    def visit_option_argument(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   878
        self.context[-3] = '.BI' # bold/italic alternate
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   879
        if node['delimiter'] != ' ':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   880
            self.body.append('\\fB%s ' % node['delimiter'] )
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   881
        elif self.body[len(self.body)-1].endswith('='):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   882
            # a blank only means no blank in output, just changing font
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   883
            self.body.append(' ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   884
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   885
            # blank backslash blank, switch font then a blank
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   886
            self.body.append(' \\ ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   887
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   888
    def depart_option_argument(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   889
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   890
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   891
    def visit_organization(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   892
        self.visit_docinfo_item(node, 'organization')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   893
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   894
    def depart_organization(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   895
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   896
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   897
    def visit_paragraph(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   898
        # ``.PP`` : Start standard indented paragraph.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   899
        # ``.LP`` : Start block paragraph, all except the first.
9712
18b134ef294c kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9628
diff changeset
   900
        # ``.P [type]``  : Start paragraph type.
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   901
        # NOTE dont use paragraph starts because they reset indentation.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   902
        # ``.sp`` is only vertical space
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   903
        self.ensure_eol()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   904
        self.body.append('.sp\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   905
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   906
    def depart_paragraph(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   907
        self.body.append('\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   908
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   909
    def visit_problematic(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   910
        self.body.append(self.defs['problematic'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   911
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   912
    def depart_problematic(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   913
        self.body.append(self.defs['problematic'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   914
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   915
    def visit_raw(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   916
        if node.get('format') == 'manpage':
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   917
            self.body.append(node.astext() + "\n")
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   918
        # Keep non-manpage raw text out of output:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   919
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   920
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   921
    def visit_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   922
        """E.g. link or email address."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   923
        self.body.append(self.defs['reference'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   924
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   925
    def depart_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   926
        self.body.append(self.defs['reference'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   927
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   928
    def visit_revision(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   929
        self.visit_docinfo_item(node, 'revision')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   930
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   931
    depart_revision = depart_docinfo_item
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   932
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   933
    def visit_row(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   934
        self._active_table.new_row()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   935
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   936
    def depart_row(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   937
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   938
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   939
    def visit_section(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   940
        self.section_level += 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   941
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   942
    def depart_section(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   943
        self.section_level -= 1
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   944
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   945
    def visit_status(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   946
        self.visit_docinfo_item(node, 'status')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   947
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   948
    depart_status = depart_docinfo_item
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   949
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   950
    def visit_strong(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   951
        self.body.append(self.defs['strong'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   952
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   953
    def depart_strong(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   954
        self.body.append(self.defs['strong'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   955
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   956
    def visit_substitution_definition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   957
        """Internal only."""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   958
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   959
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   960
    def visit_substitution_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   961
        self.document.reporter.warning('"substitution_reference" not supported',
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   962
                base_node=node)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   963
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   964
    def visit_subtitle(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   965
        if isinstance(node.parent, nodes.sidebar):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   966
            self.body.append(self.defs['strong'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   967
        elif isinstance(node.parent, nodes.document):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   968
            self.visit_docinfo_item(node, 'subtitle')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   969
        elif isinstance(node.parent, nodes.section):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   970
            self.body.append(self.defs['strong'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   971
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   972
    def depart_subtitle(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   973
        # document subtitle calls SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   974
        self.body.append(self.defs['strong'][1]+'\n.PP\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   975
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   976
    def visit_system_message(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   977
        # TODO add report_level
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   978
        #if node['level'] < self.document.reporter['writer'].report_level:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   979
        #    Level is too low to display:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   980
        #    raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   981
        attr = {}
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   982
        backref_text = ''
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   983
        if node.hasattr('id'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   984
            attr['name'] = node['id']
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   985
        if node.hasattr('line'):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   986
            line = ', line %s' % node['line']
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   987
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   988
            line = ''
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   989
        self.body.append('.IP "System Message: %s/%s (%s:%s)"\n'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   990
                         % (node['type'], node['level'], node['source'], line))
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   991
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   992
    def depart_system_message(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   993
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   994
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   995
    def visit_table(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   996
        self._active_table = Table()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   997
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   998
    def depart_table(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   999
        self.ensure_eol()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1000
        self.body.extend(self._active_table.as_list())
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1001
        self._active_table = None
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1002
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1003
    def visit_target(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1004
        # targets are in-document hyper targets, without any use for man-pages.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1005
        raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1006
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1007
    def visit_tbody(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1008
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1009
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1010
    def depart_tbody(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1011
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1012
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1013
    def visit_term(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1014
        self.body.append(self.defs['term'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1015
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1016
    def depart_term(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1017
        self.body.append(self.defs['term'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1018
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1019
    def visit_tgroup(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1020
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1021
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1022
    def depart_tgroup(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1023
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1024
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1025
    def visit_thead(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1026
        # MAYBE double line '='
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1027
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1028
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1029
    def depart_thead(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1030
        # MAYBE double line '='
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1031
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1032
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1033
    def visit_tip(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1034
        self.visit_admonition(node, 'tip')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1035
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1036
    depart_tip = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1037
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1038
    def visit_title(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1039
        if isinstance(node.parent, nodes.topic):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1040
            self.body.append(self.defs['topic-title'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1041
        elif isinstance(node.parent, nodes.sidebar):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1042
            self.body.append(self.defs['sidebar-title'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1043
        elif isinstance(node.parent, nodes.admonition):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1044
            self.body.append('.IP "')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1045
        elif self.section_level == 0:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1046
            self._docinfo['title'] = node.astext()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1047
            # document title for .TH
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1048
            self._docinfo['title_upper'] = node.astext().upper()
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1049
            raise nodes.SkipNode
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1050
        elif self.section_level == 1:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1051
            self.body.append('.SH ')
9793
d2006e6d1d59 rst2man: more robust uppercasing of section titles
Martin Geisler <mg@lazybytes.net>
parents: 9791
diff changeset
  1052
            for n in node.traverse(nodes.Text):
d2006e6d1d59 rst2man: more robust uppercasing of section titles
Martin Geisler <mg@lazybytes.net>
parents: 9791
diff changeset
  1053
                n.parent.replace(n, nodes.Text(n.astext().upper()))
9418
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1054
        else:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1055
            self.body.append('.SS ')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1056
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1057
    def depart_title(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1058
        if isinstance(node.parent, nodes.admonition):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1059
            self.body.append('"')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1060
        self.body.append('\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1061
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1062
    def visit_title_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1063
        """inline citation reference"""
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1064
        self.body.append(self.defs['title_reference'][0])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1065
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1066
    def depart_title_reference(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1067
        self.body.append(self.defs['title_reference'][1])
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1068
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1069
    def visit_topic(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1070
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1071
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1072
    def depart_topic(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1073
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1074
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1075
    def visit_sidebar(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1076
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1077
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1078
    def depart_sidebar(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1079
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1080
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1081
    def visit_rubric(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1082
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1083
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1084
    def depart_rubric(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1085
        pass
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1086
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1087
    def visit_transition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1088
        # .PP      Begin a new paragraph and reset prevailing indent.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1089
        # .sp N    leaves N lines of blank space.
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1090
        # .ce      centers the next line
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1091
        self.body.append('\n.sp\n.ce\n----\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1092
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1093
    def depart_transition(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1094
        self.body.append('\n.ce 0\n.sp\n')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1095
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1096
    def visit_version(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1097
        self.visit_docinfo_item(node, 'version')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1098
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1099
    def visit_warning(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1100
        self.visit_admonition(node, 'warning')
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1101
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1102
    depart_warning = depart_admonition
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1103
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1104
    def unimplemented_visit(self, node):
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1105
        raise NotImplementedError('visiting unimplemented node type: %s'
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1106
                                  % node.__class__.__name__)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1107
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1108
# The following part is taken from the Docutils rst2man.py script:
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1109
if __name__ == "__main__":
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1110
    from docutils.core import publish_cmdline, default_description
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1111
    description = ("Generates plain unix manual documents.  " +
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1112
                   default_description)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1113
    publish_cmdline(writer=Writer(), description=description)
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1114
a82db54bc3be doc: use our own rst2man.py script (issue1746)
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
  1115
# vim: set fileencoding=utf-8 et ts=4 ai :