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


Python Theme.get_options方法代码示例

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


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

示例1: StandaloneHTMLBuilder

# 需要导入模块: from sphinx.theming import Theme [as 别名]
# 或者: from sphinx.theming.Theme import get_options [as 别名]

#.........这里部分代码省略.........
            stylename = self.config.html_style
        elif self.theme:
            stylename = self.theme.get_confstr('theme', 'stylesheet')
        else:
            stylename = 'default.css'

        self.globalcontext = dict(
            embedded = self.embedded,
            project = self.config.project,
            release = self.config.release,
            version = self.config.version,
            last_updated = self.last_updated,
            copyright = self.config.copyright,
            master_doc = self.config.master_doc,
            use_opensearch = self.config.html_use_opensearch,
            docstitle = self.config.html_title,
            shorttitle = self.config.html_short_title,
            show_sphinx = self.config.html_show_sphinx,
            has_source = self.config.html_copy_source,
            show_source = self.config.html_show_sourcelink,
            file_suffix = self.out_suffix,
            script_files = self.script_files,
            sphinx_version = __version__,
            style = stylename,
            rellinks = rellinks,
            builder = self.name,
            parents = [],
            logo = logo,
            favicon = favicon,
        )
        if self.theme:
            self.globalcontext.update(
                ('theme_' + key, val) for (key, val) in
                self.theme.get_options(
                self.config.html_theme_options).iteritems())
        self.globalcontext.update(self.config.html_context)

    def get_doc_context(self, docname, body, metatags):
        """Collect items for the template context of a page."""
        # find out relations
        prev = next = None
        parents = []
        rellinks = self.globalcontext['rellinks'][:]
        related = self.relations.get(docname)
        titles = self.env.titles
        if related and related[2]:
            try:
                next = {
                    'link': self.get_relative_uri(docname, related[2]),
                    'title': self.render_partial(titles[related[2]])['title']
                }
                rellinks.append((related[2], next['title'], 'N', _('next')))
            except KeyError:
                next = None
        if related and related[1]:
            try:
                prev = {
                    'link': self.get_relative_uri(docname, related[1]),
                    'title': self.render_partial(titles[related[1]])['title']
                }
                rellinks.append((related[1], prev['title'], 'P', _('previous')))
            except KeyError:
                # the relation is (somehow) not in the TOC tree, handle
                # that gracefully
                prev = None
        while related and related[0]:
开发者ID:89sos98,项目名称:main,代码行数:70,代码来源:html.py

示例2: ChangesBuilder

# 需要导入模块: from sphinx.theming import Theme [as 别名]
# 或者: from sphinx.theming.Theme import get_options [as 别名]

#.........这里部分代码省略.........
                    entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext,
                                                          context)
                else:
                    entry = '<b>%s</b>: <i>%s</i>.' % (descname, ttext)
                apichanges.append((entry, docname, lineno))
            elif descname or module:
                if not module:
                    module = _('Builtins')
                if not descname:
                    descname = _('Module level')
                if context:
                    entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext,
                                                          context)
                else:
                    entry = '<b>%s</b>: <i>%s</i>.' % (descname, ttext)
                libchanges.setdefault(module, []).append((entry, docname,
                                                          lineno))
            else:
                if not context:
                    continue
                entry = '<i>%s:</i> %s' % (ttext.capitalize(), context)
                title = self.env.titles[docname].astext()
                otherchanges.setdefault((docname, title), []).append(
                    (entry, docname, lineno))

        ctx = {
            'project': self.config.project,
            'version': version,
            'docstitle': self.config.html_title,
            'shorttitle': self.config.html_short_title,
            'libchanges': sorted(iteritems(libchanges)),
            'apichanges': sorted(apichanges),
            'otherchanges': sorted(iteritems(otherchanges)),
            'show_copyright': self.config.html_show_copyright,
            'show_sphinx': self.config.html_show_sphinx,
        }
        f = codecs.open(path.join(self.outdir, 'index.html'), 'w', 'utf8')
        try:
            f.write(self.templates.render('changes/frameset.html', ctx))
        finally:
            f.close()
        f = codecs.open(path.join(self.outdir, 'changes.html'), 'w', 'utf8')
        try:
            f.write(self.templates.render('changes/versionchanges.html', ctx))
        finally:
            f.close()

        hltext = ['.. versionadded:: %s' % version,
                  '.. versionchanged:: %s' % version,
                  '.. deprecated:: %s' % version]

        def hl(no, line):
            line = '<a name="L%s"> </a>' % no + htmlescape(line)
            for x in hltext:
                if x in line:
                    line = '<span class="hl">%s</span>' % line
                    break
            return line

        self.info(bold('copying source files...'))
        for docname in self.env.all_docs:
            f = codecs.open(self.env.doc2path(docname), 'r',
                            self.env.config.source_encoding)
            try:
                lines = f.readlines()
            except UnicodeDecodeError:
                self.warn('could not read %r for changelog creation' % docname)
                continue
            finally:
                f.close()
            targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
            ensuredir(path.dirname(targetfn))
            f = codecs.open(targetfn, 'w', 'utf-8')
            try:
                text = ''.join(hl(i+1, line) for (i, line) in enumerate(lines))
                ctx = {
                    'filename': self.env.doc2path(docname, None),
                    'text': text
                }
                f.write(self.templates.render('changes/rstsource.html', ctx))
            finally:
                f.close()
        themectx = dict(('theme_' + key, val) for (key, val) in
                        iteritems(self.theme.get_options({})))
        copy_static_entry(path.join(package_dir, 'themes', 'default',
                                    'static', 'default.css_t'),
                          self.outdir, self, themectx)
        copy_static_entry(path.join(package_dir, 'themes', 'basic',
                                    'static', 'basic.css'),
                          self.outdir, self)

    def hl(self, text, version):
        text = htmlescape(text)
        for directive in ['versionchanged', 'versionadded', 'deprecated']:
            text = text.replace('.. %s:: %s' % (directive, version),
                                '<b>.. %s:: %s</b>' % (directive, version))
        return text

    def finish(self):
        pass
