summaryrefslogtreecommitdiff
path: root/sphinx/writers/websupport.py
diff options
context:
space:
mode:
authorjacob <jacob@panda>2010-05-30 21:33:04 -0500
committerjacob <jacob@panda>2010-05-30 21:33:04 -0500
commit099a58e0b7b37b0737c83253fda5b1ff344bdec2 (patch)
tree739d9645894d5adee068743f64f2098bfe0db078 /sphinx/writers/websupport.py
parent460874e11951815c3c96baf4ceaf79cfee5889cb (diff)
downloadsphinx-git-099a58e0b7b37b0737c83253fda5b1ff344bdec2.tar.gz
"Initial commit": Added sphinx.websupport module, as well as a builder and writer for the web support package.
Diffstat (limited to 'sphinx/writers/websupport.py')
-rw-r--r--sphinx/writers/websupport.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/sphinx/writers/websupport.py b/sphinx/writers/websupport.py
new file mode 100644
index 000000000..3b2507558
--- /dev/null
+++ b/sphinx/writers/websupport.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+"""
+ sphinx.writers.websupport
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ docutils writers handling Sphinx' custom nodes.
+
+ :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from sphinx.writers.html import HTMLTranslator
+from sphinx.websupport.document import Document
+
+class WebSupportTranslator(HTMLTranslator):
+ """
+ Our custom HTML translator.
+ """
+ def __init__(self, builder, *args, **kwargs):
+ HTMLTranslator.__init__(self, builder, *args, **kwargs)
+ self.support_document = Document()
+ self.current_id = 0
+
+ def depart_paragraph(self, node):
+ HTMLTranslator.depart_paragraph(self, node)
+ self.support_document.add_commentable(self.current_id)
+ self.body.append("{{ render_comment('%s-p%s') }}" %
+ (self.builder.docname, self.current_id))
+ self.current_id += 1