~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/doc_generate/writers/texinfo.py

  • Committer: Vincent Ladeuil
  • Date: 2010-07-05 17:05:31 UTC
  • mto: (5355.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5356.
  • Revision ID: v.ladeuil+lp@free.fr-20100705170531-116pjmnksoysxr55
Delete dead code and ensure compatibility with lucid.

* bzrlib/doc_generate/writers/texinfo.py:
Some cleanup.
(TexinfoTranslator.__init__): Get rid of the now useless
attributes.
(TexinfoTranslator.depart_Text): On lucid (more recent version of
docutils and sphinx), astext() *must* be used, 'node.data' doesn't
exist anymore and wasn't the official way to get the text anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    def __init__(self, document, builder):
61
61
        nodes.NodeVisitor.__init__(self, document)
62
62
        # toctree uses some nodes for different purposes (namely:
63
 
        # compact_paragraph, bullet_list, reference, list_item) that needs to
64
 
        # know when they are proessing a toctree. The following attributes take
65
 
        # care of the needs.
 
63
        # compact_paragraph, bullet_list) that needs to know when they are
 
64
        # proessing a toctree. The following attributes take care of the needs.
66
65
        self.in_toctree = False
67
 
        self.toctree_current_ref = None
68
66
        # sections can be embedded and produce different directives depending
69
67
        # on the depth.
70
68
        self.section_level = -1
71
 
        # The title text is in a Text node that shouldn't be output literally
72
 
        self.in_title = False
73
 
        # Tables has some specific nodes but need more help
74
 
        self.in_table = False
75
 
        self.tab_nb_cols = None
76
 
        self.tab_item_cmd = None
77
 
        self.tab_tab_cmd = None
78
 
        self.tab_entry_num = None
 
69
        # By default paragraghs are separated by newlines, but there are some
 
70
        # exceptions that set it to '' for some subtrees instead
79
71
        self.paragraph_sep = '\n'
80
72
 
81
73
    # The whole document
194
186
        set_item_collector(node, 'text')
195
187
 
196
188
    def depart_title(self, node):
197
 
        text = get_collected_item(node, 'text')
198
 
        node.parent['title'] = text
 
189
        node.parent['title'] = node['text']
199
190
 
200
191
    def visit_label(self, node):
201
192
        raise nodes.SkipNode # Not implemented yet
209
200
        pass
210
201
 
211
202
    def depart_Text(self, node):
212
 
        text = node.data
 
203
        text = node.astext()
213
204
        if '@' in text:
214
205
            text = text.replace('@', '@@')
215
206
        if '{' in text:
216
207
            text = text.replace('{', '@{')
217
208
        if '}' in text:
218
209
            text = text.replace('}', '@}')
219
 
        if node.parent is None:
220
 
            import pdb; pdb.set_trace()
221
210
        node.parent.collect_text(text)
222
211
 
 
212
 
223
213
    # Styled text
224
214
 
225
215
    def visit_emphasis(self, node):
226
216
        set_item_collector(node, 'text')
227
217
 
228
218
    def depart_emphasis(self, node):
229
 
        text = '@emph{%s}' % get_collected_item(node, 'text')
 
219
        text = '@emph{%s}' % node['text']
230
220
        node.parent.collect_text(text)
231
221
 
232
222
    def visit_strong(self, node):
233
223
        set_item_collector(node, 'text')
234
224
 
235
225
    def depart_strong(self, node):
236
 
        text = '@strong{%s}' % get_collected_item(node, 'text')
 
226
        text = '@strong{%s}' % node['text']
237
227
        node.parent.collect_text(text)
238
228
 
239
229
    def visit_literal(self, node):
240
230
        set_item_collector(node, 'text')
241
231
 
242
232
    def depart_literal(self, node):
243
 
        text = '@code{%s}' % get_collected_item(node, 'text')
 
233
        text = '@code{%s}' % node['text']
244
234
        node.parent.collect_text(text)
245
235
 
246
236
    # Lists
486
476
    setattr(node, 'collect_' + name, set_item)
487
477
 
488
478
 
489
 
def get_collected_item(node, name):
490
 
    return node[name]
491
 
 
492
 
 
493
479
def set_item_list_collector(node, name, sep=''):
494
480
    node[name] = []
495
481
    node[name + '_sep'] = sep
498
484
    setattr(node, 'collect_' + name, append_item)
499
485
 
500
486
 
501
 
def get_collected_item_list(node, name):
502
 
    return node[name + '_sep'].join(node[name])
503
 
 
504