• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sphinx.main函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sphinx.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: intl_update

    def intl_update(self):
        ui.info(ui.blue, "::", ui.reset, "Generating message catalogs ...")
        import sphinx
        from sphinx_intl.commands import run as sphinx_intl_run
        # First step: run sphinx-build -b gettext
        cmd = [sys.executable, "-c", self.build_dir, "-b", "gettext"]
        cmd.append(self.source_dir)
        locale_dir = os.path.join(self.source_dir, "locale")
        cmd.append(locale_dir)
        rc = 0
        try:
            sphinx.main(argv=cmd)
        except SystemExit as e:
            rc = e.code
        if rc != 0:
            raise SphinxBuildError(self)

        ui.info()

        # Second step: run sphinx-intl update -l <lingua> for every lingua
        ui.info(ui.blue, "::", ui.reset, "Updating .po files ...")
        for i, lingua in enumerate(self.linguas):
            ui.info_count(i, len(self.linguas), ui.blue, lingua)
            cmd = ["update",
                "-c", os.path.join(self.build_dir, "conf.py"),
                "--pot-dir", locale_dir,
                "--locale-dir", locale_dir,
                "--language", lingua]
            sphinx_intl_run(cmd)
开发者ID:Phlogistique,项目名称:qibuild,代码行数:29,代码来源:sphinx_project.py


示例2: build_docs

def build_docs():
    """Build the Blogofile sphinx based documentation"""
    #Abort if sphinx isn't installed
    try:
        import sphinx
    except ImportError:
        return
    #print "Building the docs..."
    #Configure the theme
    #Insert the rendered head, headers, and footers into the theme
    config = sys.modules[globals()['__name__']]
    from mako.template import Template
    head_t = Template(open(os.path.join("_templates","head.mako")).read())
    head = head_t.render(**{'bf':bf})
    header_t = Template(open(os.path.join("_templates","header.mako")).read())
    header = header_t.render(**{'bf':bf})
    footer_t = Template(open(os.path.join("_templates","footer.mako")).read())
    footer = footer_t.render(**{'bf':bf})

    #Create the new layout.html from preparse_layout.html
    #Insert the rendered templates appropriately
    layout = open(os.path.join("_documentation","themes","blogofile",
                               "preparse_layout.html")).read()
    layout = layout.replace("blogofile_head_goes_here",head)
    layout = layout.replace("blogofile_header_goes_here",header)
    layout = layout.replace("blogofile_footer_goes_here",footer)
    layout_f = open(os.path.join("_documentation","themes","blogofile",
                               "layout.html"),"w")
    layout_f.write(layout)
    layout_f.close()
    logger.info("Compiling HTML Documentation..")
    sphinx.main(shlex.split("sphinx-build -q -b html _documentation "+
                            os.path.join("_site","documentation")))
开发者ID:mpirnat,项目名称:blogofile.com,代码行数:33,代码来源:_config.py


示例3: _plugin_build_docs

def _plugin_build_docs(destdir, cfg, src="src"):
    """Builds the Sphinx docs for the plugin distribution, assuming it has
    a structure like the one created by plugin quickstart.
    """
    name = cfg.get("metadata", "name")
    version = cfg.get("metadata", "version")

    docdir = os.path.join(destdir, "docs")
    srcdir = os.path.abspath(os.path.join(destdir, src))

    sphinx.main(
        argv=[
            "",
            "-E",
            "-a",
            "-b",
            "html",
            "-Dversion=%s" % version,
            "-Drelease=%s" % version,
            "-d",
            os.path.join(srcdir, name, "sphinx_build", "doctrees"),
            docdir,
            os.path.join(srcdir, name, "sphinx_build", "html"),
        ]
    )
开发者ID:lazycrazyowl,项目名称:OpenMDAO-Framework,代码行数:25,代码来源:plugin.py


示例4: _plugin_build_docs

def _plugin_build_docs(destdir, cfg):
    """Builds the Sphinx docs for the plugin distribution, assuming it has
    a structure like the one created by plugin quickstart.
    """
    name = cfg.get('metadata', 'name')
    version = cfg.get('metadata', 'version')
    
    path_added = False
    try:
        docdir = os.path.join(destdir, 'docs')
        srcdir = os.path.join(destdir, 'src')
        
        # have to add srcdir to sys.path or autodoc won't find source code
        if srcdir not in sys.path:
            sys.path[0:0] = [srcdir]
            path_added = True
            
        sphinx.main(argv=['', '-E', '-a', '-b', 'html',
                          '-Dversion=%s' % version,
                          '-Drelease=%s' % version,
                          '-d', os.path.join(srcdir, name, 'sphinx_build', 'doctrees'), 
                          docdir, 
                          os.path.join(srcdir, name, 'sphinx_build', 'html')])
    finally:
        if path_added:
            sys.path.remove(srcdir)
开发者ID:fzahle,项目名称:OpenMDAO-Framework,代码行数:26,代码来源:plugin.py


示例5: run

    def run(self):
        if self.clean:
            if not os.path.exists(self.builddir):
                print('Nothing to clean, quiting...')
                return

            prompt = ('This action will remove all files in {0}, '
                      'would you like to continue? (y/N)').format(
                os.path.abspath(self.builddir))

            try:
                answer = raw_input(prompt)
            except NameError:
                answer = input(prompt)
            finally:
                if answer.lower() == 'y':
                    shutil.rmtree(self.builddir)
                else:
                    print('Operation aborted.')
        else:
            import sphinx

            sphinxbuild = os.environ.get('SPHINXBUILD', self.sphinxbuild)
            sphinxopts = os.environ.get('SPHINXOPTS', self.sphinxopts)
            args = '{0} -b {1} -d {2}/doctree {3} {4} {2}/{1}'

            self._process_images()
            for fmt in self.formats:
                sphinx.main(args.format(sphinxbuild,
                    fmt, self.builddir, sphinxopts, self.sourcedir).split())
开发者ID:aspidites,项目名称:ViCE,代码行数:30,代码来源:setup.py


示例6: build_docs

def build_docs(parser=None, options=None, args=None):
    """A script (openmdao build_docs) points to this.  It generates the Sphinx
    documentation for openmdao.
    """
    global _is_release
    if args and parser:
        print_sub_help(parser, 'build_docs')
        return -1

    if options is not None and hasattr(options, 'version') and options.version:
        version = options.version
        shtitle = 'OpenMDAO Documentation v%s' % version
        _is_release = True
    else:
        _is_release = False
        try:
            tag, ncommits, commit = get_rev_info()
            version = "%s-%s-%s" % (tag, ncommits, commit)
            shtitle = 'OpenMDAO Documentation (%s commits after version %s)' % (ncommits, tag)
        except:
            # try to get commit id
            try:
                top = get_ancestor_dir(sys.executable, 3)
                if '-OpenMDAO-Framework-' in top:
                    commit = top.split('-')[-1]
                    version = "dev - commit id: %s" % commit
                    shtitle = "OpenMDAO Documentation (commit id %s)" % commit
                else:
                    raise RuntimeError("can't find commit id")
            except:
                version = "?-?-?"
                shtitle = "OpenMDAO Documentation (unknown revision)"

    branchdir, docdir, bindir = _get_dirnames()

    startdir = os.getcwd()
    if not os.path.isdir(docdir):
        raise RuntimeError('doc directory '+docdir+' not found')

    _write_src_docs(branchdir, docdir)
    _make_license_table(docdir)

    os.chdir(docdir)
    try:
        # make necessary directories
        if os.path.isdir(os.path.join('_build', 'html')):
            shutil.rmtree(os.path.join('_build', 'html'), onerror=onerror)
        if os.path.isdir(os.path.join('_build', 'doctrees')):
            shutil.rmtree(os.path.join('_build', 'doctrees'), onerror=onerror)
        os.makedirs(os.path.join('_build', 'html'))
        os.makedirs(os.path.join('_build', 'doctrees'))

        sphinx.main(argv=['-P', '-b', 'html',
                          '-Dhtml_short_title=%s' % shtitle,
                          '-Dversion=%s' % version,
                          '-Drelease=%s' % version,
                          '-d', os.path.join(docdir, '_build', 'doctrees'),
                          docdir, os.path.join(docdir, '_build', 'html')])
    finally:
        os.chdir(startdir)
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:60,代码来源:build_docs.py


