Shell script scrapes @name/@description from userscripts and builds a table in README.md between marker comments. Pre-commit hook runs it automatically so the table stays in sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
951 B
Bash
30 lines
951 B
Bash
#!/bin/bash
|
|
# Updates the scripts table in README.md between SCRIPTS:START and SCRIPTS:END markers.
|
|
# Scrapes @name and @description from each .user.js file in scripts/
|
|
|
|
REPO_RAW_BASE="https://git.jeirslab.xyz/jeirmeister/tampermonkey-scripts/raw/branch/master"
|
|
README="README.md"
|
|
|
|
# Build the table
|
|
TABLE="| Script | Description | |
|
|
|--------|-------------|-|"
|
|
|
|
for script in scripts/*.user.js; do
|
|
[ -f "$script" ] || continue
|
|
|
|
name=$(grep -m1 '@name' "$script" | sed 's/.*@name\s*//')
|
|
desc=$(grep -m1 '@description' "$script" | sed 's/.*@description\s*//')
|
|
raw_url="${REPO_RAW_BASE}/${script}"
|
|
|
|
TABLE="${TABLE}
|
|
| **${name}** | ${desc} | [Install](${raw_url}) |"
|
|
done
|
|
|
|
# Replace everything between the markers
|
|
awk -v table="$TABLE" '
|
|
/<!-- SCRIPTS:START -->/ { print; print table; skip=1; next }
|
|
/<!-- SCRIPTS:END -->/ { skip=0 }
|
|
!skip { print }
|
|
' "$README" > "${README}.tmp" && mv "${README}.tmp" "$README"
|
|
|
|
echo "Updated $README"
|