开发者ID:861008761,项目名称:standard_flask_web,代码行数:104,代码来源:changes.py

示例3: StandaloneHTMLBuilder

# 需要导入模块: from sphinx.theming import Theme [as 别名]
# 或者: from sphinx.theming.Theme import get_options [as 别名]

#.........这里部分代码省略.........
        else:
            stylename = 'default.css'

        self.globalcontext = dict(
            embedded = self.embedded,
            project = self.config.project,
            release = self.config.release,
            version = self.config.version,
            last_updated = self.last_updated,
            copyright = self.config.copyright,
            master_doc = self.config.master_doc,
            use_opensearch = self.config.html_use_opensearch,
            docstitle = self.config.html_title,
            shorttitle = self.config.html_short_title,
            show_copyright = self.config.html_show_copyright,
            show_sphinx = self.config.html_show_sphinx,
            has_source = self.config.html_copy_source,
            show_source = self.config.html_show_sourcelink,
            file_suffix = self.out_suffix,
            script_files = self.script_files,
            language = self.config.language,
            css_files = self.css_files,
            sphinx_version = __display_version__,
            style = stylename,
            rellinks = rellinks,
            builder = self.name,
            parents = [],
            logo = logo,
            favicon = favicon,
        )
        if self.theme:
            self.globalcontext.update(
                ('theme_' + key, val) for (key, val) in
                iteritems(self.theme.get_options(self.theme_options)))
        self.globalcontext.update(self.config.html_context)

    def get_doc_context(self, docname, body, metatags):
        """Collect items for the template context of a page."""
        # find out relations
        prev = next = None
        parents = []
        rellinks = self.globalcontext['rellinks'][:]
        related = self.relations.get(docname)
        titles = self.env.titles
        if related and related[2]:
            try:
                next = {
                    'link': self.get_relative_uri(docname, related[2]),
                    'title': self.render_partial(titles[related[2]])['title']
                }
                rellinks.append((related[2], next['title'], 'N', _('next')))
            except KeyError:
                next = None
        if related and related[1]:
            try:
                prev = {
                    'link': self.get_relative_uri(docname, related[1]),
                    'title': self.render_partial(titles[related[1]])['title']
                }
                rellinks.append((related[1], prev['title'], 'P', _('previous')))
            except KeyError:
                # the relation is (somehow) not in the TOC tree, handle
                # that gracefully
                prev = None
        while related and related[0]:
            try:
开发者ID:Titan-C,项目名称:sphinx,代码行数:70,代码来源:html.py

示例4: StandaloneHTMLBuilder

# 需要导入模块: from sphinx.theming import Theme [as 别名]
# 或者: from sphinx.theming.Theme import get_options [as 别名]

#.........这里部分代码省略.........
            stylename = self.theme.get_confstr('theme', 'stylesheet')
        else:
            stylename = 'default.css'

        self.globalcontext = dict(
            embedded = self.embedded,
            project = self.config.project,
            release = self.config.release,
            version = self.config.version,
            last_updated = self.last_updated,
            copyright = self.config.copyright,
            master_doc = self.config.master_doc,
            use_opensearch = self.config.html_use_opensearch,
            docstitle = self.config.html_title,
            shorttitle = self.config.html_short_title,
            show_copyright = self.config.html_show_copyright,
            show_sphinx = self.config.html_show_sphinx,
            has_source = self.config.html_copy_source,
            show_source = self.config.html_show_sourcelink,
            file_suffix = self.out_suffix,
            script_files = self.script_files,
            css_files = self.css_files,
            sphinx_version = __version__,
            style = stylename,
            rellinks = rellinks,
            builder = self.name,
            parents = [],
            logo = logo,
            favicon = favicon,
        )
        if self.theme:
            self.globalcontext.update(
                ('theme_' + key, val) for (key, val) in
                self.theme.get_options(self.theme_options).iteritems())
        self.globalcontext.update(self.config.html_context)

    def get_doc_context(self, docname, body, metatags):
        """Collect items for the template context of a page."""
        # find out relations
        prev = next = None
        parents = []
        rellinks = self.globalcontext['rellinks'][:]
        related = self.relations.get(docname)
        titles = self.env.titles
        if related and related[2]:
            try:
                next = {
                    'link': self.get_relative_uri(docname, related[2]),
                    'title': self.render_partial(titles[related[2]])['title']
                }
                rellinks.append((related[2], next['title'], 'N', _('next')))
            except KeyError:
                next = None
        if related and related[1]:
            try:
                prev = {
                    'link': self.get_relative_uri(docname, related[1]),
                    'title': self.render_partial(titles[related[1]])['title']
                }
                rellinks.append((related[1], prev['title'], 'P', _('previous')))
            except KeyError:
                # the relation is (somehow) not in the TOC tree, handle
                # that gracefully
                prev = None
        while related and related[0]:
            try:
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:70,代码来源:html.py

示例5: ChangesBuilder

# 需要导入模块: from sphinx.theming import Theme [as 别名]
# 或者: from sphinx.theming.Theme import get_options [as 别名]

#.........这里部分代码省略.........
        version = self.config.version
        libchanges = {}
        apichanges = []
        otherchanges = {}
        if version not in self.env.versionchanges:
            self.info(bold("no changes in version %s." % version))
            return
        self.info(bold("writing summary file..."))
        for type, docname, lineno, module, descname, content in self.env.versionchanges[version]:
            if isinstance(descname, tuple):
                descname = descname[0]
            ttext = self.typemap[type]
            context = content.replace("\n", " ")
            if descname and docname.startswith("c-api"):
                if not descname:
                    continue
                if context:
                    entry = "<b>%s</b>: <i>%s:</i> %s" % (descname, ttext, context)
                else:
                    entry = "<b>%s</b>: <i>%s</i>." % (descname, ttext)
                apichanges.append((entry, docname, lineno))
            elif descname or module:
                if not module:
                    module = _("Builtins")
                if not descname:
                    descname = _("Module level")
                if context:
                    entry = "<b>%s</b>: <i>%s:</i> %s" % (descname, ttext, context)
                else:
                    entry = "<b>%s</b>: <i>%s</i>." % (descname, ttext)
                libchanges.setdefault(module, []).append((entry, docname, lineno))
            else:
                if not context:
                    continue
                entry = "<i>%s:</i> %s" % (ttext.capitalize(), context)
                title = self.env.titles[docname].astext()
                otherchanges.setdefault((docname, title), []).append((entry, docname, lineno))

        ctx = {
            "project": self.config.project,
            "version": version,
            "docstitle": self.config.html_title,
            "shorttitle": self.config.html_short_title,
            "libchanges": sorted(libchanges.iteritems()),
            "apichanges": sorted(apichanges),
            "otherchanges": sorted(otherchanges.iteritems()),
            "show_copyright": self.config.html_show_copyright,
            "show_sphinx": self.config.html_show_sphinx,
        }
        f = codecs.open(path.join(self.outdir, "index.html"), "w", "utf8")
        try:
            f.write(self.templates.render("changes/frameset.html", ctx))
        finally:
            f.close()
        f = codecs.open(path.join(self.outdir, "changes.html"), "w", "utf8")
        try:
            f.write(self.templates.render("changes/versionchanges.html", ctx))
        finally:
            f.close()

        hltext = [".. versionadded:: %s" % version, ".. versionchanged:: %s" % version, ".. deprecated:: %s" % version]

        def hl(no, line):
            line = '<a name="L%s"> </a>' % no + htmlescape(line)
            for x in hltext:
                if x in line:
                    line = '<span class="hl">%s</span>' % line
                    break
            return line

        self.info(bold("copying source files..."))
        for docname in self.env.all_docs:
            f = codecs.open(self.env.doc2path(docname), "r", self.env.config.source_encoding)
            try:
                lines = f.readlines()
            finally:
                f.close()
            targetfn = path.join(self.outdir, "rst", os_path(docname)) + ".html"
            ensuredir(path.dirname(targetfn))
            f = codecs.open(targetfn, "w", "utf-8")
            try:
                text = "".join(hl(i + 1, line) for (i, line) in enumerate(lines))
                ctx = {"filename": self.env.doc2path(docname, None), "text": text}
                f.write(self.templates.render("changes/rstsource.html", ctx))
            finally:
                f.close()
        themectx = dict(("theme_" + key, val) for (key, val) in self.theme.get_options({}).iteritems())
        copy_static_entry(
            path.join(package_dir, "themes", "default", "static", "default.css_t"), self.outdir, self, themectx
        )
        copy_static_entry(path.join(package_dir, "themes", "basic", "static", "basic.css"), self.outdir, self)

    def hl(self, text, version):
        text = htmlescape(text)
        for directive in ["versionchanged", "versionadded", "deprecated"]:
            text = text.replace(".. %s:: %s" % (directive, version), "<b>.. %s:: %s</b>" % (directive, version))
        return text

    def finish(self):
        pass
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:104,代码来源:changes.py


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