summaryrefslogtreecommitdiff
path: root/sphinx/websupport/api.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/websupport/api.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/websupport/api.py')
-rw-r--r--sphinx/websupport/api.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/sphinx/websupport/api.py b/sphinx/websupport/api.py
new file mode 100644
index 000000000..da6fc9e1f
--- /dev/null
+++ b/sphinx/websupport/api.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+"""
+ sphinx.websupport.api
+ ~~~~~~~~~~~~~~~~~~~~
+
+ All API functions.
+
+ :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import cPickle as pickle
+from os import path
+
+from jinja2 import Template
+
+from sphinx.application import Sphinx
+
+class WebSupport(object):
+
+ def init(self, srcdir, outdir='', comment_html=''):
+ self.srcdir = srcdir
+ self.outdir = outdir or os.path.join(self.srcdir, '_build',
+ 'websupport')
+ self.comment_template = Template(comment_html)
+
+ def build(self, **kwargs):
+ doctreedir = kwargs.pop('doctreedir',
+ path.join(self.outdir, 'doctrees'))
+ app = Sphinx(self.srcdir, self.srcdir,
+ self.outdir, doctreedir, 'websupport')
+ app.build()
+
+ def get_document(self, docname):
+ infilename = path.join(self.outdir, docname + '.fpickle')
+ f = open(infilename, 'rb')
+ document = pickle.load(f)
+ # The document renders the comment_template.
+ document.comment_template = self.comment_template
+ return document