Repository navigation
A simple method for providing a quick/dirty reload option (refs #990) - #997
Conversation
|
I agree, this is much simpler than a cache system and most likely all we need (comparing modified times using the existing features of the file system). I think I like it. I'll need to look at the specific implementation more closely later (I'm preparing to leave for a long weekend today). But, a few quick things I noticed: Could we also add a
Also, would it make sense to have Finally, I'm curious; how much does this affect performance on a large site? How noticeable of a difference is there? Actually, if we add the |
|
@waylan I will make the changes you suggest.
My initial build of the site takes about 3 min. and re-building a single file takes almost nothing, which makes live editing possible. |
Wow, that seems significant. As I have only ever used MkDocs for smaller projects, sometimes I forget about how build times can affect workflow for larger projects. A 3 min wait for every save would be untenable... But the real reason I asked was to check that these changes were actually shortening the build time as the current exclude-the-clean-flag approach does not actually shorten the build time (as you know). As I mentioned earlier, I'll be out of town this weekend (leaving in a hour or two), so I'll review more closely next week, unless @d0ugal beats me to it. |
|
The latest push includes the command-line argument improvements, including a --dirty flag for the build command. Initial build: Dirty build (changing single file): I also have a long weekend, so no-worries about getting this finished up next week. Thanks. |
|
|
||
|
|
||
| clean_help = "Remove old files from the site_dir before building" | ||
| dirty_reload_help = "Only re-build files that have changed when livereload is enabled" |
There was a problem hiding this comment.
This is redefined later. This line should be removed.
|
This is looking good. Although, I'm wondering if maybe we should issue a warning when It just occurred to me that this ignores media files (in the Also, we need the release notes updated. This should be noted in the major changes section as a default behavior is being changed. |
|
The latest push adds a warning, dirty flags for the copy methods, and moves the modified time function to utils. One thing I noticed, is the |
| ) | ||
|
|
||
| log.debug("Copying static assets from the docs dir.") | ||
| utils.copy_media_files(config['docs_dir'], config['site_dir']) |
There was a problem hiding this comment.
Don't we want to pass the value of dirty on here? Same applies to any other calls to this function or utils.copy_file.
I assume you mean |
So, |
| log.info("The directory contains stale files. Use --clean to remove them.") | ||
|
|
||
| # Set the status of a dirtyreload feature, a build is considered 'dirty' if clean_site_dir = False | ||
| dirty = not clean_site_dir |
There was a problem hiding this comment.
Sorry I missed this before, but let's just change the build function's argument from clean_site_dir=False to dirty=False. After all, we are changing the default, and the consistent API will be less confusing later.
There was a problem hiding this comment.
This is now changed and much better.
|
Looks good. Thanks for your work on this. If you could add a note to the release notes ( I should note that the |
|
@waylan I added some the requested documentation and release note updates. Give it a read to see if I made some typos. I put this in separate commit, let me know if you want me to squash it all together or not. |
| ``` | ||
|
|
||
| It is important to note that this method for building the pages is for development | ||
| of content only, since the navigation and other links do not get updated. |
There was a problem hiding this comment.
Can we add "on other pages" to the end of this sentence (or something similar)? I just want to make it clear that just because the nav is correct on the "updated" page, that does not mean it is on others.
|
I prefer the documentation regarding a change to be with the associated changes, so if you could squash, that would be preferred. That said, I would have taken it as-is if it wasn't for the Markdown-lint error. |
|
@waylan Should be good now, thanks for helping me get this in. |
|
@aeslaughter thanks for the work on this and your patience with my endless nitpicks. |
This provides a --dirty-reload option to the serve command. It simply operates by comparing the modified time of the markdown and html. This is a much simpler solution to what was proposed in
#971 and is meeting my needs well.
Note, that there was some discussion of --clean/--no-clean with the serve command. However, passing a --clean/--no-clean option to the serve command doesn't do anything since each time it runs is creates a different tmp directory (at least for me). So, effectively it is always clean.
(closes #990)