我正在为sphinx文档生成器的扩展工作。
我想添加一些html,js,css和json文件到html构建的文件。
它们不是模板的一部分,不应该受到sphinx模板中任何内容的影响。他们只是查看器的文件,我想添加到下载文件夹。(我也不知道怎么做。)
如何在sphinx扩展中包含额外的html文件?JS/CSS可以像在https://docs.readthedocs.io/en/latest/guides/adding-custom-css.html中描述的那样添加,但没有用于html的功能。
def setup(app):
app.add_stylesheet('css/custom.css')
app.add_javascript("js/custom.js")
# and custom html or any generic file ? 发布于 2018-07-24 03:47:36
conf.py中有一个html_static_path (它是路径列表)。在那里你可以添加静态文件(通过文件夹)。
以便动态地生成静态文件。没有显式的方式函数来添加静态文件。相反,静态文件可以直接由python复制到html_static_path。
在哪里可以找到html_static_path?
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相关的配置
https://stackoverflow.com/questions/51438493
复制相似问题