Skip to content

docs: fix incorrect code examples in guides#1336

Merged
pi0 merged 7 commits intomainfrom
docs/fix-code-examples
Mar 15, 2026
Merged

docs: fix incorrect code examples in guides#1336
pi0 merged 7 commits intomainfrom
docs/fix-code-examples

Conversation

@productdevbook
Copy link
Member

@productdevbook productdevbook commented Mar 15, 2026

Summary

Fix 6 incorrect code examples across the documentation that would cause errors for users copying them:

File Fix
docs/guide/basics/response.md html(event, "...")html("...") — html() doesn't take event arg
docs/guide/basics/error.md onError(event, (event, error))onError((error, event)) — wrong signature and param order
docs/guide/basics/middleware.md bodyresponse.statusbody was undefined variable
docs/guide/basics/handler.md Remove stray ) — syntax error
docs/utils/response.md for (let i = 0; i < 1000)for (let i = 0; i < 1000; i++) — missing increment
src/utils/response.ts (JSDoc) Same for loop fix in iterable() JSDoc
docs/guide/api/h3.md event.pathevent.url.pathname — deprecated property

Test plan

  • Documentation only + 1 JSDoc fix
  • No runtime code changes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated examples for consistency and correctness (handler/wrapper syntax, logging examples, response streaming loop and formatting).
  • Bug Fixes
    • Fixed loop increment and minor syntax issues in response-related examples.
  • API Changes
    • onError middleware callback parameter order updated.
    • html helper shorthand no longer requires the event parameter.

- html() does not take event as first argument (response.md)
- onError() takes (error, event) not (event, error) (error.md)
- Remove undefined variable `body` in onResponse example (middleware.md)
- Fix stray closing parenthesis in web handler example (handler.md)
- Fix invalid for loop syntax: add missing `i++` (response.md + JSDoc)
- Replace deprecated event.path with event.url.pathname (h3.md)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@productdevbook productdevbook requested a review from pi0 as a code owner March 15, 2026 07:25
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0f96c694-2e36-471a-9da3-9fea905f1ba1

📥 Commits

Reviewing files that changed from the base of the PR and between 012fc0e and 4f5b1ba.

📒 Files selected for processing (2)
  • docs/2.utils/2.response.md
  • src/utils/response.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/response.ts
  • docs/2.utils/2.response.md

📝 Walkthrough

Walkthrough

Docs and examples updated: middleware and hook examples adjusted, handler/response samples fixed for syntax and parameter usage, and iterable response example corrected with a loop increment and minor formatting fixes.

Changes

Cohort / File(s) Summary
Middleware & Hooks
docs/1.guide/1.basics/3.middleware.md, docs/1.guide/1.basics/6.error.md, docs/1.guide/900.api/1.h3.md
Adjusted example logging and callback signatures: onResponse example now logs response.status instead of body; onError example callback parameter order changed to (error, event); h3 hook example logs event.url.pathname instead of event.path.
Handler & Response examples
docs/1.guide/1.basics/4.handler.md, docs/1.guide/1.basics/5.response.md
Fixed stray parenthesis, standardized wrapper parameter parentheses, added missing semicolon, and simplified html helper example to omit the event argument in the shortcut form.
Iterable / Response utility docs
docs/2.utils/2.response.md, src/utils/response.ts
Corrected example generator loop to for (let i = 0; i < 1000; i++), adjusted generator/Promise formatting and closing punctuation in examples; no runtime API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • pi0

Poem

🐰 I hopped through docs with nibbling paws,
Fixed loops and commas, tweaked callback laws,
A status logged, a pathname found,
Small changes tidy the developer ground ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective of the PR: fixing incorrect code examples across documentation files and JSDoc.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/fix-code-examples
📝 Coding Plan
  • Generate coding plan for human review comments

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.

autofix-ci bot and others added 6 commits March 15, 2026 07:26
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The docs file is auto-generated from JSDoc via automd. Fix the source
JSDoc formatting (missing semicolon, arrow function parens) so the
generated docs pass oxfmt checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/h3@1336

commit: 4f5b1ba

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pi0 pi0 merged commit 2a982c7 into main Mar 15, 2026
9 checks passed
@pi0 pi0 deleted the docs/fix-code-examples branch March 15, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants