栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

递归使用Sphinx自动生成API文档

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

递归使用Sphinx自动生成API文档

我最终需要以下文件:

modules.rst

API Reference=============.. rubric:: Modules.. autosummary::   :toctree: generated   sparse

_templates/autosummary/module.rst

{{ fullname | escape | underline }}.. rubric:: Description.. automodule:: {{ fullname }}.. currentmodule:: {{ fullname }}{% if classes %}.. rubric:: Classes.. autosummary::    :toctree: .    {% for class in classes %}    {{ class }}    {% endfor %}{% endif %}{% if functions %}.. rubric:: Functions.. autosummary::    :toctree: .    {% for function in functions %}    {{ function }}    {% endfor %}{% endif %}

_templates/autosummary/class.rst

{{ fullname | escape | underline}}.. currentmodule:: {{ module }}.. autoclass:: {{ objname }}   {% block methods %}   {% block attributes %}   {% if attributes %}   .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.      .. autosummary::         :toctree:      {% for item in all_attributes %}         {%- if not item.startswith('_') %}         {{ name }}.{{ item }}         {%- endif -%}      {%- endfor %}   {% endif %}   {% endblock %}   {% if methods %}   .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.      .. autosummary::         :toctree:      {% for item in all_methods %}         {%- if not item.startswith('_') or item in ['__call__'] %}         {{ name }}.{{ item }}         {%- endif -%}      {%- endfor %}   {% endif %}   {% endblock %}

_templates/autosummary/base.rst

{{ fullname | escape | underline}}.. currentmodule:: {{ module }}.. auto{{ objtype }}:: {{ objname }}

我还需要转到

sphinx/ext/autosummary/generate.py
并设置
imported_members=True
功能
generate_autosummary_docs

如果您

numpydoc
不像我一样使用,则可能需要删除
.. HACK
指令。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/574830.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号