Mkdocstrings error "No module named" when using monorepo plugin

181 views Asked by At

I am using the monorepo plugin to create nested documentations of my repo packages. I have a lot of packages, but the basic structure of the repo is:

root
|- mkdocs.yml
|- docs
|- components
  |- packages
    |- package1
      |- mkdocs.yml
      |- docs
         |- api.md
      |- folder_with_py_files
        |- file.py

All is working fine with monorepo plugin, but when I try to build the documentation without having installed the packages, is not finding them, and I'm even using the path:[] at both levels inside all the mkdocs.yml, the package and the root ones.

Inside the .md file, I'm calling the module using:

::: folder_with_py_files.file

But the error persists that is not importing the module correctly, and thus is failing when trying to build the root documentation:

ERROR   -  mkdocstrings: Importing 'folder_with_py_files.file' failed, possible causes are:
- an exception happened while importing
- an element in the path does not exist
...
ERROR   -  Error reading page 'package1/api.md':
ERROR   -  Could not collect 'folder_with_py_files.file'

Aborted with a BuildError!

Any ideas on how to fix this?

1

There are 1 answers

0
pawamoy On

If you specified path, that's a typo: it should be paths (plural).

plugins:
- mkdocstrings:
    handlers:
      python:
        paths:
        - components/packages/package1
        - components/packages/package2

See https://mkdocstrings.github.io/python/usage/#finding-modules.