-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
feature: Add try_relative_path
option (for Griffes)
#145
Comments
Hello, thanks for the feature request! Could you actually provide a minimum reproducible example of your issue? Because looking at the code, So if the search paths you provided are correct, Griffe should find your package there and not in the current working directory 🤔 At least I think that's what it would be doing. If you can provide a small repro I'll use it to confirm 🙂 |
mkdocstrings-reproduction.tar.gz # setup reproduction
tar -xzvf mkdocstrings-reproduction.tar.gz --directory /tmp
cd /tmp/myprj
python -m venv venv
. venv/bin/activate
pip install mkdocs mkdocstrings[python]
# check "Reference > main" in both cases to see the difference
# A) current dirname == myprj
mkdocs serve -f /tmp/myprj/mkdocs.yml
# B) current dirname != myprj
cd /tmp/tmp
mkdocs serve -f /tmp/myprj/mkdocs.yml |
Thanks a lot, I was able to replicate the issue. There's actually a side-effect in the finder's |
Actually I think we can simply default to |
Thanks! |
Uh-oh. This (starting with version 1.9.1) broke docs builder for us in python 3.8 with error messages like:
Using |
Hi @VArt3m, no worries, and sorry for the breakage. I did think this could impact some users, but only in edge cases (misconfiguration and/or users actually changing directories before/while building to implicitly change Python's Happy to investigate your specific issue if you can share a link to a public repo 🙂 |
@pawamoy Thanks a lot for a timely and very helpful answer :)
By replacing with default as follows, everything works properly now.
|
Is your feature request related to a problem? Please describe.
I'm working on a project that aggregates docs from multiple repos by copying their content to a tempdir, and I have to move some namespaces around to properly lay them out logically. I'll illustrate the problem below, but TLDR, because Griffe looks for the package in the relative path by default, that interfere with my definitions and causes it to find the wrong definitions (depending on my current directory).
Now, clarifying the situation:
One of the repos,
prj_cli
, have a module calledprj_main.cli.common
and a reference to it as::: prj_main.cli.common
. That was a choice ofprj_cli
team, because its a "shared" plugin in the project and when installed together that makes sense. That worked well while the docs were not aggregated.But now, they are all built together, and there is indeed a
prj_main
repository which has its own stuff. When making the aggregated tmpdir, I'm providing a way to merge over these$TMP/prj_cli/prj_main/cli/common
to the$TMP/prj_main/
directory, so the referenceprj_main.cli.common
makes sense. And finally, I'm adding theprj_main
tmp source location to mkdocstringspaths
.That trick is working, unless my CWD is in the true
prj_main
repository (for example, working on the docs in there), because then Griffe findprj_main
in the relative path (and not in /tmp/.../my_prj), which doesn't containmy_prj.cli.common
.Describe the solution you'd like
To have a
try_relative_path
option in mkdocstring python handler to be passed to griffe.Describe alternatives you've considered
prj_cli
team to do it differently.Additional context
I'll happily open a PR.
The text was updated successfully, but these errors were encountered: