sphinx在构建期间不包含源代码

Sri*_*Sri 11 python python-sphinx

我试图使用Sphinx 1.2.1记录我的python包.

我对第一个文件的定义包含有关每个模块的一些描述,用法以及为重构文本添加autodoc语法,如下所示.

module
------

.. automodule:: RAT.REPORTER.bemrstcreator
    :members:
    :undoc-members:
    :show-inheritance:
Run Code Online (Sandbox Code Playgroud)

上面的设置为我做了一个明确的html构建没有任何问题.它从所有类及其相关成员等派生文档,但它包含html中的源代码.如何指示sphinx不链接每个模块的源代码?

小智 13

您可以在config.py文件上找到下一个配置值,并将其设置为false:

html_show_sourcelink = False
Run Code Online (Sandbox Code Playgroud)


Sri*_*Sri 6

在conf.py中,对特定文档进行所有修改后,删除sphinx.ext.viewcode扩展名.

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'rst2pdf.pdfbuilder'
]
Run Code Online (Sandbox Code Playgroud)

以上修改为

extensions = [
    'sphinx.ext.autodoc',
    'rst2pdf.pdfbuilder'
]
Run Code Online (Sandbox Code Playgroud)