summaryrefslogtreecommitdiff
path: root/sphinx/writers/websupport.py
diff options
context:
space:
mode:
authorJacob Mason <jacoblmason@gmail.com>2010-08-14 16:05:19 -0500
committerJacob Mason <jacoblmason@gmail.com>2010-08-14 16:05:19 -0500
commit89566e69c994546ec9cf3157d9c915555c4017b2 (patch)
treec0b6794abc09f2963deb842f327aaf00f521188d /sphinx/writers/websupport.py
parentace0e37e03f3f8ba398b579b29dd734377fcb0f1 (diff)
downloadsphinx-git-89566e69c994546ec9cf3157d9c915555c4017b2.tar.gz
simplify websupport writer now that we don't have nested commentable nodes.
Diffstat (limited to 'sphinx/writers/websupport.py')
-rw-r--r--sphinx/writers/websupport.py34
1 files changed, 9 insertions, 25 deletions
diff --git a/sphinx/writers/websupport.py b/sphinx/writers/websupport.py
index fbd3c1ef5..c3d989b7c 100644
--- a/sphinx/writers/websupport.py
+++ b/sphinx/writers/websupport.py
@@ -20,38 +20,22 @@ class WebSupportTranslator(HTMLTranslator):
def __init__(self, builder, *args, **kwargs):
HTMLTranslator.__init__(self, builder, *args, **kwargs)
self.comment_class = 'spxcmt'
- self.init_support()
-
- def init_support(self):
- self.cur_node = None
def dispatch_visit(self, node):
if is_commentable(node):
self.handle_visit_commentable(node)
HTMLTranslator.dispatch_visit(self, node)
- def dispatch_departure(self, node):
- HTMLTranslator.dispatch_departure(self, node)
- if is_commentable(node):
- self.handle_depart_commentable(node)
-
def handle_visit_commentable(self, node):
- # If this node is nested inside another commentable node this
- # node will not be commented.
- if self.cur_node is None:
- self.cur_node = self.add_db_node(node)
- # We will place the node in the HTML id attribute. If the node
- # already has an id (for indexing purposes) put an empty
- # span with the existing id directly before this node's HTML.
- if node.attributes['ids']:
- self.body.append('<span id="%s"></span>'
- % node.attributes['ids'][0])
- node.attributes['ids'] = ['s%s' % self.cur_node.id]
- node.attributes['classes'].append(self.comment_class)
-
- def handle_depart_commentable(self, node):
- if self.comment_class in node.attributes['classes']:
- self.cur_node = None
+ db_node = self.add_db_node(node)
+ # We will place the node in the HTML id attribute. If the node
+ # already has an id (for indexing purposes) put an empty
+ # span with the existing id directly before this node's HTML.
+ if node.attributes['ids']:
+ self.body.append('<span id="%s"></span>'
+ % node.attributes['ids'][0])
+ node.attributes['ids'] = ['s%s' % db_node.id]
+ node.attributes['classes'].append(self.comment_class)
def add_db_node(self, node):
storage = self.builder.app.storage