示例7: run

    def run(self):
        try:
            import sphinx
        except ImportError:
            log.info('Sphinx not installed -- skipping documentation. (%s)', sys.exc_info()[1])
            return

        if not os.path.exists(self.out_dir):
            if self.dry_run:
                self.announce('skipping creation of directory %s (dry run)' % self.out_dir)
            else:
                self.announce('creating directory %s' % self.out_dir)
                os.makedirs(self.out_dir)
        if self.dry_run:
            self.announce('skipping %s (dry run)' % ' '.join(self.sphinx_args))
        else:
            self.announce('running %s' % ' '.join(self.sphinx_args))
            opath = sys.path
            try:
                # We need to point Sphinx at the built library, including
                # the extension module so that autodoc works properly.
                sys.path.insert(0,os.path.realpath(self.build_lib))
                sphinx.main(self.sphinx_args)
            finally:
                sys.path = opath;
开发者ID:animesht,项目名称:python-rdma,代码行数:25,代码来源:setup.py


示例8: main

    def main(self, format):
        '''Create the documentation. 
        '''
        if format not in FORMATS:
            raise Exception, 'bad format'

        self.writeModuleReference()    
        self.writeGeneratedChapters()    
        self.writeContents()    

        if format == 'html':
            dirOut = self.dirBuildHtml
            pathLaunch = os.path.join(self.dirBuildHtml, 'contents.html')
        elif format == 'latex':
            dirOut = self.dirBuildLatex
            #pathLaunch = os.path.join(dirBuildHtml, 'contents.html')
        elif format == 'pdf':
            dirOut = self.dirBuildPdf
        else:
            raise Exception('undefined format %s' % format)

        if common.getPlatform() in ['darwin', 'nix', 'win']:
            # -b selects the builder
            import sphinx
            sphinxList = ['sphinx', '-E', '-b', format, '-d', self.dirBuildDoctrees,
                         self.dirRst, dirOut] 
            sphinx.main(sphinxList)
    
        if format == 'html':
            webbrowser.open(pathLaunch)
开发者ID:knuton,项目名称:music21,代码行数:30,代码来源:build.py


示例9: DoTask

    def DoTask(self):
        tmpDir = join(self.buildSetup.tmpDir, "chm")
        Prepare()
        #warnings.simplefilter('ignore', DeprecationWarning)
        sphinx.main([
            None,
            #"-a",
            "-b", "htmlhelp",
            "-E",
            "-P",
            "-D", "release=%s" % eg.Version.base,
            "-D", "templates_path=[]",
            "-d", EncodePath(join(self.buildSetup.tmpDir, ".doctree")),
            EncodePath(DOCS_SOURCE_DIR),
            tmpDir,
        ])

        print "calling HTML Help Workshop compiler"
        htmlHelpCompilerPath = GetHtmlHelpCompilerPath()
        if htmlHelpCompilerPath is None:
            raise Exception(
                "HTML Help Workshop command line compiler not found"
            )
        hhpPath = join(tmpDir, "EventGhost.hhp")
        StartProcess(htmlHelpCompilerPath, hhpPath)
        shutil.copy(join(tmpDir, "EventGhost.chm"), self.buildSetup.sourceDir)
开发者ID:garbear,项目名称:EventGhost,代码行数:26,代码来源:CreateDocs.py


示例10: run

    def run(self):
        # metadata contains information supplied in setup()
        metadata = self.distribution.metadata
        src_dir = (self.distribution.package_dir or {"": ""})[""]
        src_dir = os.path.join(os.getcwd(), src_dir)

        # Build docs from docstrings in *.py files
        sphinx.apidoc.main(["", "-e", "-o", os.path.join("docs", "source", "api"), src_dir])

        # Build the doc sources
        sphinx.main(
            [
                "",
                "-c",
                "docs",
                "-D",
                "project=" + metadata.name,
                "-D",
                "version=" + metadata.version,
                "-D",
                "release=" + metadata.version,
                os.path.join("docs", "source"),
                os.path.join("docs", "build"),
            ]
        )
