sphinx-doc / sphinx-autobuild

Watch a Sphinx directory and rebuild the documentation when a change is detected. Also includes a hot-reload web server.
MIT License
523 stars 75 forks source link

Use a time window to detect changes in batches #124

Closed choldgraf closed 1 year ago

choldgraf commented 1 year ago

Currently a re-build is triggered the moment that a file in a watched folder is updated. However, sometimes you want to make a few updates in quick succession. Currently, this will cause the re-build to trigger immediately after the first re-build completes. It would be nice if a user could configure a window where changes would be batched together in a single reload event.

Looking at the livereload-python docs, something like this seems to be possible with a delay parameter.

This package is just directly using the Server class so maybe we could make that configurable:

https://github.com/executablebooks/sphinx-autobuild/blob/ea4d04f4f68f564e65ac21843d4839ce24a6e0ae/src/sphinx_autobuild/cli.py#L175

welcome[bot] commented 1 year ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

pradyunsg commented 1 year ago

Duplicate off https://github.com/executablebooks/sphinx-autobuild/issues/87

asmeurer commented 1 year ago

I don't want there to be a delay in the rebuild. That would be a degradation in the user experience as far as I'm concerned.

The problem I described in #123 is that it rebuilds off of files that were changes since before the previous rebuild, basically rebuilding one file at a time.

pradyunsg commented 1 year ago

As I see it, #87 is meant to solve exactly that issue -- to throttle builds so that when there's more than one change in a time period, they're all bundled together and a single rebuild is performed.

asmeurer commented 1 year ago

Maybe I'm misunderstanding what is being proposed. In the common case where I am just editing a single file I would still want the build to be instant so that I can see the built version as quickly as possible.

pradyunsg commented 1 year ago

https://github.com/executablebooks/sphinx-autobuild/blob/ea4d04f4f68f564e65ac21843d4839ce24a6e0ae/src/sphinx_autobuild/cli.py#L40

The build directory not being ignored is likely a bug. #87 covers the infinite loop aspects of the complaint and #125 covers the blocking serving of the pages.

pradyunsg commented 1 year ago

(I have limited bandwidth to write a lot here, apologies for the terseness)

FWIW, I'm not sure what you are trying to say either @asmeurer -- are you saying that #87 doesn't cover your concerns, or that this issue does not cover your concerns, or something else?

choldgraf commented 1 year ago

I believe that @asmeurer is responding to my note that there is "a delay parameter" in livereload, and suggesting that this would not be the right fix. That makes sense to me - I was just noting it as something that seemed relevant. I have no idea how livereload works so am just grasping at straws of things that might be useful :-)

guideloom commented 1 year ago

Make the delay option optional.. if set to 0, it works as it is today. If set to anything else, it's the number of seconds to wait before a rebuild happens.. problem solved for all.