backstage / mkdocs-techdocs-core

The core MkDocs plugin used by Backstage's TechDocs as a wrapper around multiple MkDocs plugins and Python Markdown extensions
Apache License 2.0
83 stars 61 forks source link

`src` should not be a published package name #112

Closed roelschr closed 10 months ago

roelschr commented 1 year ago

Installing mkdocs-techdocs-core puts the src packaged in the .venv.

image

src is just a generic name that should be used by any published package. It can cause random errors by conflicting with other packages available in the PYTHONPATH. I suggest you change the name to something meaningful to this project.

Example: our own source code is placed under src. By running mkdocs serve with the techdocs plugin installed we get the following error:

Traceback (most recent call last):
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 78, in serve
    config = get_config()
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/base.py", line 363, in load_config
    errors, warnings = cfg.validate()
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/base.py", line 228, in validate
    run_failed, run_warnings = self._validate()
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/base.py", line 186, in _validate
    self[key] = config_option.validate(value)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 147, in validate
    return self.run_validation(value)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 939, in run_validation
    self.load_plugin_with_namespace(name, cfg)
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 975, in load_plugin_with_namespace
    return (name, self.load_plugin(name, config))
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 993, in load_plugin
    plugin_cls = self.installed_plugins[name].load()
  File "/Users/roelschr/Workspace/feature-store/feature_repo/.venv/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 209, in load
    module = import_module(match.group('module'))
  File "/Users/roelschr/.pyenv/versions/3.8.12/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'src.core'

This makes it impossible for us to use other plugins like mkdocstrings and mkdocs-click.

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.