sphinx-autodoc2
sphinx-autodoc2 copied to clipboard
ValueError: Item src does not exist
I'm getting the following when trying to build our docs with sphinx-autodoc2:
[Autodoc2] Determining files to write ...
[Autodoc2] Writing modules...[ 0%] src
Traceback (most recent call last):
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/sphinx/events.py", line 94, in emit
results.append(listener.handler(self.app, *args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/autodoc2/sphinx/extension.py", line 76, in run_autodoc
mod_path = run_autodoc_package(app, config, i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/autodoc2/sphinx/extension.py", line 213, in run_autodoc_package
content = "\n".join(
^^^^^^^^^^
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/autodoc2/render/rst_.py", line 25, in render_item
raise ValueError(f"Item {full_name} does not exist")
ValueError: Item src does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/sphinx/cmd/build.py", line 276, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/sphinx/application.py", line 262, in __init__
self._init_builder()
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/sphinx/application.py", line 335, in _init_builder
self.events.emit('builder-inited')
File "/home/valberg/code/project/venv/lib/python3.11/site-packages/sphinx/events.py", line 105, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function run_autodoc at 0x7f32ba1a1d00> for event 'builder-inited' threw an exception (exception: Item src does not exist)
Extension error (autodoc2.sphinx.extension):
Handler <function run_autodoc at 0x7f32ba1a1d00> for event 'builder-inited' threw an exception (exception: Item src does not exist)
Our docs/conf.py looks like this:
import os
import sys
project = "Project"
copyright = ""
author = ""
extensions = [
"myst_parser",
"sphinx.ext.viewcode",
"sphinxcontrib.mermaid",
"autodoc2",
]
autodoc2_packages = [
"../src/",
]
templates_path = ["_templates"]
language = "en"
exclude_patterns = []
html_theme = "furo"
html_static_path = []
myst_enable_extensions = [
"dollarmath",
"amsmath",
"deflist",
"fieldlist",
"html_admonition",
"html_image",
"colon_fence",
"smartquotes",
"replacements",
"strikethrough",
"substitution",
"tasklist",
"attrs_image",
]
It looks like it goes through all the modules alright, but when it comes to writing them it fails.
Am I doing anything wrong or is this a real bug?
Heya, yep I think you need to provide the path to the actual package, not just the containing src folder, e.g.:
autodoc2_packages = [
"../src/my_package",
]
But for sure it should be error handled better than this
I am currently using glob.glob("../src/**/*.py")
A feature to specify a path like autoapi does would be nice.