backstage/mkdocs-monorepo-plugin

mkdocs serve not working on mkdocs 1.2

champsblanc opened this issue · 7 comments

I updated my current virtual env to use mkdocs 1.2 (i'm testing the new analytics feature since i can't generate a UA-XXXXXX to use with older versions) and i get an error at the end of the building while serving (mkdocs build works fine):

File ".venv/lib/python3.6/site-packages/mkdocs_monorepo_plugin/plugin.py", line 67, in on_serve
    buildfunc = list(server.watcher._tasks.values())[0]['func']
AttributeError: 'LiveReloadServer' object has no attribute 'watcher'

Redirected from mkdocs/mkdocs#2446 (comment)

FYI:

Has anyone had a look at this issue? I am encountering the same issue using the following dependencies:

  • mkdocs version 1.2.1
  • mkdocs-monorepo-plugin version 0.4.15
  • markdown version 3.2.1

Any updates on this?

I also have this error. Here's my workaround (no guarantees on correctness!). Edit plugin.py, modify on_serve

def on_serve(self, server, config, **kwargs):
    #buildfunc = list(server.watcher._tasks.values())[0]['func']

    # still watch the original docs/ directory
    server.watch(self.originalDocsDir) #, buildfunc)

    # watch all the sub docs/ folders
    for _, docs_dir, yaml_file in self.resolvedPaths:
        server.watch(yaml_file) #, buildfunc)
        server.watch(docs_dir) #, buildfunc)

It appears to work for my limited test case. This is mentioned in site-packages/mkdocs/livereload/init.py

def watch(self, path, func=None, recursive=True):
    """Add the 'path' to watched paths, call the function and reload when any file changes under it."""
    path = os.path.abspath(path)
    if func in (None, self.builder):
        func = self.builder
    else:
        warnings.warn(
            "Plugins should not pass the 'func' parameter of watch(). "
            "The ability to execute custom callbacks will be removed soon.",
            DeprecationWarning,
            stacklevel=2,
        )

Thanks for the patience y'all! You should be good once you bump to 0.4.16 of this plugin.

Thanks for the patience y'all! You should be good once you bump to 0.4.16 of this plugin.

the time couldn't be better! thanks =)