由于SYS.PATH,在制作HTML期间的错误

发布于 2025-01-17 13:44:57 字数 7374 浏览 2 评论 0原文

我正在尝试为包构建 Sphinx 文档,但我不断收到错误,需要一些帮助。我的项目目录是 bb_lite ,代码位于 backend 文件夹中。

bb_lite
    ├── 1.0\ docs
    ├── 2.0\ data 
    ├── README.md
    └── backend 

这就是我的 backend 文件夹的样子 。

├── README.md
├── __init__.py
├── __pycache__
│   └── __init__.cpython-36.pyc
├── archive
│   ├── cont_pca_transform_w_original_func.py
│   └── model_tuner.py
├── automl_pipeline
│   ├── __init__.py
│   ├── flow.py
│   └── input_json.json
├── data_preparation
│   ├── __init__.py
│   ├── cat_multiclass_label_index_encoding.py
│   ├── cross_validator.py
│   ├── data_samplers.py
│   └── train_test_validator

cdbb_lite 文件夹,创建一个 docs 文件夹,然后 cddocs 。从那里我运行sphinx-quickstart。当它要求分离源目录和构建目录时,我输入 y 并按 Enter 键。当它要求 autodoc 扩展名时,我输入 y 并完成其他内容。我的 docs 看起来像 -

.
├── Makefile
├── build
├── make.bat
└── source
    ├── _static
    ├── _templates
    ├── conf.py
    └── index.rst

完成此操作后,我打开里面的 conf.py 文件并取消注释前三行

import os
import sys
sys.path.insert(0, os.path.abspath('backend'))

以 docs 文件夹作为我的工作目录,我运行最后

sphinx-apidoc -f -o source/ ../backend/

我运行 make html (来自 docs 目录),这给了我

Creating file source/backend.rst.
Creating file source/backend.automl_pipeline.rst.
Creating file source/backend.data_preparation.rst.
Creating file source/backend.explain.rst.
Creating file source/backend.explain.k_limes.rst.
Creating file source/backend.explain.surrogate_models.rst.
Creating file source/backend.feature_extraction.rst.
Creating file source/backend.model_tuner.rst.
Creating file source/backend.parameter_tuning.rst.
Creating file source/backend.profiling.rst.
Creating file source/backend.tests.rst.
Creating file source/backend.utilities.rst.
Creating file source/modules.rst.

以下错误 - 运行 Sphinx v1.7.4

making output directory...
loading pickled environment... not yet created
loading intersphinx inventory from https://docs.python.org/objects.inv...
intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.inv
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 14 source files that are out of date
updating environment: 14 added, 0 changed, 0 removed
reading sources... [100%] modules                                                                                                                                                                           
WARNING: autodoc: failed to import module 'backend.utilities'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.automl_pipeline.flow'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.automl_pipeline'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.cat_multiclass_label_index_encoding'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.cross_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.data_samplers'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain.k_limes'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain.surrogate_models'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cat_frequency_transformer'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cont_bulk_interactions'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cont_pca_transform'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.naming_constants'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.cross_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.hyperparam_bounds'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_specs'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_tuner_class'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_tuner_pipeline'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.train_test_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.parameter_tuning'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.profiling'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.tests'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.utilities'; the following exception was raised:
No module named 'backend'
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/shubhamgandhi/Desktop/bb_lite/docs/source/modules.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] modules                                                                                                                                                                            
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 28 warnings.

The HTML pages are in build/html.

我不知道哪里出了问题。我关注了一些文档和博客,但无济于事。当我打开 docs/build/html 中的 index.html 时,它没有任何文档。

知道我哪里出错了吗?

I am trying to build a Sphinx documentation for a package but I keep getting errors and could use some help. My project directory is bb_lite and the codes are located in the backend folder.

bb_lite
    ├── 1.0\ docs
    ├── 2.0\ data 
    ├── README.md
    └── backend 

This is how my backend folder looks like
.

├── README.md
├── __init__.py
├── __pycache__
│   └── __init__.cpython-36.pyc
├── archive
│   ├── cont_pca_transform_w_original_func.py
│   └── model_tuner.py
├── automl_pipeline
│   ├── __init__.py
│   ├── flow.py
│   └── input_json.json
├── data_preparation
│   ├── __init__.py
│   ├── cat_multiclass_label_index_encoding.py
│   ├── cross_validator.py
│   ├── data_samplers.py
│   └── train_test_validator

I cd to the bb_lite folder, create a docs folder and cd to docs. From there I run sphinx-quickstart. When it asks to separate the source and build directories, I type y and press enter. When it asks for the autodoc extension, I enter y and complete others. My docs looks like-

.
├── Makefile
├── build
├── make.bat
└── source
    ├── _static
    ├── _templates
    ├── conf.py
    └── index.rst

Once this is done, I open the conf.py file inside and uncomment the first three lines

import os
import sys
sys.path.insert(0, os.path.abspath('backend'))

With the docs folder as my working directory, I run the following

sphinx-apidoc -f -o source/ ../backend/

which gives me

Creating file source/backend.rst.
Creating file source/backend.automl_pipeline.rst.
Creating file source/backend.data_preparation.rst.
Creating file source/backend.explain.rst.
Creating file source/backend.explain.k_limes.rst.
Creating file source/backend.explain.surrogate_models.rst.
Creating file source/backend.feature_extraction.rst.
Creating file source/backend.model_tuner.rst.
Creating file source/backend.parameter_tuning.rst.
Creating file source/backend.profiling.rst.
Creating file source/backend.tests.rst.
Creating file source/backend.utilities.rst.
Creating file source/modules.rst.

Finally I run make html (from the docs directory) which leaves me with the following error-
Running Sphinx v1.7.4

making output directory...
loading pickled environment... not yet created
loading intersphinx inventory from https://docs.python.org/objects.inv...
intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.inv
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 14 source files that are out of date
updating environment: 14 added, 0 changed, 0 removed
reading sources... [100%] modules                                                                                                                                                                           
WARNING: autodoc: failed to import module 'backend.utilities'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.automl_pipeline.flow'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.automl_pipeline'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.cat_multiclass_label_index_encoding'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.cross_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation.data_samplers'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.data_preparation'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain.k_limes'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.explain.surrogate_models'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cat_frequency_transformer'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cont_bulk_interactions'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.cont_pca_transform'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction.naming_constants'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.feature_extraction'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.cross_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.hyperparam_bounds'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_specs'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_tuner_class'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.model_tuner_pipeline'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner.train_test_validator'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.model_tuner'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.parameter_tuning'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.profiling'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.tests'; the following exception was raised:
No module named 'backend'
WARNING: autodoc: failed to import module 'backend.utilities'; the following exception was raised:
No module named 'backend'
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/shubhamgandhi/Desktop/bb_lite/docs/source/modules.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] modules                                                                                                                                                                            
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 28 warnings.

The HTML pages are in build/html.

I dont know where I am going wrong. I followed a few documentations and blogs but cant get anywhere. When I open the index.html inside docs/build/html it doesn't have any documentation.

Any idea where I am going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2025-01-24 13:44:57

backend 目录上方的目录必须添加到 sys.path 中。

如果 bb_lite 是 backend 和 docs 的父目录,则 docs/conf.py 中需要以下内容:

sys.path.insert(0, os.path.abspath('..'))

The directory above the backend directory must be added to sys.path.

If bb_lite is the parent directory of both backend and docs, the following is needed in docs/conf.py:

sys.path.insert(0, os.path.abspath('..'))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文