renovatebot/renovatebot.github.io

Replace hooks plugin with native MkDocs 1.4.0 `hooks:` config

HonkingGoose opened this issue · 0 comments

Describe the proposed change(s).

Intro

MkDocs 1.4.0 1 has a new hooks: 2 config option, which can load in Python scripts. This means we may be able to drop a dependency.

Material for MkDocs does not support this new hooks: config option (yet). I opened an issue to ask for the hooks: option to be supported, see the todo list below.

Todo:

  • Wait for the update for mkdocs 1.4.0 to land in our repository
  • Wait until we get a version of Material for MkDocs that supports the hooks: feature:
  • Drop mkdocs-simple-hooks dependency from our Pipfile, drop lockfile
  • Run pipenv install to get a fresh lockfile
  • Drop the mkdocs-simple-hooks lines from the mkdocs.yml file
  • Update mkdocs.yml so it uses the new hooks: option
  • Run build, test if things keep working

References

Python script

# Reads the edit_url from the yaml page header and replaces the default one with it
def on_page_context(context, page, config, **kwargs):
if 'edit_url' in page.meta:
page.edit_url = page.meta['edit_url']
return context

Stuff to drop during refactor

- mkdocs-simple-hooks:
hooks:
on_page_context: 'mkdocs-hooks.custom-edit-url:on_page_context'

mkdocs-simple-hooks = "==0.1.5"

Footnotes

  1. https://github.com/mkdocs/mkdocs/releases/tag/1.4.0

  2. https://www.mkdocs.org/user-guide/configuration/#hooks