Sphinx error in make html

怎甘沉沦 提交于 2020-04-30 09:30:55

问题


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?


回答1:


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('..'))


来源:https://stackoverflow.com/questions/50230797/sphinx-error-in-make-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!