由于提示,阅读文档构建失败

read-the-docs build fails because of prompt

我正在开发 Python package which, on first use, creates a config file for the user. During this setup phase, the user is asked for input during two prompts. Corresponding calls are in the module's __init__.py. Because of this prompt, my builds on readthedocs fail (log).

尽管如此,我如何构建我的文档?为什么 readthedocs 仍然试图编译代码?

问题是您正在 conf.py:

中导入模块
project_root = os.path.dirname(cwd)
sys.path.insert(0, project_root)

import scopus  # <-- imported

# General configuration
needs_sphinx = '1.3'
extensions = [

而且你的项目没有构建好。我不认为只导入你的模块会导致提示是个好主意。

import scopus  ->  
from scopus.utils import *  ->  
from scopus.utils.startup import *  ->    
....
if 'Authentication' not in config.sections():
    set_authentication(config, CONFIG_FILE)  # <-- cause prompt
....

此外,更糟糕的是:

CONFIG_FILE = os.path.expanduser("~/.scopus/config.ini")
config = configparser.ConfigParser()
config.optionxform = str
config.read(CONFIG_FILE)

正在读取文件系统。