Skip to content
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

Mkdocs preprocess hooks #1913

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Mkdocs preprocess hooks #1913

merged 4 commits into from
Jan 31, 2024

Conversation

ADBond
Copy link
Contributor

@ADBond ADBond commented Jan 31, 2024

Type of PR

  • BUG
  • FEAT
  • MAINT
  • DOC

Is your Pull Request linked to an existing Issue or Pull Request?

Closes #1395, and fixes the cludges of my own making.

Give a brief description for the solution you have provided

This adds a docs dependency mkdocs-simple-hooks which allows straightforward access to hooks in the mkdocs build process without writing a fully-fledged plugin.

In this case I have added a hook on_page_markdown which replaces the text of the markdown files in the build, specifically the two functions of the previous script scripts/preprocess_markdown_includes.py:

This in particular means that for local builds we don't actually change the files that need their contents altering, which is irritating, and risks them being accidentally committed (and thus have their contents baked-in from that point onwards, rather than being dynamically generated).

This branch is built from this new process, and has the correct tabular content + links.

Limitations and future

The link-rewriting functionality is a little brittle, using the title of the (currently) only page this is relevant to. As it's only used for this one file, it is probably okay for now and not worth the increased complexity of a more general solution, but might need altering if this portion ends up being used more (probably not too likely - only relevant for files that live outside of docs/ that we also want to include in the build).

With these hooks a nice future option could be to actually generate the included files dynamically as part of the build also, rather than having the initial 'generation' step. This would make building more straightforward (both locally and in CI), although there might be issues with dependency clashing (see #1035), and not sure if this might slow things down.

PR Checklist

  • Added documentation for changes
  • Added feature to example notebooks or tutorial (if appropriate)
  • Added tests (if appropriate)
  • Updated CHANGELOG.md (if appropriate)
  • Made changes based off the latest version of Splink
  • Run the linter

@ADBond ADBond added documentation Improvements or additions to documentation continuous integration labels Jan 31, 2024
@ADBond ADBond requested a review from RossKen January 31, 2024 10:43
Copy link
Contributor

@RossKen RossKen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nifty solution! 🎉

On your point of the "brittleness" - I think this is a major improvement on the current process and I am happy to kick that can down the road a bit tbh. Any additions outside of the docs folder will be very rare so I don't see it as much of an issue.

@ADBond ADBond merged commit a66283c into master Jan 31, 2024
@ADBond ADBond deleted the mkdocs-preprocess-hooks branch January 31, 2024 16:36
@ADBond ADBond mentioned this pull request Feb 9, 2024
10 tasks
@ADBond ADBond mentioned this pull request Mar 14, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
continuous integration documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Find a better way to insert markdown includes into docs
2 participants