简体   繁体   English

Sphinx autodoc 没有导入任何东西?

[英]Sphinx autodoc not importing anything?

I'm trying to use sphinx (in conjunction with autodoc and numpydoc ) to document my module, but after the basic setup, running make html produces just the basic html with nothing from the docstrings included.我正在尝试使用sphinx (与autodocnumpydoc结合使用)来记录我的模块,但是在基本设置之后,运行make html只生成基本的 html,不包含文档字符串中的任何内容。 I'm running Python 3.3, the outline of the project structure is as follows:我运行的是Python 3.3,项目结构大纲如下:

Kineticlib
|--docs
|  |--build
|  |--source
|  |  |--conf.py
|--src
|  |--kineticmulti
|  |  |--__init__.py
|  |  |--file1.py
|  |  |--file2.py
|--setup.py

__init__.py is empty, and in conf.py in the docs/source directory I've added sys.path.insert(0, os.path.abspath('../..')) __init__.py是空的,在docs/source目录的conf.py中,我添加了sys.path.insert(0, os.path.abspath('../..'))

Running make html in the docs directory gives the following output:docs目录中运行make html会得到以下输出:

sphinx-build -b html -d build/doctrees   source build/html
Running Sphinx v1.2.2
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
no targets are out of date.

Build finished. The HTML pages are in build/html.

So, what am I doing wrong?那么,我做错了什么?

Did you run sphinx-apidoc in the docs/source directory?您是否在 docs/source 目录中运行了 sphinx-apidoc? This will generate the .rst files used to make the html.这将生成用于制作 html 的 .rst 文件。 From man sphinx-apidoc ,来自man sphinx-apidoc

sphinx-apidoc [options] -o <outputdir> <sourcedir> [pathnames ...]

You'll need to include (at a minimum) the outputdir (where the .rst files will go, ./ should work) and the sourcedir which should point to your package (looks like ../../src/kineticmulti should work)您需要(至少)包含outputdir (.rst 文件所在的位置,./ 应该可以工作)和应该指向您的包的sourcedir (看起来 ../../src/kineticmulti 应该可以工作)

As it is being said you should do:正如人们所说,你应该这样做:

sphinx-apidoc [options] -o <outputdir> <sourcedir> [pathnames ...]

Sometime modifying your conf.py to import some source modules are also needed.有时还需要修改您的 conf.py 以导入一些源模块。 As well as adding some docs to class in order to load its method docs (can be true only for private classed, but I've been stuck on that).以及向类添加一些文档以加载其方法文档(仅适用于私有类,但我一直坚持这样做)。

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

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