当前位置: 首页>>代码示例>>Python>>正文


Python Sphinx.build方法代码示例

本文整理汇总了Python中sphinx.application.Sphinx.build方法的典型用法代码示例。如果您正苦于以下问题:Python Sphinx.build方法的具体用法?Python Sphinx.build怎么用?Python Sphinx.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sphinx.application.Sphinx的用法示例。


在下文中一共展示了Sphinx.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_body

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def test_body():
    with open(os.path.join(_srcdir, 'conf.py'), 'w') as f:
        f.write('''
extensions = [ 'sphinxcontrib.spelling' ]
''')
    with open(os.path.join(_srcdir, 'contents.rst'), 'w') as f:
        f.write('''
Welcome to Spelling Checker documentation!
==========================================

There are several mispelled words in this txt.
''')
    stdout = StringIO()
    stderr = StringIO()
    app = Sphinx(_srcdir, _srcdir, _outdir, _outdir, 'spelling',
                 status=stdout, warning=stderr,
                 freshenv=True,
                 )
    app.build()
    print 'reading from %s' % app.builder.output_filename
    with codecs.open(app.builder.output_filename, 'r') as f:
        output_text = f.read()

    def check_one(word):
        assert word in output_text
    for word in [ '(mispelled)', '(txt)' ]:
        yield check_one, word
    return
开发者ID:torcolvin,项目名称:sphinx-contrib,代码行数:30,代码来源:test_builder.py

示例2: make_sphinx

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
  def make_sphinx(docbase, buildername='html'):
    docbase = os.path.abspath(docbase)
    if not os.path.isdir(docbase):
      cprint(bcolors.WARNING, "[%s] is not a valid directory" % docbase)

    cprint(bcolors.OKBLUE, "Building %s..." % docbase[:67])
    verbose_output = StringIO()
    sphinx = Sphinx(
      srcdir=os.path.join(docbase, 'source'),
      confdir=os.path.join(docbase, 'source'),
      outdir=os.path.join(docbase, '_build', 'html'),
      doctreedir=os.path.join(docbase, '_build', 'doctrees'),
      buildername='html',
      #confoverrides=None,
      status=verbose_output,
      #warning=sys.stderr,
      #freshenv=False,
      #warningiserror=False,
      #tags=None,
      #verbosity=0,
      #parallel=0
    )
    sphinx.build(
      #force_all=False,
      #filenames=None
    )
    vprint(verbose_output.getvalue())
    verbose_output.close()
开发者ID:sbennett18,项目名称:dotfiles,代码行数:30,代码来源:run.py

示例3: pytest_funcarg__app

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def pytest_funcarg__app(request):
    """
    A Sphinx application for testing.

    The app uses the source directory from the ``srcdir`` funcarg, and writes
    to the directories given by the ``outdir`` and ``doctreedir`` funcargs.
    Additional configuration values can be inserted into this application
    through the ``confoverrides`` funcarg.

    If the marker ``mock_lookup`` is attached to the current test, the lookup
    callback returned by the ``mock_lookup`` funcarg is automatically connected
    to the ``issuetracker-lookup-issue`` event in the the created application.

    If the marker ``build_app`` is attached to the current test, the app is
    build before returning it.  Otherwise you need to build explicitly in order
    to get the output.
    """
    srcdir = request.getfuncargvalue('srcdir')
    outdir = request.getfuncargvalue('outdir')
    doctreedir = request.getfuncargvalue('doctreedir')
    confoverrides = request.getfuncargvalue('confoverrides')
    app = Sphinx(str(srcdir), str(srcdir), str(outdir), str(doctreedir),
                 'html', confoverrides=confoverrides, status=None,
                 warning=None, freshenv=True)
    request.addfinalizer(reset_global_state)
    if 'mock_lookup' in request.keywords:
        lookup_mock_issue = request.getfuncargvalue('mock_lookup')
        app.connect(str('issuetracker-lookup-issue'), lookup_mock_issue)
    if 'build_app' in request.keywords:
        app.build()
    return app
开发者ID:evildmp,项目名称:sphinxcontrib-issuetracker,代码行数:33,代码来源:conftest.py

示例4: test_spelling

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
 def test_spelling(self):
     status = StringIO()
     with TemporaryDirectory() as OUT_DIR:
         with tmp_list_append(sys.argv, 'spelling'):
             try:
                 app = Sphinx(
                     srcdir=DOCS_DIR,
                     confdir=DOCS_DIR,
                     outdir=OUT_DIR,
                     doctreedir=OUT_DIR,
                     buildername="spelling",
                     warningiserror=True,
                     status=status,
                     confoverrides={
                         'extensions': [
                             'djangocms',
                             'sphinx.ext.intersphinx',
                             'sphinxcontrib.spelling'
                         ]
                     }
                 )
                 app.build()
                 self.assertEqual(app.statuscode, 0, status.getvalue())
             except SphinxWarning:
                 # while normally harmless, causes a test failure
                 pass
             except:
                 print(status.getvalue())
                 raise
开发者ID:quanpower,项目名称:django-cms,代码行数:31,代码来源:test_docs.py

示例5: sphinx_app

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def sphinx_app(tmpdir_factory):
    if LooseVersion(sphinx.__version__) < LooseVersion('1.8'):
        # Previous versions throw an error trying to pickle the scraper
        pytest.skip('Sphinx 1.8+ required')
    temp_dir = (tmpdir_factory.getbasetemp() / 'root').strpath
    src_dir = op.join(op.dirname(__file__), 'tinybuild')

    def ignore(src, names):
        return ('_build', 'gen_modules', 'auto_examples')

    shutil.copytree(src_dir, temp_dir, ignore=ignore)
    # For testing iteration, you can get similar behavior just doing `make`
    # inside the tinybuild directory
    src_dir = temp_dir
    conf_dir = temp_dir
    out_dir = op.join(temp_dir, '_build', 'html')
    toctrees_dir = op.join(temp_dir, '_build', 'toctrees')
    # Avoid warnings about re-registration, see:
    # https://github.com/sphinx-doc/sphinx/issues/5038
    with docutils_namespace():
        app = Sphinx(src_dir, conf_dir, out_dir, toctrees_dir,
                     buildername='html', status=MixedEncodingStringIO())
        # need to build within the context manager
        # for automodule and backrefs to work
        app.build(False, [])
    return app
开发者ID:sphinx-gallery,项目名称:sphinx-gallery,代码行数:28,代码来源:test_full.py

示例6: get_long_description

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def get_long_description(cleanup=True):
    from sphinx.application import Sphinx
    from sphinx.util.osutil import abspath
    import tempfile
    import shutil
    from doc.conf import extensions
    from sphinxcontrib.writers.rst import RstTranslator
    from sphinx.ext.graphviz import text_visit_graphviz
    RstTranslator.visit_dsp = text_visit_graphviz
    outdir = tempfile.mkdtemp(prefix='setup-', dir='.')
    exclude_patterns = os.listdir(mydir or '.')
    exclude_patterns.remove('pypi.rst')

    app = Sphinx(abspath(mydir), osp.join(mydir, 'doc/'), outdir,
                 outdir + '/.doctree', 'rst',
                 confoverrides={
                     'exclude_patterns': exclude_patterns,
                     'master_doc': 'pypi',
                     'dispatchers_out_dir': abspath(outdir + '/_dispatchers'),
                     'extensions': extensions + ['sphinxcontrib.restbuilder']
                 }, status=None, warning=None)

    app.build(filenames=[osp.join(app.srcdir, 'pypi.rst')])

    with open(outdir + '/pypi.rst') as file:
        res = file.read()

    if cleanup:
        shutil.rmtree(outdir)
    return res
开发者ID:vinci1it2000,项目名称:dispatcher,代码行数:32,代码来源:setup.py

示例7: build

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
    def build(self):
        """Build the documentation. Places the data into the `outdir`
        directory. Use it like this::

            support = WebSupport(srcdir, builddir, search='xapian')
            support.build()

        This will read reStructured text files from `srcdir`. Then it will
        build the pickles and search index, placing them into `builddir`.
        It will also save node data to the database.
        """
        if not self.srcdir:
            raise RuntimeError("No srcdir associated with WebSupport object")
        app = Sphinx(
            self.srcdir,
            self.srcdir,
            self.outdir,
            self.doctreedir,
            "websupport",
            status=self.status,
            warning=self.warning,
        )
        app.builder.set_webinfo(self.staticdir, self.staticroot, self.search, self.storage)

        self.storage.pre_build()
        app.build()
        self.storage.post_build()
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:29,代码来源:__init__.py

示例8: sphinx_build

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
    def sphinx_build(self):

        workdir = self._workdir
        if not os.path.isdir(workdir):
            os.makedirs(workdir)

        conf = os.path.join(workdir, 'conf.py')
        with codecs.open(conf, encoding='utf-8', mode='w') as out:
            out.write(SPHINX_CONF)
            out.write(SPHINX_CONF_APPEND)

        start = time.time()
        status = MezeStream(sys.stdout)
        warning = MezeStream(sys.stderr)
        app = Sphinx(srcdir=workdir, confdir=workdir, outdir=workdir,
                     doctreedir=workdir, buildername='meze',
                     confoverrides={}, status=status, warning=warning,
                     freshenv=False, warningiserror=False, tags=[])

        rst = os.path.join(workdir, 'index' + app.config.source_suffix[0])
        with codecs.open(rst, encoding='utf-8', mode='w') as out:
            out.write(self._source)

        app.build(False, [rst])

        self._messages.append((messages.INFO, 'Source was converted '
                               'into HTML using Sphinx in {:.2f}'.
                               format(time.time() - start)))
        for msg in warning.messages:
            items = msg.split('WARNING: ')
            if len(items) == 2:
                msg = items[1]
            self._messages.append((messages.WARNING, msg))

        self._content, MezeBuilder.context = MezeBuilder.context['body'], None
