Skip to content

Commit 4ec687e

Browse files
committed
Remove auto-install of missing pluglet (#262)
- Change documentation to reflect this - Bump version number - Changelog for Pypi release
1 parent e9dec13 commit 4ec687e

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project are documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 1.4.0, 2025-09-21
8+
* Removed: auto-install of missing pluglet (meaningful error message #262)
9+
* Fixed: error with yaml dumps (#258)
10+
* Fixed: detection of Jinja2, to allow title rendering (#266)
11+
* Small improvements to documentation
12+
713
## 1.3.7, 2024-10-18
814
* Fixed: incompatibility with the d2 module (#249)
915

mkdocs_macros/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ def _load_modules(self):
568568
module = importlib.import_module(module_name)
569569
except ModuleNotFoundError:
570570
if is_on_pypi(source_name, fail_silently=True):
571-
err_msg = (f"Pluglet '{source_name}' exists on PyPI. "
572-
f"Please install it:\n\n pip install {source_name}")
571+
err_msg = (f"Counld not import pluglet '{source_name}'. "
572+
f"Please install it from Pypi:\n\n pip install {source_name}")
573573
raise ModuleNotFoundError(err_msg, name=module_name)
574574
else:
575575
raise ModuleNotFoundError(f"Could not import "

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "mkdocs-macros-plugin"
33

44
# This version number is the REFERENCE for the rest of the project,
55
# particularly for update_pypi.sh
6-
version = "1.3.9"
6+
version = "1.4.0"
77

88
description = "Unleash the power of MkDocs with macros and variables"
99
readme = "README.md"
@@ -44,6 +44,9 @@ test = [
4444
"mkdocs-d2-plugin",
4545
]
4646

47+
# for the MkDocs documentation (webdoc/)
48+
doc = ["mkdocs-mermaid2-plugin"]
49+
4750
[project.entry-points."mkdocs.plugins"]
4851
macros = "mkdocs_macros.plugin:MacrosPlugin"
4952

test/missing_macros/test_site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_build():
2323
print("Result:", result)
2424
# fails, declaring that the pluglet exists and must be installed.
2525
assert build_result.returncode != 0 # failure
26-
assert "Pluglet" in result
26+
assert "pluglet" in result
2727
assert "pip install" in result
2828

2929

webdoc/docs/pluglets.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,28 @@ plugins:
8585
modules: [mkdocs_macros_foo, mkdocs_macros_bar]
8686
```
8787

88-
### Auto-installable pluglets
88+
### Finding pluglets
8989

90-
**Every pluglet specified in the `modules`list should be available.**
90+
**Every pluglet specified in the `modules`list should be already installed.**
9191

92-
However, if the pluglet cannot be found, mkdocs will attempt to install it
93-
(with `pip3 install`) from the standard repositories ([Pypi](https://pypi.org/) and others [defined locally](https://pip.pypa.io/en/stable/topics/configuration/#configuration-files)). If not, mkdocs will fail and exit.
92+
*As of 1.4.0*
9493

95-
!!! Tip "Make installations easier!"
96-
The purpose of this feature is to facilitate the management of environments with several mkdocs websites, typically when a pluglet is designed for a whole
97-
company, project, etc.
94+
!!! Tip "No more auto-install of pluglets"
95+
However, if a pluglet cannot be found, mkdocs will no longer attempt to install it
96+
(with `pip3 install`) from the standard repositories ([Pypi](https://pypi.org/) and others [defined locally](https://pip.pypa.io/en/stable/topics/configuration/#configuration-files)).
9897

99-
In this way, the macros and filters declared in the pluglet will work out
100-
of the box, as long as the pluglet is properly defined in the config file
101-
(and the pluglet is auto-installable).
98+
If a plugin is available on Pypi and it was not installed, `mkdocs serve` and `mkdocs build` will fail
99+
with a ModuleNotFound exception and a meaningful message, making debugging easier on a new install:
102100

101+
```
102+
Could not import pluglet 'mkdocs_macros_foo'. Please install it from Pypi:
103+
104+
pip install mkdocs_macros_foo
105+
```
103106

104-
In some cases, the name of the source package i:
107+
If the plugin name is different from the Python import name, you _should_ specify it
108+
in the `modules` parameter so that MkDocs-Macros can check for its existence on Pypi,
109+
in case it is not installed.
105110

106111
``` {.yaml}
107112
plugins:
@@ -113,7 +118,7 @@ plugins:
113118
In the example above `mkdocs-macros-test` is the package source, and
114119
`mkdocs_macros_test` is the package name for the `import` statement.
115120

116-
If those names are correct everything should fall into place when you type the `mkdocs serve` or `mkdocs build` commands.
121+
If those names are correct, the `mkdocs serve` or `mkdocs build` will give the correct error message.
117122

118123
## Implementing a new pluglet
119124

0 commit comments

Comments
 (0)