构建完成,但查看文档链接断开

Build completed, but View Docs links broken

我已经安装了一个本地 ReadTheDocs 服务器,我认为我已经非常接近让它正常工作了。然而,虽然我的文档项目的构建表明它已完成,并且我可以在 readthedocs.org/media/html/cadd-faq/latest 目录下看到生成的文件,但来自构建页面的 View Docs 链接生成了一个 404 页面,其中包含以下调试信息.

Using the URLconf defined in readthedocs.urls, Django tried these URL patterns, in this order:

^$ [name='homepage'] 
^support/ [name='support'] 
^security/ 
^\.well-known/security.txt$ 
^search/$ [name='search'] 
^dashboard/ 
^profiles/ 
^accounts/ 
^accounts/ 
^notifications/ 
^accounts/gold/ 
^builds/ 
^500/$ 
^projects/ 
^api/v2/ 
^api/v2/docsearch/$ [name='doc_search'] 
^api/v2/search/$ [name='search_api'] 
^api-auth/ 
^api/v3/ 
^wipe/(?P<project_slug>(?:[-\w]+))/(?P<version_slug>(?:[a-z0-9A-Z][-._a-z0-9A-Z]*?))/$ [name='wipe_version'] 
^i18n/ 
^admin/ 
^media\/epub(?P<path>.*)$ 
^media\/htmlzip(?P<path>.*)$ 
^media\/json(?P<path>.*)$ 
^media\/pdf(?P<path>.*)$ 
style-catalog/$ 
^media/(?P<remainder>.+)$ [name='media-redirect'] 
^__debug__/ 

The current path, docs/cadd-faq/en/latest/, didn't match any of these.

我可以手动将浏览器指向 URL“.../media/html/cadd-faq/latest/index.html”,它重定向到“.../static/html/cadd-faq/latest/index.html" 并查看 sphinx 生成的内容,因此构建似乎真的成功了。但是这些页面没有 ReadTheDocs 包装内容,我希望查看文档按钮将我发送到这些内容,所以那些 URLs 当然也不是正确的。

这一切似乎表明问题出在我的 ReadTheDocs and/or Django 配置中。任何有关如何解决问题的指示都将不胜感激。

所以,如果您仍然支持我,请对我的安装发表一些评论。我相信我忠实地遵循了 https://docs.readthedocs.io/en/stable/custom_installs/local_rtd_vm.html (and associated pages), but of course, I could have blundered, as there were, in retrospect, some serious steps missing. The extremely helpful, and self answered, instructions at Read the Docs local install: Celery ValueError: signal only works in main thread 上的说明,通过它我得到了 redis 服务和 celery worker 运行,至少把我带到了一个地方,在那里我开始看到我的项目的构建页面有任何进展.

尽管如此,我还是需要执行几个步骤才能获得“构建完成”结果。首先,我必须修改 readthedocs.org/readthedocs/doc_builder/python_environments.py 文件以允许我在我的 local_settings.py 文件中指定一个 HTTP_PROXY 值,并将其发送到 pip 的 --proxy 参数安装。 (只是设置环境变量似乎不起作用。)其次,我不得不手动将 django-storages 包 pip 安装到 readthedocs.org/venv 环境中。第三,我必须在我的 sphinx conf.py 文件中添加一个 master_doc 规范来处理 readthedocs 认为默认 sphinx master_doc 是 contents.rst 的事实,但我们的版本sphinx 认为是 index.rst.

但这基本上就是我所做的一切,所以我看不出在我的配置中我会在哪里导致查看文档链接有错误 URL,或者我会在哪里删除“^ docs/" 来自 Django 正在寻找的模式。

我很乐意 post 我拥有的配置文件的副本,但恐怕我不确定 post 的相关文件是什么。让我知道哪些文件(包括我的 python_environments.py 代码更改的上下文差异)将有助于诊断我的问题,我将非常乐意在这里分享它们。

谢谢, 马尔科姆

自版本 5 以来,RTD 的行为发生了变化(请参阅 changelog)。文档曾经被同步以将构建的文档复制到 rtd-builds 文件夹,然后从 /public_web_root/ 文件夹链接到该文件夹​​。现在已经不是这样了。

从版本 5 开始,他们引入了一些名为 El Proxito 的代理中间件,它在 URL 传递给 nginx 之前拦截它,并代理它指向 /media/ 文件夹,就像你已经注意到,包含内置文档。

RTD 对自定义安装的支持一直很乏味,但现在情况更糟,因为他们没有更新文档来解释如何正确使用 El Proxito。 RTD 的开发人员使用 docker-compose 工作流来设置,但这有其自身的问题,并且该特定模块的 README 明确指出他们不建议将其用于自定义安装。所以,实际上,他们暂时让你一个人呆着。

我建议深入研究 El Proxito,并尝试将那个中间件安装到您的 Django 配置中,看看您是否可以让 url 代理工作。