相关疑难解决方法(0)

如何使用Sphinx记录Python包

我试图用Python记录一个包.目前我有以下目录结构:

.
??? project
    ??? _build
    ?   ??? doctrees
    ?   ??? html
    ?       ??? _sources
    ?       ??? _static
    ??? conf.py
    ??? index.rst
    ??? __init__.py
    ??? make.bat
    ??? Makefile
    ??? mod1
    ?   ??? foo.py
    ?   ??? __init__.py
    ??? mod2
    ?   ??? bar.py
    ?   ??? __init__.py
    ??? _static
    ??? _templates
Run Code Online (Sandbox Code Playgroud)

这棵树是射击的结果sphinx-quickstart.在conf.py我没有注释sys.path.insert(0, os.path.abspath('.')),我有extensions = ['sphinx.ext.autodoc'].

index.rst是:

.. FooBar documentation master file, created by
   sphinx-quickstart on Thu Aug 28 14:22:57 2014.
   You can adapt …
Run Code Online (Sandbox Code Playgroud)

python documentation packages python-sphinx

8
推荐指数
1
解决办法
2547
查看次数

python Sphinx“模块执行模块级语句,它可能会调用 sys.exit()。”

我尝试使用 Sphinx 来记录我的代码。但我看到错误:

模块执行模块级语句,它可能会调用 sys.exit()。

我发现这个错误与代码有关:

import argparse
# parse command line arguments
parser = argparse.ArgumentParser(description='AWS VPN status checker.')
parser.add_argument('account', type=str, help='AWS account name.')
parser.add_argument('region', type=str, help='region of VPN tunnel.')
parser.add_argument('ipaddress', type=str, help='Tunnel IP address.')
parser.add_argument("-d", "--debug", help="debug", action="store_true")
args = parser.parse_args()
Run Code Online (Sandbox Code Playgroud)

我认为这与导入模块时的“副作用”有关。

为什么不好,我该如何解决?

python argparse python-sphinx

8
推荐指数
1
解决办法
3283
查看次数

sphinx是否在执行'make html'时运行我的代码?

我继承了一个相当大的代码库,我想为它创建html文档.由于它是用Python编写的,所以我决定使用sphinx,因为代码的用户习惯于使用sphinx创建的python文档的设计和功能.我使用该命令sphinx-apidoc自动创建rst文件.我导入了模块路径,sys.path以便sphinx可以找到代码.

到现在为止还挺好.但是,当我尝试使用该命令创建html时make html,会弹出许多回溯,并且代码库中的一些示例似乎已被执行.可能是什么原因以及如何防止这种情况发生?

python documentation python-sphinx

6
推荐指数
1
解决办法
3436
查看次数