def builder_inited(app): if not app.config.hyphenator_path: raise ExtensionError('hyphenator extension: "hyphenator_path" must be' ' set in "conf.py"') app.add_javascript( os.path.join(app.config.hyphenator_path, 'Hyphenator.js')) if app.config.hyphenator_language: language = app.config.hyphenator_language elif app.config.language: language = app.config.language else: raise ExtensionError('hyphenator extension: no language found' ', please set "hyphenator_language"' ' in your conf.py') start_script = ("var hyphenatorSettings = {\n" " selectorfunction: function() {\n" " return $('.document, .sphinxsidebar').get()},\n" " displaytogglebox: true,\n" " defaultlanguage: '%s'\n" " };\n" "Hyphenator.config(hyphenatorSettings);\n" "Hyphenator.run();" % language) script_name = "run_hyphenation.js" script_path = os.path.join(app.confdir, app.config.html_static_path[0], script_name) with open(script_path, "w") as script_file: script_file.write(start_script) app.add_javascript(script_name)
def builder_inited(app): datapath = app.config.datacamp_path if not datapath: raise ExtensionError('datacamp_path config value must be set for the ' 'datacamp extension to work') if datapath: app.add_javascript(datapath)
def get_shortname(self): """Validate and returns disqus_shortname config value. :returns: disqus_shortname config value. :rtype: str """ disqus_shortname = self.state.document.settings.env.config.disqus_shortname if not disqus_shortname: raise ExtensionError( 'disqus_shortname config value must be set for the disqus extension to work.' ) if not RE_SHORTNAME.match(disqus_shortname): raise ExtensionError( 'disqus_shortname config value must be 3-50 letters, numbers, and hyphens only.' ) return disqus_shortname
def builder_inited(app): """ Adds mathjax javascript file to app. """ if not app.config.mathjax_path: raise ExtensionError('mathjax_path config value must be set for the ' 'mathjax extension to work') app.add_javascript(app.config.mathjax_path)
def setup(app): try: mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) except ExtensionError: raise ExtensionError('sphinx.ext.jsmath: other math package is already loaded') app.add_config_value('jsmath_path', '', False) app.connect('builder-inited', builder_inited) return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
def add_documenter(cls): """Register a new Documenter.""" if not issubclass(cls, Documenter): raise ExtensionError('autodoc documenter %r must be a subclass ' 'of Documenter' % cls) # actually, it should be possible to override Documenters #if cls.objtype in AutoDirective._registry: # raise ExtensionError('autodoc documenter for %r is already ' # 'registered' % cls.objtype) AutoDirective._registry[cls.objtype] = cls
def add_documenter(cls): """ Register a new Documenter. This autodoc function is overridden here solely for the sake of the proper error message. """ if not issubclass(cls, Documenter): raise ExtensionError('enamldoc documenter %r must be a subclass ' 'of autodoc.Documenter' % cls) AutoDirective._registry[cls.objtype] = cls
def builder_inited(app): jaxpath = app.config.mathjax_path if not jaxpath: raise ExtensionError('mathjax_path config value must be set for the ' 'mathjax extension to work') # app.config.mathjax_path can be a string or a list of strings if isinstance(jaxpath, basestring): app.add_javascript(jaxpath) else: for p in jaxpath: app.add_javascript(p) if app.config.mathjax_css: app.add_stylesheet(app.config.mathjax_css)
def setup(app): """entry-point for sphinx""" if IS_SUPPORTED_THEMEPLUGIN: pass elif setup_themes is not None: setup_themes(app) else: raise ExtensionError( 'sphinxjp.themes.s6 requires at least Sphinx-1.2 or ' 'Sphinx-1.1 + sphinxjp.themecore to run.') directives.setup(app) app.connect("doctree-resolved", on_doctree_resolved) app.add_javascript('jquery.touchwipe.min.js') app.add_javascript('s6.js') app.add_javascript('s6-sphinx.js')
def setup(app): try: mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) except ExtensionError: raise ExtensionError( 'sphinx.ext.mathjax: other math package is already loaded') # more information for mathjax secure url is here: # http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn try: app.add_config_value( 'mathjax_path', 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?' 'config=TeX-AMS-MML_HTMLorMML', False) app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html') app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html') except: pass app.add_config_value('mathjax_css', None, 'html') app.add_config_value('mathjax_use_katex', False, 'html') app.connect('builder-inited', builder_inited) return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
def builder_inited(app): if not app.config.ga_id: raise ExtensionError("'ga_id config value must be set for the " "google analytics extension to work'")
def builder_inited(app): if not app.config.jsmath_path: raise ExtensionError('jsmath_path config value must be set for the ' 'jsmath extension to work') app.add_javascript(app.config.jsmath_path)
def check_config(app): if not app.config.googleanalytics_id: raise ExtensionError( "'googleanalytics_id' config value must be set for ga statistics to function properly." )