开发者ID:antiface,项目名称:dspy,代码行数:25,代码来源:setup.py


示例11: build_docs

def build_docs(srcdir, destdir, confdir = None, page = None):
    current_dir = os.getcwd()
    os.chdir(srcdir)

    _build_destdir = destdir
    args = ['sphinx-build',                          # Fake argv[0]
            '-b', 'html',                            # Use the JSON builder
            '-q',                                    # Do not output anything on standard output, only write warnings and errors to standard error. 
            srcdir,                                  # Source file directory
            _build_destdir,                          # Destination directory
            ]
    
    if confdir:
        args.insert(1, confdir)
        args.insert(1, '-c')
    
    if page:
        args.append(os.path.join(srcdir, page.path))
    else:
        if os.path.exists(destdir):
            shutil.rmtree(destdir)
        if not os.path.exists(_build_destdir):
            os.makedirs(_build_destdir)
            
    import sphinx
    sphinx.main(args)
    os.chdir(current_dir)
开发者ID:ZoomQuiet,项目名称:openbookplatform,代码行数:27,代码来源:sphinx_handler.py


示例12: build_html_doc

    def build_html_doc(self):
        """Build the html documentation."""
        try:
            import sphinx
        except ImportError:
            self.warn("sphinx not found, documentation won't be build.")
            return

        sphinx_ver = sphinx.__version__
        def digits(x):
            res = re.match('\d+', x)
            if res is None:
                return 0
            else:
                return int(res.group())
        if map(digits, sphinx_ver.split('.')) < [0, 5, 1]:
            self.warn("Sphinx's version is too old (%s, expected at least "
                    "0.5.1, documentation won't be build." % sphinx_ver)
            return

        # Build the documentation just like it is done through the Makefile
        sphinx.main([__file__,
            "-b", "html",
            "-d", os.path.join(BASE_DOCS_DIR, 'doctrees'),
            os.path.join(BASE_DOCS_DIR, 'src'), DOCS_DIR])
开发者ID:umitproject,项目名称:zion,代码行数:25,代码来源:setup.py


示例13: run

    def run(self):
        # We import here to ensure that setup.py has had a chance to install the
        # relevant package eggs first.
        import sphinx
        import sphinx.apidoc

        metadata = self.distribution.metadata
        src_dir = os.path.join(PYTHON_STEM, self.distribution.package_dir[""], "grpc")
        sys.path.append(src_dir)
        sphinx.apidoc.main(
            [
                "",
                "--force",
                "--full",
                "-H",
                metadata.name,
                "-A",
                metadata.author,
                "-V",
                metadata.version,
                "-R",
                metadata.version,
                "-o",
                os.path.join("doc", "src"),
                src_dir,
            ]
        )
        conf_filepath = os.path.join("doc", "src", "conf.py")
        with open(conf_filepath, "a") as conf_file:
            conf_file.write(CONF_PY_ADDENDUM)
        sphinx.main(["", os.path.join("doc", "src"), os.path.join("doc", "build")])
开发者ID:liaorui,项目名称:grpc,代码行数:31,代码来源:commands.py


示例14: build

    def build(self, expected_return=0):
        print("")

        with mock.patch.object(sys, "exit") as mock_exit:
            sys.argv = ["sphinx-build", "-q", "-d", paths.doctree, "-b", "html", paths.root, paths.html]
            sphinx.main(sys.argv)
            mock_exit.assert_called_once_with(expected_return)
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:7,代码来源:utils.py


示例15: call_sphinx

 def call_sphinx(builder, workdir, extraopts=None):
     import sphinx
     if extraopts is None:
         extraopts = []
     if not options['--cache']:
         extraopts.append('-E')
     sphinx.main(['', '-b', builder] + extraopts +
                 [os.path.join(throot, 'doc'), workdir])
开发者ID:AlexArgus,项目名称:Theano,代码行数:8,代码来源:docgen.py


