Description
The docs says:
The serve event is only called when the serve command is used during development. It is passed the Server instance which can be modified before it is activated. For example, additional files or directories could be added to the list of "watched" files for auto-reloading.
How can I add files or directories?
I tried this:
def on_serve(self, server, config, **kwargs):
for element in self.config["watch"]:
server.watch(element)
return server
With this in my mkdocs.yml
:
plugins:
- search
- mkdocstrings:
watch:
- src/mkdocstrings
It detects the changes, but since I gave no function to server.watch(dir, func)
, the site is not rebuilt.
I checked the source code of mkdocs
, and I see that you are using a local function that we cannot reuse ourselves without rewriting it:
mkdocs/mkdocs/commands/serve.py
Lines 120 to 137 in 262c2b7
and
mkdocs/mkdocs/commands/serve.py
Line 69 in 262c2b7
What would be the best way to add a directory with this same builder
functionality? Should I simply copy paste it?