def run(self, context):
        if not self.can_run():
            return bento.errors.CommandExecutionFailure("sphinx not available")
        import sphinx.application

        p = context.options_context.parser
        o, a = p.parse_args(context.command_argv)
        if o.output_format != "html":
            raise ValueError("Only html output supported for now")
        else:
            builder = "html"

        if o.source_dir is None:
            source_dir = guess_source_dir()
        else:
            source_dir = o.source_dir
        if source_dir is None:
            raise bento.errors.UsageException("""\
Doc source dir could not be found: please specify the directory where your
sphinx conf.py is located with the --source-dir option""")
        if not op.isabs(source_dir):
            source_dir = op.join(context.top_node.abspath(), source_dir)

        sphinx_build = context.build_node.make_node("sphinx")
        html_build = sphinx_build.make_node(o.output_format)
        doctrees_build = sphinx_build.make_node("doctrees")

        doc_html_build = html_build.abspath()
        doc_doctrees_build = doctrees_build.abspath()

        confoverrides = {}
        status_stream = sys.stdout
        fresh_env = False
        force_all = False

        app = sphinx.application.Sphinx(
                source_dir, source_dir,
                doc_html_build, doc_doctrees_build,
                builder, confoverrides, status_stream,
                freshenv=fresh_env)
        try:
            app.build(force_all=force_all)
        except Exception:
            err = extract_exception()
            raise bento.errors.CommandExecutionFailure("error while building doc: %r" % str(err))
dataset/ETHPy150Open cournape/Bento/bento/commands/sphinx_command.py/SphinxCommand.run/original