-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hot reload for the watch command (#627) #629
Conversation
|
||
// handler for signalling to refresh the page to the client | ||
let hotReloadHandler _ = Serve.signalHotReload <- true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hotReloadHandler
get used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, that is indeed a leftover from a previous test, will remove
I'm not sure of the best approach here - perhaps a template substitution that's only activated when building |
That worked well! |
@kMutagene This looks ready? |
@dsyme yeah i was just not sure if i should merge my own PR or wait for a review ;) |
Feel free to ask for a review bia @ to myself and other maintainters. Then if you don't get one after a while you can self-merge :-) |
docs/styling.md
Outdated
@@ -104,6 +104,12 @@ If you write a new theme by CSS styling please contribute it back to FSharp.Form | |||
You can do advanced styling by creating a new template. Add a file `docs/_template.html`, likely starting | |||
with the existing default template. | |||
|
|||
to enable hot reload during development with `fsdocs watch` in a custom `_template.html` file, make sure to add the following line to your `<head>` tag: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capital "T" at start of line.
Also there is a table of substitutions in content.md I believe, this should be added there
) }) ) | ||
) | ||
} | ||
|> Async.RunSynchronously |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has changed from Start to RunSynchronously. If it's RunSynchronously then no async is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this is unnecessary. I was kind of thrown off by the 'fire and forget' nature of Async.Start (via this) and ditched it without second thought thinking i have to wait until the computation is finished. I missed that the hot reload trigger does not have to happen after the whole block but just after the last function call inside it, so i moved it inside the block now using the original Async.start version again.
|
||
regenerateSearchIndex()) | ||
} | ||
|> Async.RunSynchronously |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here....
On Start v. RunSynchronously - was this fixing a bug? |
This is a WIP PR trying to implement hot reload for the
fsdocs watch
command as discussed in #627.The server side part is done, and the cycle works when adding the following script to the _template.html files:
But i am not sure what the best way to handle injecting this code is, as it has to be removed when building the actual docs, or the page will be loked in a constant reload cycle. My idea so far would be, when running the watch command, copy the template files, inject the code, and generate files based on that. This would also need an additional handling of updating these copied template files. I am not familiar enough with the code base yet to see what the best approach here is, and where best to intoduce these changes in the code, so feedback is welcome!