diff options
author | Georg Brandl <georg@python.org> | 2008-09-24 12:01:16 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-09-24 12:01:16 +0000 |
commit | 0970f31caa728c4e3d267ff5b8bb326e1773ec4e (patch) | |
tree | 512846d8745bac5e85aab829da0f9f03cdd1894f /sphinx/builder.py | |
parent | 0830a04bbf83f3da75c3ab95cee27bba0e721c46 (diff) | |
download | sphinx-git-0970f31caa728c4e3d267ff5b8bb326e1773ec4e.tar.gz |
Rename util.json to util.jsdump because it doesn't generate valid JSON anymore.
The JSON html builder still needs simplejson to work.
Diffstat (limited to 'sphinx/builder.py')
-rw-r--r-- | sphinx/builder.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sphinx/builder.py b/sphinx/builder.py index 2a1379bc7..228959548 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -26,7 +26,7 @@ from docutils.frontend import OptionParser from docutils.readers.doctree import Reader as DoctreeReader from sphinx import addnodes, locale, __version__ -from sphinx.util import ensuredir, relative_uri, SEP, os_path, json, texescape +from sphinx.util import ensuredir, relative_uri, SEP, os_path, texescape from sphinx.htmlhelp import build_hhx from sphinx.htmlwriter import HTMLWriter, HTMLTranslator, SmartyPantsHTMLTranslator from sphinx.textwriter import TextWriter @@ -36,6 +36,14 @@ from sphinx.highlighting import PygmentsBridge from sphinx.util.console import bold, purple, darkgreen from sphinx.search import js_index +try: + import json +except ImportError: + try: + import ssimplejson as json + except ImportError: + json = None + # side effect: registers roles and directives from sphinx import roles from sphinx import directives @@ -802,9 +810,6 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): self.init_translator_class() self.templates = None # no template bridge necessary - indexer_format = property(lambda x: x.implementation, doc=''' - Alias the indexer format to the serilization implementation''') - def get_target_uri(self, docname, typ=None): if docname == 'index': return '' @@ -866,6 +871,7 @@ class PickleHTMLBuilder(SerializingHTMLBuilder): A Builder that dumps the generated HTML into pickle files. """ implementation = pickle + indexer_format = pickle name = 'pickle' out_suffix = '.fpickle' globalcontext_filename = 'globalcontext.pickle' @@ -877,11 +883,20 @@ class JSONHTMLBuilder(SerializingHTMLBuilder): A builder that dumps the generated HTML into JSON files. """ implementation = json + indexer_format = json name = 'json' out_suffix = '.fjson' globalcontext_filename = 'globalcontext.json' searchindex_filename = 'searchindex.json' + def init(self): + if json is None: + from sphinx.application import SphinxError + raise SphinxError('The module simplejson (or json in Python >= 2.6) ' + 'is not available. The JSONHTMLBuilder builder ' + 'will not work.') + SerializingHTMLBuilder.init(self) + class HTMLHelpBuilder(StandaloneHTMLBuilder): """ |