GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — docs/scripts/update-cli-docs.sh at main · epilot-dev/docs Expand file tree/ Copy pathupdate-cli-docs.shMore file actions executable file ·110 lines (95 loc) · 3.47 KB / Copy pathupdate-cli-docs.shFile metadata and controlsexecutable file ·110 lines (95 loc) · 3.47 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 #!/usr/bin/env bash # # Copies CLI command reference docs from sdk-js/packages/cli/docs # and generates the API commands table in docs/cli/overview.md # # Usage: npm run update-cli # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DOCS_ROOT="$SCRIPT_DIR/.." CLI_DOCS_SRC="$DOCS_ROOT/../sdk-js/packages/cli/docs" CLI_DOCS_DEST="$DOCS_ROOT/docs/cli/commands" OVERVIEW_FILE="$DOCS_ROOT/docs/cli/overview.md" START_MARKER="<!-- cli-commands-table -->" END_MARKER="<!-- /cli-commands-table -->" if [ ! -d "$CLI_DOCS_SRC" ]; then echo "Error: CLI docs not found at $CLI_DOCS_SRC" echo "Make sure the sdk-js repo is checked out and CLI docs are generated." exit 1 fi # --- 1. Copy CLI command docs --- echo "Copying CLI command docs from $CLI_DOCS_SRC" mkdir -p "$CLI_DOCS_DEST" rm -f "$CLI_DOCS_DEST"/*.md for src_file in "$CLI_DOCS_SRC"/*.md; do filename="$(basename "$src_file")" [ "$filename" = "index.md" ] && continue slug="${filename%.md}" title="$(head -1 "$src_file" | sed 's/^#\s*//')" # Prepend docusaurus frontmatter, escape MDX-incompatible syntax, and copy { echo "---" echo "title: \"$title\"" echo "description: \"epilot CLI commands for the $title: quick start, common flags and every operation, callable from the command line.\"" echo "---" echo "" cat "$src_file" } | python3 -c " import sys, re HTML_TAGS = { 'details', 'summary', 'div', 'span', 'p', 'br', 'hr', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'ul', 'ol', 'li', 'a', 'img', 'em', 'strong', 'code', 'pre', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'sup', 'sub', 'del', 'ins', 'abbr', 'b', 'i', 'u', 's', 'small', 'mark', } in_code = False for line in sys.stdin: line = line.rstrip('\n') if line.startswith('\`\`\`'): in_code = not in_code if not in_code: prev = None while prev != line: prev = line line = re.sub( r'(?<!\`)<([a-zA-Z][a-zA-Z0-9_-]*)>(?!\`)', lambda m: m.group(0) if m.group(1).lower() in HTML_TAGS else '\`<' + m.group(1) + '>\`', line ) print(line) " > "$CLI_DOCS_DEST/$filename" done COUNT="$(ls "$CLI_DOCS_DEST"/*.md 2>/dev/null | wc -l)" echo "Copied $COUNT command docs to $CLI_DOCS_DEST" # --- 2. Generate API commands table --- echo "Generating CLI commands table in $OVERVIEW_FILE" TABLE_LINES="| API | Command | Reference |" TABLE_LINES="$TABLE_LINES | --- | ------- | --------- |" for doc_file in "$CLI_DOCS_DEST"/*.md; do filename="$(basename "$doc_file")" slug="${filename%.md}" # Extract title from the first H1 line (skip frontmatter) title="$(grep -m1 '^# ' "$doc_file" | sed 's/^# //')" TABLE_LINES="$TABLE_LINES | $title | \`epilot $slug\` | [reference](commands/$slug.md) |" done # Replace the table between markers in overview.md if grep -q "$START_MARKER" "$OVERVIEW_FILE"; then TABLE_FILE="$(mktemp)" printf '%s\n' "$TABLE_LINES" > "$TABLE_FILE" awk -v tfile="$TABLE_FILE" ' /<!-- cli-commands-table -->/ { print; print ""; while ((getline l < tfile) > 0) print l; found=1; next } /<!-- \/cli-commands-table -->/ { found=0 } found { next } { print } ' "$OVERVIEW_FILE" > "$OVERVIEW_FILE.tmp" rm -f "$TABLE_FILE" mv "$OVERVIEW_FILE.tmp" "$OVERVIEW_FILE" echo "Updated commands table in $OVERVIEW_FILE" else echo "Warning: $START_MARKER markers not found in $OVERVIEW_FILE" echo "Add the markers to enable auto-generation of the commands table." fi echo "Done!" |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |