Replies: 9 comments
-
That's a good point, but my answer is two-fold:
1. Why this cannot be easily changedIf were look at the piece of code: on_error_fail = self.config['on_error_fail']
try:
md_template = self.env.from_string(markdown)
# Execute the jinja2 template and return
return md_template.render(**page_variables)
except Exception as error:
error_message = format_error(
error,
markdown=markdown,
page=self.page,
)
trace('ERROR', error_message)
if on_error_fail:
exit(ERROR_MACRO)
else:
return error_message It fails just as any compiler would, at the first error, and there is no way to resume. The best that we could do would be to keep track that it is a failure, and still try to run other pages. Beside the fact that this would complicate the code, it might display a series of errors, but still without certainty that all of them were found (since there might be more than one error per page). As mentioned earlier, the purpose is to stop the build process with an indication of where to start from to debug, not to fully debug the website. 2. How to debugThe prescribed way to debug an MkDocs website mirrors any other piece of code that could break during a build process. The offending piece of code must be analysed, debugged and run through its own "unit" testing, until all bugs are found and weeded out. In that particular case, the testing tool of choice would be |
Beta Was this translation helpful? Give feedback.
-
Thanks for your comments. Wouldn't be a way around this to report the 'errors' as 'warnings' to |
Beta Was this translation helpful? Give feedback.
-
More generally, the behavior of MkDocs-Macros is built on the arguments that can be given to the Jinja2 environment. I used a simple approach, but going beyond that would require some more serious thought. One could perhaps define a new subclass of I would like it if someone else studied a solution and proposed it; as long as it doesn't change the rest of the plugin's logic. |
Beta Was this translation helpful? Give feedback.
-
Regarding I use strict: true
validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn and the build process runs through, at the end it prints something like
after which an error is raised and the build failed. Hmm, spurious warnings of plugins are bad and somehow spoil this approach. |
Beta Was this translation helpful? Give feedback.
-
Perhaps we are getting philosophical here, but the point with warnings, is that they were defined in Python as distinct from Exceptions, so as to continue the execution:
A Which is why I would prefer to (ideally) provide solutions about stopping/not-stopping that rely on exceptions; then letting the user (DevOp) decide what they want to catch or not. |
Beta Was this translation helpful? Give feedback.
-
Well in python this makes sense, but we are talking about mkdocs (even though your plugin is written in python).
From my perspective the quickest / easiest way to write documentation is to 'just' write it have it built and then fix all the errors in one go. |
Beta Was this translation helpful? Give feedback.
-
I understand, though in my mind the job of the running If there disagreement on this, it is a question that might be deferred to the MkDocs project? 🤔 |
Beta Was this translation helpful? Give feedback.
-
You are right, if there is one error, there are likely more. Why making it hard / inconvenient to see all errors? Imagine if it is sent back to you, you probably also prefer to see all the errors immediately rather than having to set up your own environment first in order to see and fix all issues. Having all build errors displayed rather than only the first error is just more convenient. Don't you agree? |
Beta Was this translation helpful? Give feedback.
-
I understand but unfortunately that is not the way Jinja2 and MkDocs have been implemented. There have three options with Jinja2:
As far as I know, it is adequate for the user base and there is not a sufficient case for trying to alter that behavior at the moment. |
Beta Was this translation helpful? Give feedback.
-
With the
mkdocs.yml
setting inwe have the option to have the mkdocs build fail on error.
The build however fails exactly when the error is encountered.
When using
on_error_fail: false
one can see all the errors but the build does not failIt would be better if one could see all the logs and all the error.
Otherwise one can only fix one error and build again to see the next error.
Beta Was this translation helpful? Give feedback.
All reactions