Sphinx扩展,用于为Sphinx构建收集外部数据。
sphinx-collections的Python项目详细描述
完整文档:http://sphinx-collections.readthedocs.io/en/latest/
欢迎来到
Sphinx-Collections是一个Sphinx扩展,用于从不同的源收集和生成其他文件。 这些文件被添加到Sphinx源文件夹中,这样Sphinx就可以从整体上考虑它们 文档生成。在
Sphinx Collections支持多个集合,其中每个集合都有自己的集合 源和目标文件夹、特定配置和 use case based driver。在
默认情况下可以激活集合,也可以由Sphinx标记触发其使用。在
根据生成的特定集合的使用情况,其内容集成可以由 if-collection:: directive。在
支持以下用例:
- Create file with content from string
- Create file with content from function call
- Copy single file from local path
- Copy folder tree from local path
- Create a symlink to a local target
- Create a usage-report of collections
- Clone git repository
- Create multiple files based on jinja-template and specific data
Sphinx-Collections关心在每次生成前后保持集合文件夹的干净。在
简介
Sphinx-Collections完全由Sphinx项目的conf.py文件中的变量配置:
collections = { 'my_files': { 'driver': 'copy_folder', 'source': '../../extra_files/' } }
驱动程序copy_folder允许将本地文件夹及其文件复制到Sphinx项目中。 还有其他可用的驱动程序,它们支持不同的用例和文件位置。在
默认情况下,所有文件都被复制到_collections/+collection_name,因此在本例中,完整的路径 在您的文档文件夹中是_collections/my_files/。可以为每个位置设置特定的位置 使用target选项收集。在
然后可以使用目录树引用复制的文件:
^{pr2}$请看 documentation of the needed Driver 了解哪些选项是可用的和必要的。在
基于标记的集合
使用Sphinx标记只收集和集成所需的数据:
collections = { 'my_files': { 'driver': 'copy', 'source': '../../extra_files/', 'tags': ['user_manual'], # gets active, if "user_manual" is set as tag 'active': False, # by default, collection shall not be executed } }
然后使用-t选项运行sphinx-build:
sphinx-build -b html -t user_manual . _build/html
基于集合的内容
如果指定的集合已成功执行,则仅使用if-collection向页添加内容。在
..if-collection:: my_test, my_data My Test & Data chapter ---------------------- ..toctree:: /_collections/my_test/index /_collections/my_data/index
有关更多信息,请查看 documentation of if-collection。在
动机
这个sphinx扩展基于内部软件开发团队的需要 一家德国汽车公司。在
项目组正在寻找一种实用的方法来支持多个基于sphinx的文档 mono存储库,可以合并不同的文档或添加基于 在外部数据上。在
Sphinx Collections是软件包的一部分,该软件包旨在支持 ISO 26262兼容软件。 其他工具包括: sphinx-needs, sphinx-test-reports, tox-envreport。在
- 项目
标签: