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