Skip to content

Commit 34f44f5

Browse files
committed
Support also ProperDocs-specific keys for get-deps, and prioritize them
This way, even mkdocs can still use the projects file maintained by us.
1 parent a638567 commit 34f44f5

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

properdocs/commands/get_deps/__init__.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,17 @@ def get_deps(
174174
theme = cfg.get("theme")
175175
themes = {theme} if theme else set()
176176

177-
plugins = set(_strings(_dig(cfg, "plugins")))
178-
extensions = set(_strings(_dig(cfg, "markdown_extensions")))
177+
plugins = set(_strings(_dig(cfg, "plugins"))) - BUILTIN_PLUGINS
178+
extensions = set(_strings(_dig(cfg, "markdown_extensions"))) - BUILTIN_EXTENSIONS
179179

180180
wanted_plugins = (
181+
(_PluginKind("properdocs_theme", "properdocs.themes"), themes),
181182
(_PluginKind("mkdocs_theme", "mkdocs.themes"), themes),
182-
(_PluginKind("mkdocs_plugin", "mkdocs.plugins"), plugins - BUILTIN_PLUGINS),
183-
(_PluginKind("markdown_extension", "markdown.extensions"), extensions - BUILTIN_EXTENSIONS),
183+
(_PluginKind("properdocs_plugin", "properdocs.plugins"), plugins),
184+
(_PluginKind("mkdocs_plugin", "mkdocs.plugins"), plugins),
185+
(_PluginKind("markdown_extension", "markdown.extensions"), extensions),
184186
)
185-
for kind, wanted in wanted_plugins:
187+
for kind, wanted in (wanted_plugins[0], wanted_plugins[2], wanted_plugins[4]):
186188
log.debug(f"Wanted {kind}s: {sorted(wanted)}")
187189

188190
if projects_file is None:
@@ -197,7 +199,7 @@ def get_deps(
197199
if ( # Also check theme-namespaced plugin names against the current theme.
198200
"/" in entry_name
199201
and theme is not None
200-
and kind.projects_key == "mkdocs_plugin"
202+
and kind.projects_key in ("properdocs_plugin", "mkdocs_plugin")
201203
and entry_name.startswith(f"{theme}/")
202204
and entry_name[len(theme) + 1 :] in wanted
203205
and entry_name not in wanted
@@ -220,21 +222,29 @@ def get_deps(
220222

221223
wanted.remove(entry_name)
222224

225+
warnings: dict[str, str] = {}
226+
223227
for kind, wanted in wanted_plugins:
224228
for entry_name in sorted(wanted):
225229
dist_name = None
226230
ep = _entry_points(kind.entry_points_key).get(entry_name)
227231
if ep is not None and ep.dist is not None:
228232
dist_name = ep.dist.name
229-
warning = (
233+
base_warning = (
230234
f"{str(kind).capitalize()} '{entry_name}' is not provided by any registered project"
231235
)
232236
if ep is not None:
233-
warning += " but is installed locally"
237+
warning = base_warning + " but is installed locally"
234238
if dist_name:
235239
warning += f" from '{dist_name}'"
236-
log.info(warning)
240+
warnings[base_warning] = warning # Always prefer the lesser warning
237241
else:
238-
log.warning(warning)
242+
warnings.setdefault(base_warning, base_warning)
243+
244+
for warning in warnings.values():
245+
if " is installed " in warning:
246+
log.info(warning)
247+
else:
248+
log.warning(warning)
239249

240250
return sorted(packages_to_install)

properdocs/tests/integration/projects.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# This is an intentionally small subset of https://github.com/properdocs/catalog
33
projects:
44
- name: MkDocs theme
5-
mkdocs_theme: [mkdocs]
5+
properdocs_theme: [mkdocs]
66
github_id: properdocs/properdocs
77
pypi_id: properdocs-theme-mkdocs
88
- name: ReadTheDocs theme
9-
mkdocs_theme: [readthedocs]
9+
properdocs_theme: [readthedocs]
1010
github_id: properdocs/properdocs
1111
pypi_id: properdocs-theme-readthedocs
1212
- name: Material for MkDocs

0 commit comments

Comments
 (0)