mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-24 21:59:04 +00:00
## Summary
Fixes issues discovered while running the docs automation workflow for
the first time, plus improvements based on the v0.225 run where 44
suggestions overwhelmed a single Droid invocation.
### docs-suggest-publish
- Ignore untracked files when checking for clean working directory
- Add `--auto high` flag to droid exec for non-interactive use
- Add error handling to show droid output on failure
- Remove non-existent `documentation` label from PR creation
- Use `--write` flag for prettier to fix formatting
- **Batch suggestions** into groups of 10 (configurable with
`--batch-size`) to prevent Droid from dropping suggestions when context
is too large
- **Pre-PR docs build validation** — runs `generate-action-metadata` +
`mdbook build` before creating the PR to catch invalid `{#action}` and
`{#kb}` references locally instead of waiting for CI (skippable with
`--skip-validation`)
- **Prompt guardrail** — instructs Droid not to invent `{#kb}` or
`{#action}` references, only reusing action names already present in
docs files
- **Stable release detection** — at publish time, checks each queued
PR's merge commit against the latest stable release tag. PRs already in
stable get annotated "ALREADY IN STABLE" so Droid applies content
changes without adding incorrect Preview callouts
- **Feature flag detection** — parses
`crates/feature_flags/src/flags.rs` for all feature flag struct names,
then checks each PR's diff for references. PRs behind feature flags are
skipped entirely since those features aren't generally available yet
### docs-strip-preview-callouts
- Remove non-existent `documentation` label from PR creation
- Add `Release Notes: - N/A` to generated PR body (fixes Danger bot
check)
## Context
These scripts were run for the first time as part of the v0.225 release.
Issues found:
1. The `documentation` label doesn't exist in this repo
2. Droid exec needs `--auto high` for non-interactive execution
3. Prettier needs `--write` to actually fix files (was running in check
mode)
4. Untracked files should not block the workflow
5. Sending all 44 suggestions in one Droid invocation only applied 2 —
batching in groups of 10 fixed this
6. Droid hallucinated action names (`settings::OpenSettings`,
`gpui::Modifiers::secondary_key`) that broke the docs preprocessor build
7. PRs that shipped in stable v0.225 incorrectly got Preview callouts
because the queue doesn't distinguish preview-only from
already-in-stable
8. PRs behind feature flags (subagents, git graph) got documented
despite not being generally available
Release Notes:
- N/A
231 lines
5.4 KiB
Bash
Executable file
231 lines
5.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Remove Preview callouts from documentation for stable release.
|
|
#
|
|
# Usage:
|
|
# script/docs-strip-preview-callouts [--dry-run]
|
|
#
|
|
# This script finds and removes all Preview-related callouts from docs:
|
|
# > **Preview:** This feature is available in Zed Preview...
|
|
# > **Changed in Preview (v0.XXX).** See [release notes]...
|
|
#
|
|
# Then creates a PR with the changes.
|
|
#
|
|
# Options:
|
|
# --dry-run Show what would be changed without modifying files or creating PR
|
|
# --verbose Show detailed progress
|
|
#
|
|
# Run this as part of the stable release workflow.
|
|
|
|
set -euo pipefail
|
|
|
|
DRY_RUN=false
|
|
VERBOSE=false
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log() {
|
|
if [[ "$VERBOSE" == "true" ]]; then
|
|
echo -e "${BLUE}[strip-preview]${NC} $*" >&2
|
|
fi
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}Error:${NC} $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Parse arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--dry-run)
|
|
DRY_RUN=true
|
|
shift
|
|
;;
|
|
--verbose)
|
|
VERBOSE=true
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
head -18 "$0" | tail -16
|
|
exit 0
|
|
;;
|
|
*)
|
|
error "Unknown option: $1"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Get repo root
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
DOCS_DIR="$REPO_ROOT/docs/src"
|
|
|
|
echo "Searching for Preview callouts in $DOCS_DIR..."
|
|
|
|
# Find files with either type of preview callout:
|
|
# - > **Preview:** ...
|
|
# - > **Changed in Preview ...
|
|
files_with_callouts=$(grep -rlE "> \*\*(Preview:|Changed in Preview)" "$DOCS_DIR" 2>/dev/null || true)
|
|
|
|
if [[ -z "$files_with_callouts" ]]; then
|
|
echo "No Preview callouts found. Nothing to do."
|
|
exit 0
|
|
fi
|
|
|
|
file_count=$(echo "$files_with_callouts" | wc -l | tr -d ' ')
|
|
echo "Found $file_count file(s) with Preview callouts:"
|
|
echo ""
|
|
|
|
for file in $files_with_callouts; do
|
|
relative_path="${file#$REPO_ROOT/}"
|
|
echo " $relative_path"
|
|
|
|
if [[ "$VERBOSE" == "true" ]]; then
|
|
grep -nE "> \*\*(Preview:|Changed in Preview)" "$file" | while read -r line; do
|
|
echo " $line"
|
|
done
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
|
|
if [[ "$DRY_RUN" == "true" ]]; then
|
|
echo -e "${YELLOW}=== DRY RUN ===${NC}"
|
|
echo ""
|
|
echo "Would remove Preview callouts from the files above and create a PR."
|
|
echo ""
|
|
echo "Lines to be removed:"
|
|
echo ""
|
|
|
|
for file in $files_with_callouts; do
|
|
relative_path="${file#$REPO_ROOT/}"
|
|
echo "--- $relative_path ---"
|
|
grep -nE "> \*\*(Preview:|Changed in Preview)" "$file" || true
|
|
echo ""
|
|
done
|
|
|
|
echo -e "${YELLOW}=== END DRY RUN ===${NC}"
|
|
echo ""
|
|
echo "Run without --dry-run to apply changes and create PR."
|
|
exit 0
|
|
fi
|
|
|
|
# Check for clean working state (ignore untracked files)
|
|
if [[ -n "$(git status --porcelain docs/ | grep -v '^??' || true)" ]]; then
|
|
error "docs/ directory has uncommitted changes. Please commit or stash first."
|
|
fi
|
|
|
|
# Apply changes
|
|
echo "Removing Preview callouts..."
|
|
|
|
for file in $files_with_callouts; do
|
|
log "Processing: $file"
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
# Remove preview callout lines and their continuations
|
|
# Handles both:
|
|
# > **Preview:** This feature is available...
|
|
# > **Changed in Preview (v0.XXX).** See [release notes]...
|
|
awk '
|
|
BEGIN { in_callout = 0 }
|
|
/^> \*\*Preview:\*\*/ {
|
|
in_callout = 1
|
|
next
|
|
}
|
|
/^> \*\*Changed in Preview/ {
|
|
in_callout = 1
|
|
next
|
|
}
|
|
in_callout && /^>/ && !/^> \*\*/ {
|
|
next
|
|
}
|
|
in_callout && /^$/ {
|
|
in_callout = 0
|
|
next
|
|
}
|
|
{
|
|
in_callout = 0
|
|
print
|
|
}
|
|
' "$file" > "$tmp_file"
|
|
|
|
mv "$tmp_file" "$file"
|
|
echo " Updated: ${file#$REPO_ROOT/}"
|
|
done
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Preview callouts removed from $file_count file(s).${NC}"
|
|
|
|
# Check if there are actual changes (in case callouts were in comments or something)
|
|
if [[ -z "$(git status --porcelain docs/)" ]]; then
|
|
echo ""
|
|
echo "No effective changes to commit (callouts may have been in non-rendered content)."
|
|
exit 0
|
|
fi
|
|
|
|
# Create branch and PR
|
|
echo ""
|
|
echo "Creating PR..."
|
|
|
|
BRANCH_NAME="docs/stable-release-$(date +%Y-%m-%d)"
|
|
log "Branch: $BRANCH_NAME"
|
|
|
|
git checkout -b "$BRANCH_NAME"
|
|
git add docs/src/
|
|
|
|
# Build file list for commit message
|
|
FILE_LIST=$(echo "$files_with_callouts" | sed "s|$REPO_ROOT/||" | sed 's/^/- /')
|
|
|
|
git commit -m "docs: Remove Preview callouts for stable release
|
|
|
|
Features documented with Preview callouts are now in Stable.
|
|
|
|
Files updated:
|
|
$FILE_LIST"
|
|
|
|
git push -u origin "$BRANCH_NAME"
|
|
|
|
gh pr create \
|
|
--title "docs: Remove Preview callouts for stable release" \
|
|
--body "This PR removes Preview callouts from documentation for features that are now in Stable.
|
|
|
|
## Files Updated
|
|
|
|
$(echo "$files_with_callouts" | sed "s|$REPO_ROOT/|• |")
|
|
|
|
## What This Does
|
|
|
|
Removes callouts like:
|
|
\`\`\`markdown
|
|
> **Preview:** This feature is available in Zed Preview. It will be included in the next Stable release.
|
|
\`\`\`
|
|
|
|
And:
|
|
\`\`\`markdown
|
|
> **Changed in Preview (v0.XXX).** See [release notes](/releases#0.XXX).
|
|
\`\`\`
|
|
|
|
These features are now in Stable, so the callouts are no longer needed.
|
|
|
|
Release Notes:
|
|
|
|
- N/A"
|
|
|
|
PR_URL=$(gh pr view --json url --jq '.url')
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Done!${NC}"
|
|
echo ""
|
|
echo "PR created: $PR_URL"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Review the PR to ensure callouts were removed correctly"
|
|
echo "2. Merge the PR as part of the stable release"
|