This question seems to be fairly common, for example, here or here, but their solutions did not work for me.
The directory structure looks like this:
└──faulty_meters_study
└── __init__.py
└── utils.py
└── anomaly_detection.py
└── visuals.py
└── anomalous_kwh_detection
└── __init__.py
└── general_anomalies.py
└── slowing_down.py
└── data
└── x_data.npy
└── y_data.npy
└── docs
└── conf.py
└── index.rst
└── etc
data
does not contain any files that need to be documented, but anomalous_kwh_detection
does. I run sphinx using the following commands
sphinx-quickstart
sphinx-apidoc -o . ..
make html
My conf.py
file looks like this:
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
project = 'a'
copyright = '2021, b'
author = 'b'
release = '0.0.1'
extensions = ['sphinx.ext.autodoc','sphinx.ext.napoleon']
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
and my index.rst
file looks like:
.. a documentation master file, created by
sphinx-quickstart on Thu Aug 19 21:54:31 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to a's documentation!
=============================
.. toctree::
:maxdepth: 6
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
When I run make html
, I get the error: WARNING: autodoc: failed to import module 'anomaly_detection' from module 'faulty_meters_study'; the following exception was raised: No module named 'faulty_meters_study'
for all modules.
That error usually happens when the path to the directory is not specified in conf.py
, but I did specify it. I'd appreciate if someone can help me out finding what is wrong and how to make sphinx works.
As a smaller additional question, is there a problem if a script looks like this:
a = 3+1
def function1(arg1):
"""
Documentation
"""
return arg1*2
p = a+7
meaning a script that has functions, but also has lines of code that get executed and are not documented.