From 01ef1e6aa2d30d99ae7d1d6b6e579882a15e6a32 Mon Sep 17 00:00:00 2001
From: Allison Thackston
Date: Thu, 7 Apr 2022 17:05:34 +0000
Subject: [PATCH] Add mkdocs-simple-hooks to run gen_readme script in pre-build
---
.github/workflows/publish_docs.yml | 4 ----
build.sh | 8 +-------
examples/gen_readme.py | 7 ++++---
examples/ok-with-mkdocstrings/module.grepout | 2 +-
mkdocs.yml | 7 +++++--
tests/run_integration_tests.sh | 2 +-
tests/test_local.sh | 2 +-
7 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml
index 39ed26d5..7568e3fe 100644
--- a/.github/workflows/publish_docs.yml
+++ b/.github/workflows/publish_docs.yml
@@ -15,10 +15,6 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: 3
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build Docs
run: ./build.sh
- name: Publish Docs
diff --git a/build.sh b/build.sh
index bf172e08..06d8283b 100755
--- a/build.sh
+++ b/build.sh
@@ -3,13 +3,7 @@ set -e
pip install -r requirements.txt
pip install -e .
# md file="build.snippet"
-# Building this package requires generating the readme files for the examples.
-#
-# ```bash
-./examples/gen_readme.py
-# ```
-#
-# And then using `mkdocs_simple_gen` to generate the site.
+# Building this package simply requires using `mkdocs_simple_gen` to generate the site.
#
# ```bash
mkdocs_simple_gen --build -- --verbose
diff --git a/examples/gen_readme.py b/examples/gen_readme.py
index 9153b4d7..5cdc2307 100755
--- a/examples/gen_readme.py
+++ b/examples/gen_readme.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
"""Generate the dockerfiles from a jinja template."""
+import os
+import logging
from pathlib import Path
+
from jinja2 import Environment, FileSystemLoader
from markupsafe import Markup
-
-import os
import yaml
-import logging
+
log = logging.getLogger(__name__)
diff --git a/examples/ok-with-mkdocstrings/module.grepout b/examples/ok-with-mkdocstrings/module.grepout
index 6f5d86bc..bd64588e 100644
--- a/examples/ok-with-mkdocstrings/module.grepout
+++ b/examples/ok-with-mkdocstrings/module.grepout
@@ -9,7 +9,7 @@ documentation!
-module.main()
+module.main()
diff --git a/mkdocs.yml b/mkdocs.yml
index 543caa80..a1c77bba 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,7 +1,9 @@
site_name: athackst/mkdocs-simple-plugin
docs_dir: /tmp/mkdocs-simple/mkdocs-simple-plugin
plugins:
- - search
+ - mkdocs-simple-hooks:
+ hooks:
+ on_pre_build: examples.gen_readme:generate
- simple:
include_extensions:
- .yml
@@ -9,8 +11,9 @@ plugins:
- .pages
- .bats
- .sh
- - macros
- awesome-pages
+ - macros
+ - search
edit_uri: ''
site_url: https://athackst.github.io/mkdocs-simple-plugin
repo_url: https://github.com/athackst/mkdocs-simple-plugin
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index 2078679c..d079766f 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -2,7 +2,7 @@
set -e
sudo apt-get install bats
pip install -e .
-pip install mkdocs-macros-plugin mkdocstrings
+pip install mkdocs-macros-plugin mkdocstrings mkdocs-material
# md file="test.snippet"
# ### Integration tests
#
diff --git a/tests/test_local.sh b/tests/test_local.sh
index 4dc2b38d..2a3f4569 100755
--- a/tests/test_local.sh
+++ b/tests/test_local.sh
@@ -22,7 +22,7 @@ set -e
function docker_run_integration_tests() {
docker build -t mkdocs-simple-test-runner:$1 -f- . <