jhp*_*jhp 5 python documentation inheritance python-sphinx
我正在使用sphinx生成我的文档,自动摘要扩展负责为所有未由我自己明确编写的类生成小桩。
以该类为例,Foo并假定它具有一个mixin Base,它可以为存储添加更多的非常基本的方法。它们不是私有的,因为它们可能会被使用,但只有1%的用户使用。我使用的几乎所有类中都存在一个mixin。要点是,必要的但必须在所有类中进行记录的mixin只会使文档混乱,我只想提及在类描述中使用Base mixin,但隐藏了实际的方法和属性。
使用autodoc可以使用自定义删除记录这些功能的文档autodoc-skip-member。这是可行的,但只会影响每种方法的扩展文档,而不会在一开始就影响继承的方法。
现在,自动摘要会将所有这些内容放入存根,并且不使用任何自动文档设置。我修改了自动摘要代码以实际执行我想要的操作,但这确实不是很优雅。
我的问题是:
生成的内容如下所示
foo.Foo
=======
.. currentmodule:: foo
.. autoclass:: foo
.. automethod:: __init__
.. rubric:: Methods
.. autosummary::
~Foo.method1
~Foo.method2
~Foo.inherited_method_from_Base1 # remove
~Foo.inherited_method_from_Base2 # remove
.. rubric:: Attributes
.. autosummary::
~Foo.attribute1
~Foo.attribute2
~Foo.inherited_attribute_from_Base1 # remove
~Foo.inherited_attribute_from_Base2 # remove
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
516 次 |
| 最近记录: |