mkdocstrings · GitHub

First, I'm a big fan of this plugin, thank you to the author and contributors.

Here's my question: when searching for a module, if there are multiple modules on the path with the same name, can I configure the plugin to prefer my source code over modules installed in site-packages?

I've got a project set up as follows:

my_module/
    __init__.py
    ...
    docs/
        tests.md
tests/
    __init__.py
    ...
mkdocs.yml
pyproject.toml

I'm trying to collect documentation from my tests root. tests.md looks like this:

# Testing
::: tests

I believe mkdocs.yml is correctly configured:

plugins:
 - mkdocstrings:
      handlers:
          python:
            paths: [.]

When I render these docs, other python source is correctly collected/rendered, but "tests" is not.
From the logs, it seems like "tests" is actually being loaded from site-packges:

  mkdocstrings: Matched '::: tests'
│    ▹ DEBUG   -  griffe: Searching path(s) for tests
│    ▹ DEBUG   -  griffe: Found tests: loading
│    ▹ DEBUG   -  griffe: Loading path (omitted)/.venv/lib/python3.12/site-packages/tests/__init__.py

From manually looking at this path, it seems like this originates from one of my 3rd party dependencies, a bibtex parser package. I'm hoping there is an easy way to configure the plugin to prioritize my modules.

(edit) I've also tried setting "paths" to paths: [my_module, tests], and got the same result.

Thanks in advance for any help!

Read the original on github.com ↗