首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python-sphinx扩展,额外的html文件

python-sphinx扩展,额外的html文件
EN

Stack Overflow用户
提问于 2018-07-20 16:40:23
回答 1查看 620关注 0票数 0

我正在为sphinx文档生成器的扩展工作。

我想添加一些html,js,css和json文件到html构建的文件。

它们不是模板的一部分,不应该受到sphinx模板中任何内容的影响。他们只是查看器的文件,我想添加到下载文件夹。(我也不知道怎么做。)

如何在sphinx扩展中包含额外的html文件?JS/CSS可以像在https://docs.readthedocs.io/en/latest/guides/adding-custom-css.html中描述的那样添加,但没有用于html的功能。

代码语言:javascript
复制
def setup(app):
    app.add_stylesheet('css/custom.css')
    app.add_javascript("js/custom.js")
    # and custom html or any generic file ? 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-24 03:47:36

conf.py中有一个html_static_path (它是路径列表)。在那里你可以添加静态文件(通过文件夹)。

以便动态地生成静态文件。没有显式的方式函数来添加静态文件。相反,静态文件可以直接由python复制到html_static_path。

在哪里可以找到html_static_path?

代码语言:javascript
复制
class Node(nodes.TextElement):
    @staticmethod
    def visit_html(self, node), 
        self.document.settings.env.config.html_static_path

class Direc(Directive):
    def run(self):
        self.state.document.settings.env.config.html_static_path

另外,html_static_path是相对于

self.document.settings.env.app.confdir

和build dir可以通过以下方式获得

document.settings.env.app.builder.outdir

http://www.sphinx-doc.org/en/master/usage/configuration.html中有更多与html相关的配置

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51438493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档