Django 中 .rst 文档的多页 html 输出
我正在编写一个 Django 应用程序来提供一些用 RestructedText 编写的文档。 我有很多用 *.rst 编写的文档,每个文档都很长,有很多节、小节等等。
使用 Django 过滤器在单个页面中显示整个文档不是问题,但我宁愿在第一页上只显示主题索引,并链接到一个 URL,在其中我可以显示单个部分/子部分(这将需要一些我猜是“上一页 | 上一页 | 下一页”链接...)。其方式类似于文档/XML 到 HTML 转换中的“多个 HTML 页面输出”。
谁能给我指出一些方向来构建 *.rst 文档的文档树并解析它的单个部分,或者建议一种巧妙的方法来获得类似的结果?
I'm writing a Django app to serve some documentation written in RestructuredText.
I have many documents written in *.rst, each of them is quite long with many section, subsection and so on.
Display the whole document in a single page is not a problem using Django filters, but I'd rather have just the topic index on a first page, whit links to an URL where I can display a single section / subsection (which will need some 'previous | up | home | next' link I guess...). In a way similar to a 'multiple HTML page output' as in a docbook / XML to HTML conversion.
Can anyone point me to some direction to build a document tree of a *.rst document an parse a single section of it, or suggest a clever way to obtain a similar result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择 1. 包含指向文档其他部分的 URL 链接。
您编写一个index.rst、part1.rst、part2.rst 等。您的index.rst 具有指向其他部分的链接。除了仔细规划以确保您的 RST HTML 链接正确之外,这几乎不需要任何工作。
没有“解析”。您只需将文档分成几个部分即可。手动。
[这似乎很明显,我不敢提及。]
选择2.使用Sphinx。它可以很好地管理目录和文档间连接。
但是,Sphinx 对 RST 的扩展不是由 Django 直接处理的,因此您需要保存 Sphinx 输出,然后在 Django 中显示它。我们使用 JSON HTML Builder (http://sphinx .pocoo.org/builders.html?highlight=json#sphinx.builders.html.JSONHTMLBuilder) 来自 Sphinx 的输出。然后我们通过模板渲染这些文档。
Choice 1. Include URL links to the other parts of the document.
You write an index.rst, part1.rst, part2.rst, etc. And your index.rst has links to the other parts. This requires almost no work, except careful planning to make sure that your RST HTML links are correct.
There's no "parse". You just break your document into sections. Manually.
[This seems so obvious, I'm afraid to mention it.]
Choice 2. Use Sphinx. It manages table-of-contents and inter-document connections very nicely.
However, the Sphinx extensions to RST aren't handled directly by Django, so you'd need to save the Sphinx output and then display that in Django. We use the JSON HTML Builder (http://sphinx.pocoo.org/builders.html?highlight=json#sphinx.builders.html.JSONHTMLBuilder) output from Sphinx. Then we render these documents through a template.