【问题标题】:Remove package and module name from sphinx function从 sphinx 函数中删除包和模块名称
【发布时间】:2013-12-31 23:59:42
【问题描述】:

有什么方法可以从 sphinx doc 中删除包和/或模块名称?

示例:如果在模块 foo.bar 中存在一个名为 waa 的函数,则第一个代码

.. automodule:: foo.bar
    :members:

会生成

foo.bar.waa()

我想输出

waa()

【问题讨论】:

    标签: python-sphinx


    【解决方案1】:

    您可以在文件conf.py中将add_module_names更改为False

    # If true, the current module name will be prepended to all description
    # unit titles (such as .. function::).
    add_module_names = False
    

    然后foo.bar.my_function() 将显示为my_function()

    【讨论】:

    • 有没有办法在每个自动模块中执行此操作,而不是在 conf.py 级别?
    • 这适用于函数/模块/类本身,但不适用于带有类型注释的参数。见stackoverflow.com/q/51394955/965332
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    相关资源
    最近更新 更多