Skip to content

fix(ts-docs): move typedoc config heredoc to column 0#59

Merged
WomB0ComB0 merged 1 commit into
mainfrom
fix/ts-multi-pkg-bash-heredoc
May 10, 2026
Merged

fix(ts-docs): move typedoc config heredoc to column 0#59
WomB0ComB0 merged 1 commit into
mainfrom
fix/ts-multi-pkg-bash-heredoc

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

First multi-package run failed with syntax error: unexpected end of file. The heredoc was nested inside a bash subshell with 14-space indentation, and the closing JSON marker was also indented — bash heredocs only ignore leading tabs via <<-, not spaces.

Lift the heredoc out of the subshell, write the typedoc config once to a tmp path, and cp it into each package dir. The typedoc options are identical across packages, so emitting once is also a tiny optimization.

The first multi-package run failed with `syntax error: unexpected
end of file`. The heredoc was nested inside a bash subshell with
14-space indentation and the closing `JSON` marker was also
indented — bash heredocs only ignore leading TABS via `<<-`, not
spaces.

Lift the heredoc out of the subshell, write the typedoc config
once to a tmp path, and cp it into each package dir before running
typedoc. The typedoc options are identical across packages, so
emitting once is also a tiny optimization.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@WomB0ComB0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 23 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8dfe7ac3-b0a1-4603-b3c9-bf45309d2780

📥 Commits

Reviewing files that changed from the base of the PR and between cefd173 and a3425e7.

📒 Files selected for processing (1)
  • automation/source-repo-templates/api-docs.typescript.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ts-multi-pkg-bash-heredoc

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.

@github-actions github-actions Bot added the area:content MDX/MD documentation content label May 10, 2026
@WomB0ComB0 WomB0ComB0 merged commit 78072a6 into main May 10, 2026
13 checks passed
@WomB0ComB0 WomB0ComB0 deleted the fix/ts-multi-pkg-bash-heredoc branch May 10, 2026 07:33
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 refactors the API documentation generation workflow by centralizing the TypeDoc configuration into a single temporary file that is copied into each package, rather than being redefined in every iteration. Feedback suggests implementing a cleanup mechanism for the temporary file using a trap and ensuring that per-package configuration files are removed after use to maintain a clean workspace. Additionally, a recommendation was made to ensure source links resolve correctly in monorepos.

# once to a tmp path and copy into each package dir.
# Heredoc body lives at column 0 so the bash parser doesn't
# trip on the indented closing marker (tabs vs spaces).
tmp_cfg="$(mktemp)"
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

The temporary file created by mktemp should be cleaned up to avoid leaking files in /tmp. While GitHub Action runners are ephemeral, it is good practice to ensure cleanup, especially if this template is used in persistent environments or self-hosted runners.

          tmp_cfg="$(mktemp)"
          trap 'rm -f "$tmp_cfg"' EXIT

Comment on lines +150 to 157
cp "$tmp_cfg" "$pkg_dir/typedoc.docs-site.json"
(
cd "$pkg_dir"
bun add --dev typedoc-plugin-markdown@latest >/dev/null
bun add --dev typedoc@latest >/dev/null
cat > typedoc.docs-site.json <<'JSON'
{
"$schema": "https://typedoc-plugin-markdown.org/schema.json",
"plugin": ["typedoc-plugin-markdown"],
"tsconfig": "tsconfig.json",
"entryPointStrategy": "Expand",
"entryPoints": ["src"],
"exclude": [
"**/*.cy.ts",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.stories.ts",
"**/*.stories.tsx",
"**/*.spec.ts",
"**/*.spec.tsx"
],
"out": "generated-docs",
"readme": "none",
"cleanOutputDir": true
}
JSON
rm -rf generated-docs
bunx typedoc --options typedoc.docs-site.json
) || {
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

The per-package TypeDoc configuration file should be removed after use to keep the workspace clean. Additionally, ensure the configuration includes the relative path to the package directory in the source code link base URL, as required for monorepos to ensure 'View source' links resolve correctly.

            cp "$tmp_cfg" "$pkg_dir/typedoc.docs-site.json"
            (
              cd "$pkg_dir"
              bun add --dev typedoc-plugin-markdown@latest >/dev/null
              bun add --dev typedoc@latest >/dev/null
              rm -rf generated-docs
              bunx typedoc --options typedoc.docs-site.json
              rm -f typedoc.docs-site.json
            ) || {
              rm -f "$pkg_dir/typedoc.docs-site.json"
            }
References
  1. In monorepos, documentation generator source links must include the relative path to the package directory for correct resolution.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants