fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
321 stars 50 forks source link

fix: Fallback to variables if macro not found #92

Closed CrispyDrone closed 3 years ago

CrispyDrone commented 3 years ago

When defining a macro, also define it in the variables property if the no macro with that name has been defined yet.

This ensures backwards compatible behavior with previous versions that included built-in macros in the variables property.

Issue #87

CrispyDrone commented 3 years ago

Hi,

my thoughts are the following:

Since the plugin is following semantic versioning:

  1. Create a hotfix that ensures predefined macros keep working through env.variables
  2. In the next major version, remove this fallback behavior.

I am new to python development and was unsure how to test this properly. What I did was:

# in the root of the repository
pip install -e .
# change directory to my new folder containing test files
cd test/built-in-macros/
# start mkdocs
mkdocs serve

Is there a way to do some form of unit testing perhaps? Or am I doing this in the completely wrong way?

Thanks :)

fralau commented 3 years ago

See explanation and background in #87.