diff options
author | Jacob Mason <jacoblmason@gmail.com> | 2010-07-08 21:35:19 -0500 |
---|---|---|
committer | Jacob Mason <jacoblmason@gmail.com> | 2010-07-08 21:35:19 -0500 |
commit | 03056a8a31062034edb88521cafb2fa66238076f (patch) | |
tree | c5ab504e42aa111e264ecd6a7aba635265cc3196 /sphinx/writers/websupport.py | |
parent | ac262bb012458987adcb25941c845578232bd2ca (diff) | |
download | sphinx-git-03056a8a31062034edb88521cafb2fa66238076f.tar.gz |
Basic comment system.
Diffstat (limited to 'sphinx/writers/websupport.py')
-rw-r--r-- | sphinx/writers/websupport.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sphinx/writers/websupport.py b/sphinx/writers/websupport.py index 4afc3ecbd..18c0807d6 100644 --- a/sphinx/writers/websupport.py +++ b/sphinx/writers/websupport.py @@ -41,14 +41,14 @@ class WebSupportTranslator(HTMLTranslator): # node will not be commented. if not self.in_commentable: self.in_commentable = True - id = self.create_id(node) + node_id = self.add_db_node(node) # We will place the node in the HTML id attribute. If the node - # already has another id (for indexing purposes) put an empty + # 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'] = [id] + node.attributes['ids'] = ['s%s' % node_id] node.attributes['classes'].append(self.comment_class) def handle_depart_commentable(self, node): @@ -56,6 +56,10 @@ class WebSupportTranslator(HTMLTranslator): if self.comment_class in node.attributes['classes']: self.in_commentable = False - def create_id(self, node): - self.current_id += 1 - return '%s_%s' % (node.__class__.__name__, self.current_id) + def add_db_node(self, node): + comments = self.builder.app.comments + db_node_id = comments.add_node(document=self.builder.cur_docname, + line=node.line, + source=node.rawsource, + treeloc='???') + return db_node_id |