Skip to content

refactor(nav): rename group to 'Generated Package References' + add sync-templates.sh#40

Merged
WomB0ComB0 merged 1 commit intomainfrom
refactor/rename-and-tooling
May 9, 2026
Merged

refactor(nav): rename group to 'Generated Package References' + add sync-templates.sh#40
WomB0ComB0 merged 1 commit intomainfrom
refactor/rename-and-tooling

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

@WomB0ComB0 WomB0ComB0 commented May 9, 2026

Summary

  1. Rename nav group from "Generated API Reference" → "Generated Package References" in `docs.json`, the splice script, and all three SDK source-repo templates. The old name clashed with the OpenAPI "API reference" tab and obscured what the group actually contains (per-language SDK package docs, not REST endpoints).

  2. Add `automation/sync-templates.sh` that clones each SDK source repo (`npm`, `pypi`, `dotnet-sdk`), copies the matching canonical `api-docs..yml`, and opens a sync PR per repo on `sync/api-docs-template`. Replaces the manual three-PR cadence with one command. Supports `--dry-run` and per-language selection.

Test plan

  • `automation/sync-templates.sh --dry-run` reports diffs for all three repos with the rename
  • After merge, run `automation/sync-templates.sh --auto-merge` to push the rename to source repos
  • `bunx mint dev` shows "Generated Package References" under the SDKs tab

Summary by CodeRabbit

  • Documentation

    • Updated README with instructions for syncing workflow templates across repositories using automation scripts.
    • Restructured SDK navigation menu, renaming "Generated API Reference" group to "Generated Package References" for improved organization.
  • Chores

    • Added automation tooling for template synchronization across source repositories.

Review Change Stack

The SDK API docs group was labeled 'Generated API Reference', which
clashes with the OpenAPI 'API reference' tab and obscured what it
actually contains (per-language SDK package docs, not REST API
reference). Rename to 'Generated Package References' across:

- docs.json (the live nav label)
- scripts/splice-sdk-nav.py (used by manual splice)
- automation/source-repo-templates/api-docs.{python,typescript,dotnet}.yml

Also adds automation/sync-templates.sh: a helper that clones each SDK
source repo, copies the canonical workflow template, and opens a sync
PR when the workflows diverge. This collapses the manual three-PR
template-sync cadence into one command (or `--dry-run` to preview).

Source-repo workflow updates need a follow-up sync PR per repo via
the new script.
@github-actions github-actions Bot added area:content MDX/MD documentation content area:meta Repo meta — docs.json, README, etc. labels May 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

📝 Walkthrough

Walkthrough

This PR renames the "Generated API Reference" navigation group to "Generated Package References" across docs.json, splice scripts, and three language workflow templates. It introduces automation/sync-templates.sh to distribute canonical per-language workflows to target repositories with dry-run and auto-merge support, and documents the sync process.

Changes

SDK Navigation Rename and Distribution

Layer / File(s) Summary
Navigation Configuration
docs.json
SDKs navigation group renamed from "Generated API Reference" to "Generated Package References".
Splice Script Update
scripts/splice-sdk-nav.py
Updated module docstring and main() logic to locate and populate the renamed "Generated Package References" group.
Workflow Template Updates
automation/source-repo-templates/api-docs.dotnet.yml, api-docs.python.yml, api-docs.typescript.yml
Each workflow's docs.json splice step now targets "Generated Package References" instead of "Generated API Reference"; comments and group-selector logic updated.
Template Distribution Automation
automation/sync-templates.sh
New Bash script clones target repositories, copies canonical workflow templates to .github/workflows/api-docs.yml, creates sync PRs on sync/api-docs-template branch, and optionally auto-merges; supports --dry-run, --auto-merge, and language filtering.
Documentation
automation/source-repo-templates/README.md
New "Syncing changes" section describes how to use sync-templates.sh to update workflows across source repositories.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • resq-software/docs#15: Adds the dotnet workflow template that this PR updates to use the renamed navigation group.
  • resq-software/docs#17: Introduces the "Generated API reference" navigation group that this PR renames to "Generated Package References".

