Closed AngryMane closed 11 months ago
Hi @AngryMane ; long time no see, thanks for yet another contrib :)
Frankly, I think dirty flag should be passed from mkdocs. However, since it is currently not possible to obtain the flag from mkdocs, I implemented this by referencing sys.argv.
As a matter a fact, mkdocs DOES provide a way to let plugins know about its own command line invocation AND the dirty flag using the on_startup event!
So you could add a property to the ExtendedPlugin
class defined in reconfigure.py
and then implement a on_startup
method in the plugin.py
which could look like this:
def on_startup(self, command: str, dirty: bool):
"""
Store dirty flag to propagate it to language builds.
"""
self.dirty = dirty
and of course use it later in the on_post_build
method just like you did!
Thank you, I had missed it. I'll correct it. :smile:
Something is wrong with the behavior... Only updates to the default language pages seem not to be hot reloaded. I need to investigate
self.building may need to be set False at the end of on_post_build :thinking:
I understood why the test failed. mkdocs make a cache for plugins if the plugin has "on_startup" or "on_shuddown" event. https://github.com/mkdocs/mkdocs/blob/79f17b4b71c73460c304e3281f6ff209788a76bf/mkdocs/config/config_options.py#L1128
This PR adds "on_startup" event, so mkdocs create plugin cache, and it causes current_language parameter of one previous test case is left. This is the direct cause of test failed.
You're almost there @AngryMane ! Keep it up :)
OK. I fixed. But the commit log is a bit messy, so I'm going to create a new branch and re-create the PR, and close this PR.
Hi! I issued a PR once a long time ago. Long time no see.🙂
description
I found mkdocs supports incremental builds (--dirty and --dirtyreload options), but this plugin does not. This PR changes to support them.
motivation
If there are many documents, not supporting --dirty and --dirtyreload will cause extra time to build. (For instance, my documents have been getting larger and larger, eventually taking as long as two minutes to hot reload!) This PR allows hot reloads to be performed in a fraction of the time.
remarks
Frankly, I think dirty flag should be passed from mkdocs. However, since it is currently not possible to obtain the flag from mkdocs, I implemented this by referencing sys.argv.