示例16: run

    def run(self):
        import sphinx, shutil, os
        if os.path.exists("docs/build/html"):
            shutil.rmtree("docs/build/html")

        self.mkpath("docs/build/html")

        sphinx.main(["-E", "docs", "docs/build/html"])
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:8,代码来源:setup.py


示例17: build

 def build(self, **kwargs):
     """ Run sphinx.main() with the correct arguments """
     try:
         import sphinx
     except ImportError as e:
         ui.error(e, "skipping build")
         return
     build_type = kwargs.get("build_type", None)
     language = kwargs.get("language", None)
     spellcheck = kwargs.get("spellcheck", False)
     werror = kwargs.get("werror", False)
     pdb = kwargs.get("pdb", False)
     if self.prebuild_script:
         ui.info(ui.green, "Running pre-build script:",
                 ui.white, self.prebuild_script)
         cmd = [sys.executable, self.prebuild_script]
         qisys.command.call(cmd, cwd=self.path)
         ui.info()
     self.generate_examples_zips()
     if self.translated and language and language != "en" \
             and language not in self.linguas:
         raise UnknownLingua(self, language)
     if self.translated:
         self.intl_build(language)
     qisys.sh.mkdir(self.html_dir, recursive=True)
     spell_dir = os.path.join(self.build_dir, "spellcheck")
     qisys.sh.mkdir(spell_dir, recursive=True)
     cmd = [sys.executable, "-c", self.build_dir]
     if spellcheck:
         cmd.extend(("-b", "spelling"))
     else:
         cmd.extend(("-b", "html"))
     if werror:
         cmd.append("-W")
     if language:
         cmd.append("-Dlanguage=%s" % language)
     if pdb:
         cmd.append("-P")
     cmd.append(self.source_dir)
     if spellcheck:
         cmd.append(spell_dir)
     else:
         cmd.append(self.html_dir)
     if build_type:
         os.environ["build_type"] = build_type
     ui.debug("launching:", cmd)
     rc = 0
     try:
         sphinx.main(argv=cmd)
     except SystemExit as e:
         rc = e.code
     if spellcheck:
         num_errors = get_num_spellcheck_errors(self.build_dir)
         if num_errors != 0:
             raise SphinxBuildError(self)
     if rc != 0:
         raise SphinxBuildError(self)
开发者ID:aldebaran,项目名称:qibuild,代码行数:57,代码来源:sphinx_project.py


示例18: sphinx_build

def sphinx_build(src_dir, build_dir):
    import sphinx
    sphinx.main((   'sphinx-build',  # Dummy 
                    '-b', 'html', 
                    '-d', os.path.join(build_dir, 'doctrees'),
                    src_dir,  # Source
                    os.path.join(build_dir, 'html'),  # Dest
                ))
    print("Build finished. The HTML pages are in %s/html." % build_dir)
开发者ID:tobyhijzen,项目名称:vispy,代码行数:9,代码来源:make.py


示例19: run

 def run(self):
     # metadata contains information supplied in setup()
     metadata = self.distribution.metadata
     # package_dir may be None, in that case use the current directory.
     src_dir = (self.distribution.package_dir or {'': ''})['']
     src_dir = os.path.join(os.getcwd(),  src_dir)
     import sphinx
     sphinx.main(['runme',
                 '-D', 'version=%s' % metadata.get_version(),
                 os.path.join('docs',), os.path.join(self.built_docs, 'docs')])
开发者ID:lnussel,项目名称:osc,代码行数:10,代码来源:setup.py


示例20: call_sphinx

 def call_sphinx(builder, workdir, extraopts=None):
     import sphinx
     if extraopts is None:
         extraopts = []
     if not options['--cache'] and files is None:
         extraopts.append('-E')
     docpath = os.path.join(throot, 'doc')
     inopt = [docpath, workdir]
     if files is not None:
         inopt.extend(files)
     sphinx.main(['', '-b', builder] + extraopts + inopt)
开发者ID:ballasn,项目名称:Theano,代码行数:11,代码来源:docgen.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python addnodes.compact_paragraph函数代码示例发布时间:2022-05-27
下一篇:
Python sphere.sim函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap