aklajnert/mkdocs-simple-hooks

Invalid config option

Ahrak opened this issue · 1 comments

Ahrak commented

Hi! I like the idea of your plugin but it doesn't work that way for me.

I tried your sample code and get the following error:

ERROR   -  Config value: 'plugins'. Error: Plugin value: 'hooks'. Error: Expected type: <class 'dict'> but received: <class 'list'>

My config:

# Plugins
plugins:
  - mkdocs-simple-hooks:
      hooks:
        - on_pre_build: "docs.hooks:copy_readme"

I am using the latest plugin version (0.1.1), mkdocs 1.1.2, python 3.7 64bit

If i debug into your plugin there seems to be something wrong how the hook config value is read:

[{'on_pre_build': 'docs.hooks:copy_readme'}]
> special variables
> function variables
> 0:{'on_pre_build': 'docs.hooks:copy_readme'}
> len():1

Do you know what could be wrong in my configuration? It seems that the codes workes for you?

Oh, it seems like I've made a mistake in the documentation. As the error message says - it expected dict for hooks declaration, but a list of dicts has been provided instead.

Change this:

# Plugins
plugins:
  - mkdocs-simple-hooks:
      hooks:
        - on_pre_build: "docs.hooks:copy_readme"

To this:

# Plugins
plugins:
  - mkdocs-simple-hooks:
      hooks:
        on_pre_build: "docs.hooks:copy_readme"  # <-- no dash here

I'll fix the readme later.