Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#135 Print page path on error #136

Merged
merged 3 commits into from
May 15, 2022

Conversation

anatoly-scherbakov
Copy link
Contributor

Copy link
Owner

@fralau fralau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, sorry for the delay. A few comments.

mkdocs_macros/plugin.py Show resolved Hide resolved
from mkdocs.structure.pages import Page


@singledispatch
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating an ad-hoc function was a good idea. 👍

@@ -685,7 +671,10 @@ def on_page_markdown(self, markdown, page, config,
for func in self.pre_macro_functions:
func(self)
# render the macros
self._raw_markdown = self.render(markdown)
self._raw_markdown = self.render(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you added the page argument, for debugging purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is necessary to print the excerpt of the page content in the error handler function.

).strip() % traceback.format_exc()


@format_error.register
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be @format_error.register(TemplateSyntaxError) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily. As per functools.singledispatch docs,

For functions annotated with types, the decorator will infer the type of the first argument automatically

@fralau fralau merged commit cfdadd1 into fralau:master May 15, 2022
@anatoly-scherbakov anatoly-scherbakov deleted the issue-135-print-page-path-on-error branch May 15, 2022 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants