Skip to content

Add an option to raise exception if render fails #133

Closed
@allebacco

Description

@allebacco

The current behavior of the MacrosPlugin.render() method when the template rendering fails is to return the exception message as the rendered text.

This behavior is convenient when writing the mkdocs pages, but it is less useful when documentation is compiled in a CI/CD environment.

My proposal is to add an option to raise an exception when the rendering fails, in this way the CI/CD process can fail. Otherwise the compiled documentation will miss the relevant information because of the error message of the macros plugin.

The option could be named strict and should be false to keep the current behavior of the plugin.

Thanks to mkdocs 1.2, the option could then be configured with an environment variable like:

plugins:
  - search
  - macros:
      module_name: my_module
      strict: !ENV [ENABLE_STRICT_MODE, false]

In this way, local execution will not raise exception, but execution within CI/CD pipelines could raise exceptions in case of rendering errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfixedA fix has been submitteduseful tipA how-to, good to know

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions