diff --git a/.github/workflows/lint-bash-blocks.yml b/.github/workflows/lint-bash-blocks.yml new file mode 100644 index 00000000..c987ddf8 --- /dev/null +++ b/.github/workflows/lint-bash-blocks.yml @@ -0,0 +1,41 @@ +name: Lint bash code blocks + +on: + pull_request: + paths: + - '**/*.md' + +jobs: + check-bash-blocks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check for multi-line bash code blocks + run: | + fail=0 + while IFS= read -r file; do + # Strip leading ./ so GitHub annotations link to the correct file + clean="${file#./}" + awk -v file="$clean" ' + /^```bash/ { in_block=1; lines=0; start=NR; next } + /^```/ && in_block { + if (lines > 1) { + printf "::error file=%s,line=%d::Bash code block has multiple commands. Each block must contain exactly one command.\n", file, start + found=1 + } + in_block=0; next + } + in_block && /^[^#]/ && !/^[[:space:]]*$/ { lines++ } + END { if (found) exit 1 } + ' "$file" || fail=1 + done < <(find . -name '*.md' -not -path './.git/*' -not -name 'CLAUDE.md') + + if [ "$fail" -eq 1 ]; then + echo "" + echo "Error: Found bash code blocks with multiple commands." + echo "Each bash code block must contain exactly one command." + exit 1 + fi + + echo "All bash code blocks contain a single command." diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..39feb0b6 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,26 @@ +# Docs Conventions + +## Markdown bash code blocks + +Each bash code block must contain exactly one command. Never combine multiple commands in a single block. On the roots.io front-end, bash code blocks have a clipboard copy button that only supports single lines. + +Good: + +````markdown +```bash +composer require example/package +``` + +```bash +wp plugin activate example +``` +```` + +Bad: + +````markdown +```bash +composer require example/package +wp plugin activate example +``` +```` diff --git a/bedrock/converting-wordpress-sites-to-bedrock.md b/bedrock/converting-wordpress-sites-to-bedrock.md index 9f797adb..bca12b37 100644 --- a/bedrock/converting-wordpress-sites-to-bedrock.md +++ b/bedrock/converting-wordpress-sites-to-bedrock.md @@ -28,6 +28,9 @@ Create a new Bedrock installation: ```bash $ composer create-project roots/bedrock example.com +``` + +```bash $ cd example.com ``` @@ -65,6 +68,9 @@ Activate Lithify and run the conversion command: ```bash $ wp plugin activate lithify +``` + +```bash $ wp lithify ``` diff --git a/trellis/redis.md b/trellis/redis.md index 500693d0..80df203b 100644 --- a/trellis/redis.md +++ b/trellis/redis.md @@ -309,13 +309,17 @@ This setup uses three different cache systems: Monitor Redis usage: ```bash -# Redis CLI redis-cli +``` -# Inside Redis CLI -INFO memory -INFO stats +```bash +redis-cli INFO memory +``` -# Monitor real-time commands +```bash +redis-cli INFO stats +``` + +```bash redis-cli MONITOR ```