-
Notifications
You must be signed in to change notification settings - Fork 51
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
#135 Print page path on error #136
Conversation
There was a problem hiding this 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.
from mkdocs.structure.pages import Page | ||
|
||
|
||
@singledispatch |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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
on_error_fail
parameter in the config file (issue Add an option to raise exception if render fails #133)