Suggested labels

area:content, area:meta

Poem

🐰 Templates unite beneath a new name so bright,
"Package References" shines true and right,
Sync scripts hop far to distant repos round,
Each workflow in place, tight and sound! 📦✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: a navigation group rename and the addition of a new sync script, which are the primary objectives of the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/rename-and-tooling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new synchronization script, automation/sync-templates.sh, to automate the deployment of documentation workflow templates across SDK repositories. It also renames the 'Generated API Reference' navigation group to 'Generated Package References' across configuration files and scripts. Feedback focused on improving the robustness of the sync script, specifically by enhancing error handling during repository cloning, ensuring reliable PR URL capture, and correctly handling scenarios where a pull request already exists.

Comment on lines +122 to +134
pr_url="$(gh pr create \
--repo "$target_repo" \
--base "$default_branch" \
--head "$branch" \
--title "ci(api-docs): sync workflow from resq-software/docs" \
--body "Sync from canonical template \`automation/source-repo-templates/${template_file}\`. Auto-generated by \`automation/sync-templates.sh\`." \
2>&1 | tail -1)"
echo "[$lang] $pr_url"

if [ "$AUTO_MERGE" -eq 1 ]; then
gh pr merge "$pr_url" --repo "$target_repo" --squash --auto --delete-branch || true
echo "[$lang] auto-merge enabled"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current PR creation and merging logic has several issues:

  1. Brittle URL capture: Using 2>&1 | tail -1 is unreliable as it mixes stderr and stdout, potentially capturing error messages as URLs if the command fails.
  2. Existing PR handling: gh pr create fails if a PR already exists for the branch. The script should handle this by fetching the existing PR's URL to allow the sync to continue (e.g., for auto-merging).
  3. Incorrect return status: The function returns 0 even if PR creation or merging fails because the last command executed is an echo. This prevents the main loop from correctly reporting failures.

The suggested refactor addresses these by using a safer capture method, adding a fallback for existing PRs, and ensuring non-zero exit codes on failure.

  if ! pr_url=$(gh pr create \
    --repo "$target_repo" \
    --base "$default_branch" \
    --head "$branch" \
    --title "ci(api-docs): sync workflow from resq-software/docs" \
    --body "Sync from canonical template \`automation/source-repo-templates/${template_file}\`. Auto-generated by \`automation/sync-templates.sh\`." 2>/dev/null); then
    # Fallback: if PR already exists, fetch its URL
    pr_url=$(gh pr view "$branch" --repo "$target_repo" --json url -q .url 2>/dev/null || true)
  fi

  if [ -z "$pr_url" ]; then
    echo "[$lang] failed to create or find PR" >&2
    return 1
  fi
  echo "[$lang] $pr_url"

  if [ "$AUTO_MERGE" -eq 1 ]; then
    if ! gh pr merge "$pr_url" --repo "$target_repo" --squash --auto --delete-branch; then
      echo "[$lang] auto-merge failed" >&2
      return 1
    fi
    echo "[$lang] auto-merge enabled"
  fi

Comment on lines +76 to +77
--depth=1 --branch="$default_branch" --quiet 2>/dev/null; then
echo "[$lang] clone failed for $target_repo" >&2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hiding stderr from gh repo clone using 2>/dev/null makes it difficult to diagnose failures (e.g., authentication issues or repository permission errors). Removing the redirection will provide better visibility when a sync target fails to clone.

Suggested change
--depth=1 --branch="$default_branch" --quiet 2>/dev/null; then
echo "[$lang] clone failed for $target_repo" >&2
if ! gh repo clone "$target_repo" "$clone_dir" -- \
--depth=1 --branch="$default_branch" --quiet; then

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@automation/sync-templates.sh`:
- Around line 98-129: The script currently always runs gh pr create for the
fixed head branch stored in local branch="sync/api-docs-template", causing
failures if a PR already exists; change the flow in the block that sets pr_url
so it first checks for an existing open PR for that head (use gh pr list or gh
pr view with --head "$branch" and --repo "$target_repo") and if found, capture
and echo that existing PR URL instead of calling gh pr create, otherwise call gh
pr create as before; ensure pr_url is set to the existing PR URL when reusing
and preserve the existing commit/push steps (git checkout -b "$branch", git push
-u origin "$branch" --force-with-lease) so the create-or-reuse logic around gh
pr create sets the same pr_url variable used by the echo.

