如何使用 Sphinx 管理多个版本的文档? [英] How to manage multiple versions of documentation with Sphinx?

查看:42
本文介绍了如何使用 Sphinx 管理多个版本的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护一个用 C++ 编写的小型库项目.我想使用 Sphinx 来维护每个发布版本的库网站 + 用户文档.我发现[类似的问题问如何管理多个版本?sphinx-dev 邮件列表 我碰到过,但没有进行广泛的跟进.

I maintain a small library project written in C++. I'd like to use Sphinx to maintain the library website + user documentation per release version. I have found [similar question asked How to manage many versions? on the sphinx-dev mailing list which I have bumped but without extensive follow-up.

如何管理多个版本?

我认为基本结构是这样的:

I think of basic structure like this:

mylib/     <- website root
mylib/...
mylib/tutorial/...
mylib/doc   <- list of documentation per release version
mylib/doc/1.0.0
mylib/doc/2.0.0
mylib/doc/X.Y.Z

我正在尝试找出此结构的最佳实用配置.我有根配置 mylib/conf.py,我可以在其中控制网站结构和内容.

I'm trying to figure out best practical configuration for this structure. I have root configuration mylib/conf.py where I control the website structure and content.

我可以将 .rst 文件放入 mylib/doc/1.0.0mylib/doc/2.0.0 使用根 conf.py 构建它们.但是,控制网站和文档的目录树似乎很棘手.

I could put .rst files into mylib/doc/1.0.0 and mylib/doc/2.0.0 build them using the root conf.py. But then it seems tricky to control toctree for website and for docs.

因此,我认为将网站配置/构建与每个发布文档的配置/构建分开可能更实用:

So, I think it may be more practical to separate website config/build from per release documentation config/builds:

mylib/conf.py
mylib/doc/1.0.0/conf.py
mylib/doc/2.0.0/conf.py
mylib/doc/X.Y.Z/conf.py

但我希望mylib/doc/XYZ/conf.py中的主要文件使用与mylib/中的根文件相同的布局,所以我可以有一致的外观,例如页眉等中的链接

but I'd like the main documents in mylib/doc/X.Y.Z/conf.py to use the same layout is the root documents in mylib/, so I can have consistent look, e.g. links in page header, etc.

通过这种方式,我可以轻松实现每个文档版本的一致 toctree.应该很容易浏览目录并分别为网站和每个文档版本执行构建.

This way I can easily achieve consistent toctree per documentation release. It should be easy to walk the directories and perform builds for website and for each doc version separately.

关于搜索文档,我不介意搜索引擎扫描每个查询的所有版本的文档,也不介意搜索引擎特定于特定版本(搜索框显示在同一位置,但根据正在读取的内容,它仅扫描当前版本的索引).

Regarding searching the documentation, I don't mind the search engine to scan all versions of documentation per single query as well as I don't mind to have search engine specific to particular version (search box is displayed in the same place, but depending what is being read, it scans index of current version only).

有没有更好的方法来实现这一目标?

Is there any better way to achieve that?

我在 sphinx 中发现了类似的问题,用于多个单独的文档 和我想知道 Intersphinx 插件 是否是一个好主意.

I've found similar question asked in sphinx for multiple, separate documents and I'm wondering if the Intersphinx plugin is a good idea here.

更新:

  • 2017-04-10:SO 答案指向一个有趣的 Sphinx 扩展:sphinxcobtrib-versioning
  • 2011-10-21:在评论中关注 olt 的问题,mylib/不是我想在 VCS 中构建项目的意思.所以,我不想在 VCS 中维护多个版本的文档.mylib/ 只是为了更容易可视化的结构.它也可以是我将 Sphinx 源放在一起的工作目录(例如,从版本分支中提取等)以及我启动 Sphinx 以构建输出的位置.
  • 2017-04-10: SO answer pointing to an interesting Sphinx extension: sphinxcobtrib-versioning
  • 2011-10-21: Following olt's question in comments, mylib/ is not how I mean to structure project in VCS. So, I don't want to maintain multiple versions of documentation in VCS. The mylib/ is just structure for easier visualisation. It can be also working directory where I put Sphinx sources together (e.g. pull from version branches, etc.) and where I launch Sphinx to build the output.

推荐答案

在我看来,文档应该与代码放在同一个存储库中.否则,您将需要手动管理文档源,例如当您将功能从版本 B 向后移植到 A 时.使用单个存储库,您只需检查该版本并重新构建文档.

In my opinion, the documentation should stay with the code in the same repository. Otherwise you would need to manage the documentation source manually, for example when you backport a feature from version B to A. With a single repository, you just check out that version and re-build the documentation.

您应该查看 SQLAlchemy 项目,他们在同一站点上提供了多个版本的文档.文档位于同一个存储库中,他们复制输出 每个版本的静态主页文件夹.

You should look at SQLAlchemy project, they have multiple versions of their documentation available on the same site. The documentation is in the same repository and they copy the output of each version into their static homepage folders.

这篇关于如何使用 Sphinx 管理多个版本的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