Sphinx autodoc不够自动化 [英] Sphinx autodoc is not automatic enough

查看:65
本文介绍了Sphinx autodoc不够自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Sphinx在Python中记录5,000多个项目。它有大约7个基本模块。据我所知,为了使用自动文档,我需要为项目中的每个文件编写如下代码:

I'm trying to use Sphinx to document a 5,000+ line project in Python. It has about 7 base modules. As far as I know, In order to use autodoc I need to write code like this for each file in my project:

.. automodule:: mods.set.tests
    :members:
    :show-inheritance:

这太麻烦了,因为我有很多文件。如果我只想指定要记录的 mods包,那就容易多了。然后,Sphinx可以递归地浏览该软件包,并为每个子模块创建一个页面。

This is way too tedious because I have many files. It would be much easier if I could just specify that I wanted the 'mods' package to be documented. Sphinx could then recursively go through the package and make a page for each submodule.

是否有类似的功能?如果不能,我可以编写一个脚本来制作所有.rst文件,但这将花费很多时间。

Is there a feature like this? If not I could write a script to make all the .rst files, but that would take up a lot of time.

推荐答案

您可以查看我制作的脚本。我认为它可以为您提供帮助。

You can check this script that I've made. I think it can help you.

此脚本解析目录树以查找python模块和软件包,并适当地创建ReST文件以使用Sphinx创建代码文档。

This script parses a directory tree looking for python modules and packages and creates ReST files appropriately to create code documentation with Sphinx. It also creates a modules index.

UPDATE

此脚本现在已成为一部分Sphinx 1.1的 apidoc

This script is now part of Sphinx 1.1 as apidoc.

这篇关于Sphinx autodoc不够自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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