In `@scripts/splice-sdk-nav.py`:
- Line 165: The generator expression that builds the English language entry uses
an ambiguous variable name `l`; update the expression in the assignment to `en =
next(...)` to use a descriptive identifier (e.g., `lang` or `language_entry`)
instead of `l` so it satisfies Ruff E741 and improves readability—locate the `en
= next(l for l in docs["navigation"]["languages"] if l["language"] == "en")`
line and replace the `l` identifier throughout that generator expression with
the chosen descriptive name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ef15c64-8046-4f20-b037-a3491f5ffba8

📥 Commits

Reviewing files that changed from the base of the PR and between 24df40d and b05ba32.

📒 Files selected for processing (7)
  • automation/source-repo-templates/README.md
  • automation/source-repo-templates/api-docs.dotnet.yml
  • automation/source-repo-templates/api-docs.python.yml
  • automation/source-repo-templates/api-docs.typescript.yml
  • automation/sync-templates.sh
  • docs.json
  • scripts/splice-sdk-nav.py

Comment on lines +98 to +129
local branch="sync/api-docs-template"
local commit_msg
commit_msg="$(cat <<EOF
ci(api-docs): sync workflow from resq-software/docs

Sync .github/workflows/api-docs.yml from the canonical template at
automation/source-repo-templates/${template_file} in
resq-software/docs.

Generated by automation/sync-templates.sh.
EOF
)"

(
cd "$clone_dir"
git checkout -b "$branch"
git add .github/workflows/api-docs.yml
git -c user.email=engineer@resq.software \
-c user.name="resq-sw" \
commit -m "$commit_msg"
git push -u origin "$branch" --force-with-lease
)

local pr_url
pr_url="$(gh pr create \
--repo "$target_repo" \
--base "$default_branch" \
--head "$branch" \
--title "ci(api-docs): sync workflow from resq-software/docs" \
--body "Sync from canonical template \`automation/source-repo-templates/${template_file}\`. Auto-generated by \`automation/sync-templates.sh\`." \
2>&1 | tail -1)"
echo "[$lang] $pr_url"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

for repo in resq-software/npm resq-software/pypi resq-software/dotnet-sdk; do
  echo "==> $repo"
  gh pr list \
    --repo "$repo" \
    --state open \
    --head sync/api-docs-template \
    --json number,url,headRefName,baseRefName \
    --jq '.[] | "\(.number) \(.url) [\(.headRefName)->\(.baseRefName)]"'
done

Repository: resq-software/docs

Length of output: 136


🌐 Web query:

gh pr create behavior when PR already exists same head base

💡 Result:

When using GitHub CLI (gh) to create a PR, if the head branch and base branch resolve to the exact same ref within the same repository, gh pr create does NOT proceed; it errors out early. Specifically, gh/cli added an isSameRef check that returns true when head and base point to the same ref in the same repo, and createRun then returns: head branch "<head>" is the same as base branch "<base>", cannot create a pull request [1]. Important nuance: the same branch name across different repositories (e.g., fork vs upstream) is not treated as “same ref”; the code avoids the error for cross-repository PRs even if the branch names match [1]. Separately (different scenario), if you try to create a PR when an open PR for the same head branch already exists, gh pr create reports that the PR already exists and aborts (rather than creating/overwriting another PR) [2][3].

Citations:


🏁 Script executed:

# Verify the gh pr list syntax and jq filter from the suggested fix
# Also check if gh pr create indeed fails on duplicate head/base

# Test: Simulate the suggested check command to verify syntax
gh pr list \
  --repo "resq-software/npm" \
  --state open \
  --head "sync/api-docs-template" \
  --base "main" \
  --json url \
  --jq '.[0].url' 2>&1 | head -20

Repository: resq-software/docs

Length of output: 63


Make PR creation idempotent when sync/api-docs-template already has an open PR.

This always calls gh pr create on a fixed head branch. If an open PR already exists, reruns fail and block the workflow. The GitHub CLI aborts with "PR already exists" rather than reusing the existing PR URL.

🛠️ Suggested diff
-  local pr_url
-  pr_url="$(gh pr create \
-    --repo "$target_repo" \
-    --base "$default_branch" \
-    --head "$branch" \
-    --title "ci(api-docs): sync workflow from resq-software/docs" \
-    --body "Sync from canonical template \`automation/source-repo-templates/${template_file}\`. Auto-generated by \`automation/sync-templates.sh\`." \
-    2>&1 | tail -1)"
+  local pr_url
+  pr_url="$(gh pr list \
+    --repo "$target_repo" \
+    --state open \
+    --head "$branch" \
+    --base "$default_branch" \
+    --json url \
+    --jq '.[0].url')"
+  if [ -z "$pr_url" ]; then
+    pr_url="$(gh pr create \
+      --repo "$target_repo" \
+      --base "$default_branch" \
+      --head "$branch" \
+      --title "ci(api-docs): sync workflow from resq-software/docs" \
+      --body "Sync from canonical template \`automation/source-repo-templates/${template_file}\`. Auto-generated by \`automation/sync-templates.sh\`." )"
+  fi
   echo "[$lang] $pr_url"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@automation/sync-templates.sh` around lines 98 - 129, The script currently
always runs gh pr create for the fixed head branch stored in local
branch="sync/api-docs-template", causing failures if a PR already exists; change
the flow in the block that sets pr_url so it first checks for an existing open
PR for that head (use gh pr list or gh pr view with --head "$branch" and --repo
"$target_repo") and if found, capture and echo that existing PR URL instead of
calling gh pr create, otherwise call gh pr create as before; ensure pr_url is
set to the existing PR URL when reusing and preserve the existing commit/push
steps (git checkout -b "$branch", git push -u origin "$branch"
--force-with-lease) so the create-or-reuse logic around gh pr create sets the
same pr_url variable used by the echo.

Comment thread scripts/splice-sdk-nav.py

# Find Generated API Reference under en > SDKs > groups
# Find Generated Package References under en > SDKs > groups
en = next(l for l in docs["navigation"]["languages"] if l["language"] == "en")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Rename the ambiguous generator variable to satisfy Ruff E741.

next(l for l in ...) is flagged as ambiguous and hurts readability. Rename l to a descriptive identifier.

🧩 Suggested diff
-    en = next(l for l in docs["navigation"]["languages"] if l["language"] == "en")
+    en = next(lang_entry for lang_entry in docs["navigation"]["languages"] if lang_entry["language"] == "en")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
en = next(l for l in docs["navigation"]["languages"] if l["language"] == "en")
en = next(lang_entry for lang_entry in docs["navigation"]["languages"] if lang_entry["language"] == "en")
🧰 Tools
🪛 Ruff (0.15.12)

[error] 165-165: Ambiguous variable name: l

(E741)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/splice-sdk-nav.py` at line 165, The generator expression that builds
the English language entry uses an ambiguous variable name `l`; update the
expression in the assignment to `en = next(...)` to use a descriptive identifier
(e.g., `lang` or `language_entry`) instead of `l` so it satisfies Ruff E741 and
improves readability—locate the `en = next(l for l in
docs["navigation"]["languages"] if l["language"] == "en")` line and replace the
`l` identifier throughout that generator expression with the chosen descriptive
name.

@WomB0ComB0 WomB0ComB0 merged commit fe2e01d into main May 9, 2026
14 checks passed
@WomB0ComB0 WomB0ComB0 deleted the refactor/rename-and-tooling branch May 9, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:content MDX/MD documentation content area:meta Repo meta — docs.json, README, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants