Rev 5219: Delete dead code and ensure compatibility with lucid. in file:///home/vila/src/bzr/bugs/219334-texinfo/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Jul 5 18:05:31 BST 2010
At file:///home/vila/src/bzr/bugs/219334-texinfo/
------------------------------------------------------------
revno: 5219
revision-id: v.ladeuil+lp at free.fr-20100705170531-116pjmnksoysxr55
parent: v.ladeuil+lp at free.fr-20100705160133-mm65deh355k9n89f
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: texinfo
timestamp: Mon 2010-07-05 19:05:31 +0200
message:
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.
-------------- next part --------------
=== modified file 'bzrlib/doc_generate/writers/texinfo.py'
--- a/bzrlib/doc_generate/writers/texinfo.py 2010-05-08 08:19:38 +0000
+++ b/bzrlib/doc_generate/writers/texinfo.py 2010-07-05 17:05:31 +0000
@@ -60,22 +60,14 @@
def __init__(self, document, builder):
nodes.NodeVisitor.__init__(self, document)
# toctree uses some nodes for different purposes (namely:
- # compact_paragraph, bullet_list, reference, list_item) that needs to
- # know when they are proessing a toctree. The following attributes take
- # care of the needs.
+ # compact_paragraph, bullet_list) that needs to know when they are
+ # proessing a toctree. The following attributes take care of the needs.
self.in_toctree = False
- self.toctree_current_ref = None
# sections can be embedded and produce different directives depending
# on the depth.
self.section_level = -1
- # The title text is in a Text node that shouldn't be output literally
- self.in_title = False
- # Tables has some specific nodes but need more help
- self.in_table = False
- self.tab_nb_cols = None
- self.tab_item_cmd = None
- self.tab_tab_cmd = None
- self.tab_entry_num = None
+ # By default paragraghs are separated by newlines, but there are some
+ # exceptions that set it to '' for some subtrees instead
self.paragraph_sep = '\n'
# The whole document
@@ -194,8 +186,7 @@
set_item_collector(node, 'text')
def depart_title(self, node):
- text = get_collected_item(node, 'text')
- node.parent['title'] = text
+ node.parent['title'] = node['text']
def visit_label(self, node):
raise nodes.SkipNode # Not implemented yet
@@ -209,38 +200,37 @@
pass
def depart_Text(self, node):
- text = node.data
+ text = node.astext()
if '@' in text:
text = text.replace('@', '@@')
if '{' in text:
text = text.replace('{', '@{')
if '}' in text:
text = text.replace('}', '@}')
- if node.parent is None:
- import pdb; pdb.set_trace()
node.parent.collect_text(text)
+
# Styled text
def visit_emphasis(self, node):
set_item_collector(node, 'text')
def depart_emphasis(self, node):
- text = '@emph{%s}' % get_collected_item(node, 'text')
+ text = '@emph{%s}' % node['text']
node.parent.collect_text(text)
def visit_strong(self, node):
set_item_collector(node, 'text')
def depart_strong(self, node):
- text = '@strong{%s}' % get_collected_item(node, 'text')
+ text = '@strong{%s}' % node['text']
node.parent.collect_text(text)
def visit_literal(self, node):
set_item_collector(node, 'text')
def depart_literal(self, node):
- text = '@code{%s}' % get_collected_item(node, 'text')
+ text = '@code{%s}' % node['text']
node.parent.collect_text(text)
# Lists
@@ -486,10 +476,6 @@
setattr(node, 'collect_' + name, set_item)
-def get_collected_item(node, name):
- return node[name]
-
-
def set_item_list_collector(node, name, sep=''):
node[name] = []
node[name + '_sep'] = sep
@@ -498,7 +484,3 @@
setattr(node, 'collect_' + name, append_item)
-def get_collected_item_list(node, name):
- return node[name + '_sep'].join(node[name])
-
-
=== modified file 'bzrlib/tests/doc_generate/builders/test_texinfo.py'
--- a/bzrlib/tests/doc_generate/builders/test_texinfo.py 2010-05-07 21:50:14 +0000
+++ b/bzrlib/tests/doc_generate/builders/test_texinfo.py 2010-07-05 17:05:31 +0000
@@ -163,7 +163,7 @@
Bazaar Release Notes
####################
''')
- self.assertContent('''@chapter Bazaar Release Notes\n''', end='')
+ self.assertContent('@chapter Bazaar Release Notes\n', end='')
class TestListGeneration(TestSphinx):
More information about the bazaar-commits
mailing list