我希望创建一个single_html.rst
包含我所有的文件class
/method
/attribute
/etc... ,还可以将分类符号拆分到单独的页面中。
e.g.
single_html.rst
.. single html
.. include:: foo.rst
.. include:: bar.rst
bar.rst
.. autoclass:: my.mod.Bar
:members:
foo.rst
.. autoclass:: my.mod.Foo
:members:
这会抛出多个duplicate object description
errors:
/path/to/project/my/mod.py:my.module.Bar:0 的文档字符串:警告:my.mod.Bar 的重复对象描述,/path/to/project/docs/source/api 中的其他实例/single_html.rst,对其中之一使用 :noindex:
/path/to/project/my/mod.py:my.module.Bar:0 的文档字符串:警告:my.mod.Foo 的重复对象描述,/path/to/project/docs/source/api 中的其他实例/single_html.rst,对其中之一使用 :noindex:
我不能简单地放置:noindex:
on the autoclass::
指令,因为这将完全删除所有索引。 (所以要么有重复的索引,要么根本没有!)
有一个更好的方法吗?
您可以通过更改包含文件的扩展名来避免这些警告。
狮身人面像考虑每一个.rst
(默认情况下,可以在conf.py
文件)作为“解析源”文件。所以它会尝试解析foo.rst
和bar.rst
文件并找到autodoc
指令my.mod.Foo
and my.mod.Bar
。
当它尝试解析时single_html.rst
,它首先包含的内容foo.rst
and bar.rst
;因此,它会再次找到指令my.mod.Foo
and my.mod.Bar
.
通过重命名foo.rst
and bar.rst
to foo.inc
and bar.inc
(任何你想要的扩展名),你将阻止 Sphinx 解析包含的文件并避免警告。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)