简体   繁体   English

文档字符串未填充 Sphinx 文档

[英]Docstrings not populating Sphinx documentation

I am trying to generate Sphinx documentation for my Python application.我正在尝试为我的 Python 应用程序生成 Sphinx 文档。 Originally I had a complex structure as follows...最初我有一个复杂的结构如下......

venv
docs
├───source
├───├───_static
├───├───_templates
├───├───conf.py
├───├───index.rst
├───├───modules.rst
├───├───...
├───build
├───make.bat
├───Makefile
├───MyCode
├───├───Utilities
│   │   └───class1.py
├───├───Configurations
│   │   ├───Archive
│   │   ├───API1_Configurations
│   │   │   ├───Config1.ini
│   │   ├───API2_Configurations
│   │   │   ├───Config2.ini
│   │   ├───API3_Configurations
│   │   │   ├───Config3.ini
│   │   ├───API4_Configurations
│   │   │   ├───Config4.ini
├───├───APIs
│   │   ├───API1
│   │   │   ├───Class1.py
│   │   │   ├───Class2.py
│   │   ├───API2
│   │   │   ├───Class1.py
│   │   │   ├───Class2.py
│   │   │   ├───Supporting
│   │   │   │   └───Class1.py
│   │   ├───API3
│   │   │   ├───Support
│   │   │   │   ├───SupportPackage1
│   │   │   │   ├───Support Package2
│   │   │   │   │   └───Class1.py
│   │   │   │   └───__pycache__
│   │   │   └───Class1.py

In this case, my source code exists in ./docs/MyCode.在这种情况下,我的源代码存在于 ./docs/MyCode 中。

I am using...我在用...

  • Python 3.8蟒蛇 3.8
  • Sphinx 4.2 (although I've tried with many versions) Sphinx 4.2(虽然我尝试过很多版本)
  • NumPy docstrings NumPy 文档字符串

I have...我有...

  • Added the following extensions添加了以下扩展
    • sphinx.ext.autodoc
    • sphinx.ext.apidoc
    • sphinx.ext.napoleon
  • Pointed conf.py to my code using both a relative path and absolute path (relative path being ../MyCode ).conf.py我的代码同时使用相对路径和绝对路径(相对路径之中../MyCode )。

For some reason, the closest I can get to actually populating the HTML pages with my documentation is simply having the classes in the index toctree .出于某种原因,我最接近实际使用我的文档填充 HTML 页面的方法就是将类放在索引toctree They link out to blank html pages without my Python docstrings.它们链接到没有我的 Python 文档字符串的空白 html 页面。

Does anyone have any idea why it won't grab my docstrings??有谁知道为什么它不会抓取我的文档字符串?

Ok... feeling pretty dumb about this, but it was just cause of the warnings.好吧……对此感觉很愚蠢,但这只是警告的原因。

Sphinx requires that the package is a fully installable package in the sense that when it is placed in the sphinx package, it should be able to compile. Sphinx 要求该包是一个完全可安装的包,因为当它被放置在 sphinx 包中时,它应该能够编译。 I had some absolute references in my import statements which caused my program to fail.我的导入语句中有一些绝对引用,这导致我的程序失败。 As such, the actual docstrings in my program could not be pulled while the names of the classes still showed in my sphinx html.因此,当类的名称仍然显示在我的 sphinx html 中时,无法拉出我程序中的实际文档字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM