简体   繁体   English

我可以在“阅读文档”中构建和托管自定义HTML页面吗?

[英]Can I build and host custom HTML pages at Read the Docs?

My program's documentation is mainly written in Sphinx , but it also includes two custom HTML pages: 我程序的文档主要是用Sphinx编写的,但是它还包括两个自定义HTML页面:

These two HTML files are produced by the program itself, not by Sphinx. 这两个HTML文件是由程序本身而不是Sphinx生成的。

I want to host my docs on Read the Docs , and it would be very convenient for me to build and host the two custom pages, versioned, together with the Sphinx docs. 我想将我的文档托管在Read the Docs上 ,这对我来说非常方便,可以与Sphinx文档一起构建和托管版本化的两个自定义页面。

My program is already installed in the RtD build environment as I have the Install Project option enabled. 由于启用了“ 安装项目”选项,因此我的程序已经安装在RtD构建环境中。 And since the RtD docs mention writing your own builder , I gather it might be possible to invoke my program from there and have it dump the HTML content in a specific place. 而且由于RtD文档提到编写您自己的构建器 ,所以我认为可以从那里调用我的程序并将它的HTML内容转储到特定位置。

So I really have two questions: 所以我真的有两个问题:

  1. Is this an appropriate use of Read the Docs? 这是否适合使用“阅读文档”? I guess it's not designed to host arbitrary Web pages — but then again, those files are not arbitrary, they are an important part of the docs. 我猜它不是设计来承载任意网页的,但是同样,那些文件也不是任意的,它们是文档的重要组成部分。

  2. How would I implement it? 我将如何实施? I'm having a hard time making sense of the RtD API : is this “builder” related in any way to Sphinx builders ? 我很难理解RtD API :这个“构建器”与Sphinx构建器有任何关系吗? how do I hook it up to RtD? 如何将其连接到RtD? perhaps there is an example somewhere? 也许某处有一个例子?

I achieved the desired result using Sphinx's html_extra_path feature: 我使用Sphinx的html_extra_path功能获得了预期的结果:

A list of paths that contain extra files [...] They are copied to the output directory. 包含多余文件的路径列表,这些文件已复制到输出目录。

To generate these files, I haven't found a better place than right in my conf.py , which seems a bit precarious, but works so far. 为了生成这些文件,我没有conf.py找到比正确的地方更好的地方了,这似乎有点conf.py可危,但到目前为止已经可以使用了。 Of course, Install your project inside a virtualenv needs to be enabled in Read the Docs advanced settings. 当然,需要在“阅读文档”高级设置中启用在virtualenv中安装项目

Now my custom notices.html and showcase.html are treated just like the .html pages produced by Sphinx itself, with versioning and redirects: http://httpolice.readthedocs.io/page/notices.html 现在,我的自定义notices.htmlshowcase.html就像Sphinx本身生成的.html页面一样,具有版本控制和重定向: http : //httpolice.readthedocs.io/page/notices.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM