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
318 stars 50 forks source link

Allow opt-in of page rendering, instead of opt-out #162

Closed fralau closed 1 year ago

fralau commented 1 year ago

Large projects sometimes have too many pages, to allow them to change them all.

In those cases, it would be easier to render only the pages that require it.

See PR (not used): https://github.com/fralau/mkdocs_macros_plugin/pull/159#issue-1664812954

fralau commented 1 year ago

Opt-in

The solution will be to use in the header:

---
# YAML header
render_macros: true
---

Opt-in is set in the config file, by specifying that no page will be rendered by default:

plugins:
  - search
  - macros:
      render_by_default: false

Opt-out

This is the default case. If you want to be explicit, you can set the parameter render_by_default to true, in the config file.

In the page, use the following directive:

---
# YAML header
render_macros: false
---

This one will be maintained for compatibility (deprecated):

---
# YAML header
ignore_macros: true
---
attie commented 1 year ago

Would you like me to rework the PR?

fralau commented 1 year ago

@attie Thanks! Actually I just implemented and tested it as I went. I should be able to push it today - few lines of code.

Most of the work is was testing and documentation. But you can be credited with the idea!

fralau commented 1 year ago

@attie @hexus This is pushed, if you wish you can started to test if that works for you?

attie commented 1 year ago

@fralau Perfect, thanks very much! Any idea when you plan to push to PyPi? (no hurry, I'd just like to know so I can drop the git reference)

hexus commented 1 year ago

Works well for me too, @fralau. Cheers!

I wasn't particularly in need of this global override for my current project, just offering my two cents on #159. ☺️

Nice to have though, and I think it'll be useful for future projects.

fralau commented 1 year ago

Thanks to both of you, for your input and for testing!

That's part of the 1.0.0 project, and I will push it to pypi as soon as it is ready. The more people test it, the better it is!