athackst / mkdocs-simple-plugin

Build documentation files inside your code into a MkDocs site.

Home Page:https://althack.dev/mkdocs-simple-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incremental file building when --dirtyreload is set

jkaye2012 opened this issue · comments

Hey there,

I've been playing around with this plugin recently and have noticed some significant performance issues related to live reloading. The performance of the plugin is perfectly acceptable for a single documentation build, but it appears that any file change while this plugin is active leads the plugin to rebuild all files that it's watching.

I've played around with the code a bit, and I think it's relatively easy to:

  • Know when the user has --dirtyreload set (from the MkDocsConfiguration)
  • Track the most recent build that mkdocs-simple performed (e.g., using a global within plugin.py, although there may be a better way to do this)
  • Filter the list of files that will be operated on by the plugin in both merge_docs and build_docs in simple.py

The one thing I haven't been able to figure out is something that's going on under the hood leading to this error (during the build step):

[Errno 2] No such file or directory: <file that was not changed>

So it seems like something is expecting this file to be output, but I haven't been able to tell what.

Given this, two questions for you:

  1. If we can figure out how to make this work, would you be willing to merge a change like this assuming I can make it reasonable
  2. If so, could you please point me in the right direction to complete this?

Thanks!

I would absolutely support dirtlyreload.

I think I'd need more information on the error to figure out what's happening. If you have a test branch I can look into it?

I can push one up later today or tomorrow - was just hacking around locally in a docker container today, but now that I know you're game for the change I'll get something more real together!

Here's a crack at it - somehow the issue I was seeing locally earlier I'm not seeing in the bundled Docker container, but I'm not 100% sure the best way to test this. I'm sure tests are still broken and there's a lot more to be done here, but hopefully this is a good start.

#442

The Dockerfile tweaks are there purely to speed up local testing using the container, they're not necessary for the change at all.