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

module_name fails if .py filename begins with mkdocs_ #254

Open
mcrumiller opened this issue Dec 19, 2024 · 3 comments
Open

module_name fails if .py filename begins with mkdocs_ #254

mcrumiller opened this issue Dec 19, 2024 · 3 comments
Labels
info required Further information is requested

Comments

@mcrumiller
Copy link

mcrumiller commented Dec 19, 2024

I was trying to use something other than main.py with the following configuration:

plugins:
  ...
  - macros:
        module_name: mkdocs_macros

with an accompanying mkdocs_macros.py file. Upon trying to mkdocs serve the site, I ran into this error:

ModuleNotFoundError: No module named 'mkdocs_macros.plugin'; 'mkdocs_macros' is not a package

If I rename the file to mkdocsmacros.py (no underscore) and update the mkdocs.yml file, it works properly. It also works if I use something like my_macros.py. It appears that modules that begin with mkdocs_ cause the issue.

I think a simple update to the User Guilde/documentation warning to avoid this pattern may help.

Copy link

Welcome to this project and thank you!

@fralau
Copy link
Owner

fralau commented Dec 20, 2024

Thanks for the heads ups. Have you tried other names with an underscore?

@fralau fralau added the info required Further information is requested label Dec 20, 2024
@mcrumiller
Copy link
Author

Thanks for the heads ups. Have you tried other names with an underscore?

You're right, shame on me, that's obvious...it looks like mkdocs_ is off limits, not necessarily the underscore. Using an underscore is fine. I'll update the OP.

@mcrumiller mcrumiller changed the title module_name fails if .py filename contains underscores module_name fails if .py filename begins with mkdocs_ Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info required Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants