def _process_script(source, filename, env, js_name, use_relative_paths=False): # Explicitly make sure old extensions are not included until a better # automatic mechanism is available Model._clear_extensions() # quick and dirty way to inject Google API key if "GOOGLE_API_KEY" in source: GOOGLE_API_KEY = getenv('GOOGLE_API_KEY') if GOOGLE_API_KEY is None: if env.config.bokeh_missing_google_api_key_ok: GOOGLE_API_KEY = "MISSING_API_KEY" else: raise SphinxError( "The GOOGLE_API_KEY environment variable is not set. Set GOOGLE_API_KEY to a valid API key, " "or set bokeh_missing_google_api_key_ok=True in conf.py to build anyway (with broken GMaps)" ) run_source = source.replace("GOOGLE_API_KEY", GOOGLE_API_KEY) else: run_source = source c = ExampleHandler(source=run_source, filename=filename) d = Document() c.modify_document(d) if c.error: raise RuntimeError(c.error_detail) resources = get_sphinx_resources() js_path = join(env.bokeh_plot_auxdir, js_name) js, script = autoload_static(d.roots[0], resources, js_name) with open(js_path, "w") as f: f.write(js) return (script, js, js_path, source)
def process_source(self, source, path, js_filename): Model._clear_extensions() root, docstring = _evaluate_source(source, path, self.env) height_hint = root._sphinx_height_hint() js_path = join(self.env.bokeh_plot_auxdir, js_filename) js, script_tag = autoload_static(root, RESOURCES, js_filename) with open(js_path, "w") as f: f.write(js) return (script_tag, js_path, source, docstring, height_hint)
def _process_script(source, filename, env, js_name, use_relative_paths=False): # Explicitly make sure old extensions are not included until a better # automatic mechanism is available Model._clear_extensions() # quick and dirty way to inject Google API key if "GOOGLE_API_KEY" in source: GOOGLE_API_KEY = getenv("GOOGLE_API_KEY") if GOOGLE_API_KEY is None: if env.config.bokeh_missing_google_api_key_ok: GOOGLE_API_KEY = "MISSING_API_KEY" else: raise SphinxError( "The GOOGLE_API_KEY environment variable is not set. Set GOOGLE_API_KEY to a valid API key, " "or set bokeh_missing_google_api_key_ok=True in conf.py to build anyway (with broken GMaps)" ) run_source = source.replace("GOOGLE_API_KEY", GOOGLE_API_KEY) else: run_source = source c = ExampleHandler(source=run_source, filename=filename) d = Document() # We may need to instantiate deprecated objects as part of documenting # them in the reference guide. Suppress any warnings here to keep the # docs build clean just for this case with warnings.catch_warnings(): if "reference" in env.docname: warnings.filterwarnings("ignore", category=BokehDeprecationWarning) c.modify_document(d) if c.error: raise RuntimeError(c.error_detail) resources = get_sphinx_resources() js_path = join(env.bokeh_plot_auxdir, js_name) js, script = autoload_static(d.roots[0], resources, js_name) with open(js_path, "w") as f: f.write(js) return (script, js, js_path, source)