website icon indicating copy to clipboard operation
website copied to clipboard

fix: resolve code block rendering issues in api_components.mdx

Open Amythystx opened this issue 8 months ago β€’ 7 comments

Fixes #5160

Root Cause

The code block rendering issues were caused by two problems:

  1. The api_components.mdx file was missing from pages/docs/tools/generator/
  2. Color inconsistency between code blocks is a Prism.js behavior β€” import inside JSX (<Component />) highlights differently than plain JS. This is handled by the syntax highlighter theme in CodeBlock.tsx.

Changes

  • Added api_components.mdx to pages/docs/tools/generator/
  • Used consistent js language tags on all code blocks to fix color inconsistency
  • Used proper 2-space indentation to fix uneven padding issue
  • All code blocks now render correctly with consistent syntax highlighting

How to test

  1. Run npm run dev
  2. Open http://localhost:3000/docs/tools/generator/api_components
  3. Verify code blocks render with correct colors and no padding issues

Note

The slight color difference on import keyword inside JSX blocks is a known Prism.js behavior and may require a separate fix in CodeBlock.tsx if maintainers decide it needs addressing.

Summary by CodeRabbit

  • Documentation
    • Added a new "API Components" documentation page describing reusable AsyncAPI Generator components (CloseConnection, Connect, CoreMethods, DependencyProvider, OnClose, OnError, OnMessage, OnOpen, Usage).
    • Includes overview, per-component explanations and practical JavaScript/JSX examples demonstrating installation, import, rendering, and common usage patterns.

Amythystx avatar Mar 22 '26 15:03 Amythystx

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
Latest commit 7c81640371dd2d626fd0e85db8b5b18a26fee8a6
Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/69c145a67e130c00080e12e6
Deploy Preview https://deploy-preview-5270--asyncapi-website.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify avatar Mar 22 '26 15:03 netlify

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 28517928-a296-4651-8c54-8a1ec59e8681

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 8c4143252a3d5f3f554de8323f0b15777dda88e0 and 7c81640371dd2d626fd0e85db8b5b18a26fee8a6.

πŸ“’ Files selected for processing (1)
  • pages/docs/tools/generator/api_components.mdx
βœ… Files skipped from review due to trivial changes (1)
  • pages/docs/tools/generator/api_components.mdx

πŸ“ Walkthrough

Walkthrough

A new MDX documentation page pages/docs/tools/generator/api_components.mdx was added, documenting reusable components from @asyncapi/generator-components with sections for CloseConnection, Connect, CoreMethods, DependencyProvider, Installation, OnClose, OnError, OnMessage, OnOpen, and Usage, each including descriptive text and JavaScript/JSX examples.

Changes

Cohort / File(s) Summary
API Components Documentation
pages/docs/tools/generator/api_components.mdx
Added a new MDX page describing ten reusable generator components; includes overview, per-component descriptions, and JS/JSX import+render usage examples with representative props (language, methodName, methodParams, preExecutionCode, postExecutionCode, framework, role, additionalDependencies, title, clientName, clientFileName, etc.).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble lines of docs anew,

Components sprout, a helpful crew,
Code blocks gleam and examples play,
Hop, build, and ship β€” hooray hooray! πŸ₯•

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The PR title accurately describes the main change: fixing code block rendering issues in the api_components.mdx file, which is the primary objective of the changeset.
Linked Issues check βœ… Passed The PR successfully addresses all coding requirements from issue #5160: added the missing api_components.mdx file, normalized code block language tags, applied consistent indentation, and resolved padding inconsistencies.
Out of Scope Changes check βœ… Passed All changes in the PR are directly related to the linked issue #5160 objectives; only the api_components.mdx file was added with no unrelated modifications.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests

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.

coderabbitai[bot] avatar Mar 22 '26 15:03 coderabbitai[bot]

⚑️ Lighthouse report for the changes in this PR:

Category Score
πŸ”΄ Performance 42
🟒 Accessibility 98
🟒 Best practices 92
🟒 SEO 100
πŸ”΄ PWA 33

Lighthouse ran on https://deploy-preview-5270--asyncapi-website.netlify.app/

asyncapi-bot avatar Mar 22 '26 15:03 asyncapi-bot

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 100.00%. Comparing base (7653853) to head (7c81640). :warning: Report is 84 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #5270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          796       830   +34     
  Branches       146       159   +13     
=========================================
+ Hits           796       830   +34     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Mar 22 '26 15:03 codecov[bot]

@animeshk923 Got it I’ll take another look at the rendering issue an update soon.

Amythystx avatar Mar 23 '26 14:03 Amythystx

@animeshk923 @Sourya07 The CoreMethods JSX color inconsistency is a known Prism.js limitation β€” it highlights JSX differently inside a js code block. Changing the code example would affect documentation accuracy so I kept it correct. Can you guide me

Amythystx avatar Apr 02 '26 11:04 Amythystx