Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Item src does not exist #23

Open
valberg opened this issue Mar 24, 2023 · 2 comments
Open

ValueError: Item src does not exist #23

valberg opened this issue Mar 24, 2023 · 2 comments

Comments

@valberg
Copy link

valberg commented Mar 24, 2023

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?

@chrisjsewell
Copy link
Member

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

@mkonig
Copy link

mkonig commented Jul 11, 2024

I am currently using glob.glob("../src/**/*.py")

A feature to specify a path like autoapi does would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants