我一直在使用Sphinx和reStructuredText记录软件包.
在我的文档中,有一些很长的代码片段.我希望能够将它们隐藏为默认值,并使用一个"显示/隐藏"按钮来扩展它们(示例).
有没有一种标准的方法可以做到这一点?
我想用我自己的自定义样式扩展Sphinx和ReadTheDocs使用的主题.
我能做到这一点的最佳方式是什么,以便我的改变能够坚持下去?
我有以下docstring:
def progress_bar(progress, length=20):
'''
Returns a textual progress bar.
>>> progress_bar(0.6)
'[##########--------]'
:param progress: Number between 0 and 1 describes the progress.
:type progress: float
:param length: The length of the progress bar in chars. Default is 20.
:type length: int
:rtype: string
'''
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉sphinx如果可用,将"Default is X"部分添加到参数的描述中?
有一种简单的方法来定制现有sphinxdoc主题吗?对于默认主题,有许多主题属性,但在sphinxdoc中,我甚至无法设置徽标或更改某些颜色?
或者你能推荐一个我可以学习如何修改主题的网站吗?
我已经为我想做的大部分事情找到了 sphinx 选项,但是在使用 autodoc 时,我看不到如何在函数签名之间注入空格和水平线。
以下是 autodoc 生成的内容:
get_all_edges(network=None, base_url='http://localhost:1234/v1')
docstring for get_all_edges
get_all_nodes(network=None, base_url='http://localhost:1234/v1')
docstring for get_all_nodes
get_edge_count(network=None, base_url='http://localhost:1234/v1')
docstring for get_edge_count
Run Code Online (Sandbox Code Playgroud)
这是我想要得到的:
get_all_edges(network=None, base_url='http://localhost:1234/v1')
docstring for get_all_edges
------------------------------------------------------------
get_all_nodes(network=None, base_url='http://localhost:1234/v1')
docstring for get_all_nodes
------------------------------------------------------------
get_edge_count(network=None, base_url='http://localhost:1234/v1')
docstring for get_edge_count
Run Code Online (Sandbox Code Playgroud)
......或接近于此的东西。我对最后一个函数签名是否有尾随分隔符不感兴趣。也许这很简单,但我没有看到。谢谢!
仅供参考,这里是生成我的函数签名的 autodoc 指令:
PyCy3.networks module
---------------------
.. automodule:: PyCy3.networks
:members:
:undoc-members:
:show-inheritance:
Run Code Online (Sandbox Code Playgroud)