开发者ID:Nassty,项目名称:mezzanine-meze,代码行数:37,代码来源:meze.py

示例9: test_title

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def test_title():
    with open(os.path.join(_srcdir, 'conf.py'), 'w') as f:
        f.write('''
extensions = [ 'sphinxcontrib.spelling' ]
''')
    with open(os.path.join(_srcdir, 'contents.rst'), 'w') as f:
        f.write('''
Welcome to Speeling Checker documentation!
==========================================
''')
    stdout = StringIO()
    stderr = StringIO()
    app = Sphinx(_srcdir, _srcdir, _outdir, _outdir, 'spelling',
                 status=stdout, warning=stderr,
                 freshenv=True,
                 )
    app.build()
    with codecs.open(app.builder.output_filename, 'r') as f:
        output_text = f.read()

    def check_one(word):
        print output_text
        assert word in output_text
    for word in [ '(Speeling)', ]:
        yield check_one, word
    return
开发者ID:torcolvin,项目名称:sphinx-contrib,代码行数:28,代码来源:test_builder.py

示例10: run

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
    def run(self):
        if not color_terminal():
            # Windows' poor cmd box doesn't understand ANSI sequences
            nocolor()
        if not self.verbose:
            status_stream = StringIO()
        else:
            status_stream = sys.stdout
        confoverrides = {}
        if self.project:
             confoverrides['project'] = self.project
        if self.version:
             confoverrides['version'] = self.version
        if self.release:
             confoverrides['release'] = self.release
        if self.today:
             confoverrides['today'] = self.today
        app = Sphinx(self.source_dir, self.config_dir,
                     self.builder_target_dir, self.doctree_dir,
                     self.builder, confoverrides, status_stream,
                     freshenv=self.fresh_env)

        try:
            app.build(force_all=self.all_files)
        except Exception, err:
            from docutils.utils import SystemMessage
            if isinstance(err, SystemMessage):
                print >>sys.stderr, darkred('reST markup error:')
                print >>sys.stderr, err.args[0].encode('ascii',
                                                       'backslashreplace')
            else:
                raise
开发者ID:SurfasJones,项目名称:icecream-info,代码行数:34,代码来源:setup_command.py

示例11: runsphinx

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def runsphinx(text, builder, confoverrides):
    f = open(os.path.join(_srcdir, "index.rst"), "w")
    try:
        f.write(text.encode("utf-8"))
    finally:
        f.close()
    app = Sphinx(_srcdir, _fixturedir, _outdir, _outdir, builder, confoverrides)
    app.build()
开发者ID:skurfuerst,项目名称:ReST-summary,代码行数:10,代码来源:test_functional.py

示例12: run

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
 def run(self):
     from sphinx.application import Sphinx
     sph = Sphinx('./doc/source',  # source directory
                  './doc/source',  # directory containing conf.py
                  self.output_dir,  # output directory
                  './doc/build/doctrees',  # doctree directory
                  self.target)  # finally, specify the doctest builder'
     sph.build()
开发者ID:nihlaeth,项目名称:lilyflower,代码行数:10,代码来源:setup.py

示例13: runsphinx

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
def runsphinx(text, builder, confoverrides):
    f = open(os.path.join(_srcdir, 'index.rst'), 'w')
    try:
        f.write(text)
    finally:
        f.close()
    app = Sphinx(_srcdir, _fixturedir, _outdir, _outdir, builder,
                 confoverrides)
    app.build()
开发者ID:Lemma1,项目名称:MINAMI,代码行数:11,代码来源:test_functional.py

示例14: test_html

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
 def test_html(self):
     nullout = StringIO()
     with TemporaryDirectory() as OUT_DIR:
         app = Sphinx(DOCS_DIR, DOCS_DIR, OUT_DIR, OUT_DIR, "html", warningiserror=True, status=nullout)
         try:
             app.build()
         except:
             print nullout.getvalue()
             raise
开发者ID:philippbosch,项目名称:django-cms,代码行数:11,代码来源:docs.py

示例15: test_html_documentation

# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import build [as 别名]
 def test_html_documentation(self):
     app = Sphinx(
         self.source_dir,
         self.config_dir,
         self.output_dir,
         self.doctree_dir,
         buildername='html',
         warningiserror=True,
     )
     app.build(force_all=self.all_files)
开发者ID:zsdonghao,项目名称:tensorlayer,代码行数:12,代码来源:test_documentation.py


注:本文中的sphinx.application.Sphinx.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。