Skip to content

Commit 399e892

Browse files
committed
lets update to use the Jekyll docs publiser instead of doing it every time we use this template repo
1 parent 5dfa485 commit 399e892

File tree

6 files changed

+59
-37
lines changed

6 files changed

+59
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ htmlcov
55
dist
66
coverage.json
77
site
8+
docs/pydoc

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# the things that don't have output files or run every time
22
.PHONY: help all install test dev coverage clean \
3-
pre-commit update-pre-commit
3+
pre-commit update-pre-commit docs dist
44

55

66
PROJECT_NAME := example_package
@@ -18,7 +18,8 @@ test: .venv/.installed-dev ## run the project's tests
1818
coverage: .venv/.installed-dev scripts/coverage.sh ## build the html coverage report
1919
scripts/coverage.sh $(PROJECT_NAME)
2020

21-
docs: .docs/index.html ## build the documentation
21+
docs: .venv/.installed-dev scripts/docs.sh docs/index.md README.md pyproject.toml ## build the documentation
22+
scripts/docs.sh
2223

2324
clean: ## delete caches and the venv
2425
scripts/clean.sh
@@ -36,9 +37,6 @@ release: scripts/release.sh ## publish to pypi
3637

3738
# Caching doesn't work if we depend on PHONY targets
3839

39-
.docs/index.html: .venv/.installed-dev scripts/docs.sh mkdocs.yml $(shell find -name '*.md')
40-
scripts/docs.sh $(PROJECT_NAME)
41-
4240
.venv/.installed: pyproject.toml .venv/bin/activate scripts/install.sh $(shell find src -name '*.py')
4341
scripts/install.sh $(PROJECT_NAME)
4442

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

mkdocs.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ dev = [
2121
"build",
2222
"twine",
2323
"ruff",
24-
"mkdocs",
25-
"mkdocs-material",
2624
"pydoc-markdown"
2725
]
2826

scripts/docs.sh

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
1-
#!/usr/bin/bash
2-
3-
source .venv/bin/activate
1+
#!/bin/sh
42

53
set -e
64

7-
pushd src
8-
pydoc-markdown -p "$1" > ../docs/pydoc.md
9-
popd
5+
# Variables
6+
PROJECT_NAME=$(basename "$(pwd)")
7+
REPO_URL="ssh://git@github.com/bitplane/bitplane.net.git"
8+
SRC_PATH="docs"
9+
DEST_PATH="dev/python/$PROJECT_NAME"
10+
COMMIT_MSG="Update $PROJECT_NAME docs"
11+
12+
# Build the pydocs
13+
. .venv/bin/activate
14+
15+
mkdir -p docs/pydoc
16+
cd src
17+
pydoc-markdown -p "$PROJECT_NAME" > ../docs/pydoc/index.md
18+
cd ..
19+
20+
# Check out the main website repo
21+
TMP_DIR=$(mktemp -d)
22+
23+
# Cleanup on exit
24+
cleanup() {
25+
echo "Cleaning up..."
26+
rm -rf "$TMP_DIR"
27+
}
28+
trap cleanup EXIT
29+
30+
# Clone the repository
31+
echo "Cloning $REPO_URL into $TMP_DIR..."
32+
git clone --depth=1 "$REPO_URL" "$TMP_DIR"
33+
34+
# Set up the destination path
35+
FULL_DEST_PATH="$TMP_DIR/$DEST_PATH"
36+
37+
# Copy files from source to destination
38+
echo "Copying files from $SRC_PATH to $FULL_DEST_PATH..."
39+
mkdir -p "$FULL_DEST_PATH"
40+
cp -r "$SRC_PATH/." "$FULL_DEST_PATH/"
41+
42+
# Remove symlinks in the destination
43+
echo "Removing symlinks in $FULL_DEST_PATH..."
44+
find "$FULL_DEST_PATH" -type l -exec rm {} +
45+
46+
# Replace symlinks with file contents
47+
echo "Replacing symlinks with file contents..."
48+
cd "$SRC_PATH"
49+
find . -type l -exec sh -c 'cat "$1" > "$2/$1"' _ {} "$FULL_DEST_PATH" \;
50+
51+
# Commit and push
52+
echo "Committing and pushing changes..."
53+
cd "$TMP_DIR"
54+
git add "$DEST_PATH"
55+
git commit -m "$COMMIT_MSG"
56+
git push
1057

11-
mkdocs build
12-
mkdocs gh-deploy
58+
echo "Docs published!"

0 commit comments

Comments
 (0)