Skip to content

Conversation

@lightning-sagar
Copy link
Contributor

@lightning-sagar lightning-sagar commented Dec 13, 2025

Description

  • Refactored Installation to be language-aware instead of language-locked
  • Render AvailableOperations based on the presence of AsyncAPI operations,
    not on a specific language

Related issue(s)

Summary by CodeRabbit

  • New Features

    • Installation section always shown and accepts a language selection, displaying the appropriate install command.
    • Code examples now include per-language variants (e.g., JavaScript and Python) with language-specific payload formatting.
  • Refactor

    • Available operations list is rendered only when one or more operations exist.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 13, 2025

⚠️ No Changeset found

Latest commit: 5182727

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@asyncapi-bot
Copy link
Contributor

What reviewer looks at during PR review

The following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.

  1. PR Title: Use a concise title that follows our Conventional Commits guidelines and clearly summarizes the change using imperative mood (it means spoken or written as if giving a command or instruction, like "add new helper for listing operations")

    Note - In Generator, prepend feat: or fix: in PR title only when PATCH/MINOR release must be triggered.

  2. PR Description: Clearly explain the issue being solved, summarize the changes made, and mention the related issue.

    Note - In Generator, we use Maintainers Work board to track progress. Ensure the PR Description includes Resolves #<issue-number> or Fixes #<issue-number> this will automatically close the linked issue when the PR is merged and helps automate the maintainers workflow.

  3. Documentation: Update the relevant Generator documentation to accurately reflect the changes introduced in the PR, ensuring users and contributors have up-to-date guidance.

  4. Comments and JSDoc: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions, so others can easily understand and use the code.

  5. DRY Code: Ensure the code follows the Don't Repeat Yourself principle. Look out for duplicate logic that can be reused.

  6. Test Coverage: Ensure the new code is well-tested with meaningful test cases that pass consistently and cover all relevant edge cases.

  7. Commit History: Contributors should avoid force-pushing as much as possible. It makes it harder to track incremental changes and review the latest updates.

  8. Template Design Principles Alignment: While reviewing template-related changes in the packages/ directory, ensure they align with the Assumptions and Principles. If any principle feels outdated or no longer applicable, start a discussion these principles are meant to evolve with the project.

  9. Reduce Scope When Needed: If an issue or PR feels too large or complex, consider splitting it and creating follow-up issues. Smaller, focused PRs are easier to review and merge.

  10. Bot Comments: As reviewers, check that contributors have appropriately addressed comments or suggestions made by automated bots. If there are bot comments the reviewer disagrees with, react to them or mark them as resolved, so the review history remains clear and accurate.

@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

📝 Walkthrough

Walkthrough

Installation now accepts a language prop and selects an install command from a per-language map; Readme always renders Installation (passing language), fetches operations unconditionally and only renders AvailableOperations if operations exist; MessageExamples now generates per-language examples for JavaScript and Python.

Changes

Cohort / File(s) Summary
Language-agnostic readme components
packages/components/src/components/readme/Installation.js, packages/components/src/components/readme/Readme.js, packages/components/src/components/readme/MessageExamples.js
Installation.js: signature changed to Installation({ language }); added installCommands map and uses selected ${command} instead of a hardcoded install line. Readme.js: always renders Installation with language; retrieves operations unconditionally and renders AvailableOperations only when operations.length > 0. MessageExamples.js: added toSnakeCase import; introduced languageConfig and renderExample to produce language-specific examples (JavaScript, Python) instead of a single template.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 clearly summarizes the main refactoring work by removing language-specific hardcoding from README generation, follows Conventional Commits format with 'refactor:' prefix, and uses imperative mood.
Linked Issues check ✅ Passed All objectives from issue #1787 are met: Installation component is now language-aware, AvailableOperations is rendered conditionally based on operations presence rather than language, and language-specific hardcoding has been removed.
Out of Scope Changes check ✅ Passed All changes are scoped to README component refactoring: Installation component updated to accept language prop, MessageExamples enhanced with language configuration, and Readme.js conditional logic adjusted appropriately.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc19af and 5182727.

📒 Files selected for processing (1)
  • packages/components/src/components/readme/MessageExamples.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/src/components/readme/MessageExamples.js

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.

@lightning-sagar lightning-sagar changed the title refactor(readme): Remove language-specific hardcoding from README generation refactor(readme): remove language-specific hardcoding from README generation Dec 13, 2025
Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

@lightning-sagar left few comments!

Copy link

@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

🧹 Nitpick comments (2)
packages/components/src/components/readme/MessageExamples.js (2)

27-49: Consider adding language prop for consistency with Installation component.

Unlike Installation.js (which accepts a language prop to render language-specific commands), this component renders examples for all languages unconditionally.

For consistency and to support language-aware rendering across README components, consider accepting a language prop to filter which examples to display.

🔎 Example implementation with language prop
-export default function MessageExamples({ operation }) {
+export default function MessageExamples({ operation, language }) {
  const operationId = operation.id();
  const messages = getOperationMessages(operation) || [];

  const messageExamples = [];
  messages.forEach((message) => {
    const examples = getMessageExamples(message) || [];
    examples.forEach((example) => {
      const payload = example.payload();
-     Object.values(languageConfig).forEach(({ render }) => {
-       messageExamples.push(render(operationId, payload));
-     });
+     const languages = language ? [language] : Object.keys(languageConfig);
+     languages.forEach((lang) => {
+       const config = languageConfig[lang];
+       if (config) {
+         messageExamples.push(config.render(operationId, payload));
+       }
+     });
    });
  });

27-27: Add JSDoc documentation for the component.

The component lacks JSDoc comments explaining its purpose, parameters, and return behavior.

🔎 Example JSDoc addition
+/**
+ * Renders message examples for an AsyncAPI operation in multiple programming languages.
+ * 
+ * @param {Object} props - Component props
+ * @param {Object} props.operation - AsyncAPI operation object with id() method
+ * @param {string} [props.language] - Optional language filter (e.g., 'javascript', 'python')
+ * @returns {React.ReactElement|null} Formatted examples or null if no examples exist
+ */
export default function MessageExamples({ operation }) {

Based on coding guidelines from the PR objectives.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0d944f and 98f18cf.

⛔ Files ignored due to path filters (3)
  • packages/components/test/components/__snapshots__/AvailableOperations.test.js.snap is excluded by !**/*.snap
  • packages/components/test/components/__snapshots__/MessageExamples.test.js.snap is excluded by !**/*.snap
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • packages/components/src/components/readme/Installation.js
  • packages/components/src/components/readme/MessageExamples.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/src/components/readme/Installation.js
🧰 Additional context used
🧬 Code graph analysis (1)
packages/components/src/components/readme/MessageExamples.js (2)
packages/components/src/components/readme/OperationHeader.js (1)
  • operationId (4-4)
apps/react-sdk/src/renderer/renderer.ts (1)
  • render (63-77)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test generator as dependency with Node 24
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest

Copy link

@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: 3

♻️ Duplicate comments (1)
packages/components/src/components/readme/MessageExamples.js (1)

6-7: Unused properties flagged in previous review.

The label and codeBlock properties remain unused, as noted in the previous review comment. Consider addressing that feedback by either removing these properties or documenting their intended use.

Also applies to: 16-17

🧹 Nitpick comments (1)
packages/components/src/components/readme/MessageExamples.js (1)

44-44: Consider converting operationId to snake_case for Python conventions.

JavaScript operationIds typically use camelCase (e.g., sendMessage), but Python conventions favor snake_case function names (e.g., send_message).

While not a correctness issue, converting the identifier would make examples more idiomatic for Python developers.

🔎 Suggested conversion helper

Add a utility function:

function toSnakeCase(str) {
  return str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
}

Then update line 44:

-client.${operationId}(${pythonPayload})
+client.${toSnakeCase(operationId)}(${pythonPayload})
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 762cfad and 150236c.

⛔ Files ignored due to path filters (2)
  • packages/components/test/components/__snapshots__/AvailableOperations.test.js.snap is excluded by !**/*.snap
  • packages/components/test/components/__snapshots__/MessageExamples.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/components/src/components/readme/MessageExamples.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Test generator as dependency with Node 24
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

@lightning-sagar left few comments!

Copy link

@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

🤖 Fix all issues with AI agents
In @packages/components/src/components/readme/MessageExamples.js:
- Line 1: The import list is missing a space after the comma between
getOperationMessages and toSnakeCase; update the import statement that currently
imports getMessageExamples, getOperationMessages,toSnakeCase to include a space
so it reads getMessageExamples, getOperationMessages, toSnakeCase (ensure
spacing matches other imports and preserve the same named imports ordering).
- Around line 15-27: Add a JSDoc block above the renderExample function that
documents its purpose (renders a language-specific example snippet), each
parameter (the first param is an object with label: string and codeBlock:
string, plus operationId: string and payload: any), and the return value
(string). Reference the renderExample function and mention it uses toSnakeCase
when codeBlock === 'python' to transform operationId; include types and a short
description for each parameter and the returned template string.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0a1d49 and 7fc19af.

⛔ Files ignored due to path filters (3)
  • packages/components/test/components/__snapshots__/AvailableOperations.test.js.snap is excluded by !**/*.snap
  • packages/components/test/components/__snapshots__/MessageExamples.test.js.snap is excluded by !**/*.snap
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/components/src/components/readme/MessageExamples.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.github/pr-review-checklist.md)

Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions

Files:

  • packages/components/src/components/readme/MessageExamples.js
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Update relevant Generator documentation to accurately reflect PR changes introduced
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Use a concise PR title that follows Conventional Commits guidelines and uses imperative mood (e.g., 'add new helper for listing operations'). Prepend `feat:` or `fix:` only when PATCH/MINOR release must be triggered
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.

Applied to files:

  • packages/components/src/components/readme/MessageExamples.js
🔇 Additional comments (1)
packages/components/src/components/readme/MessageExamples.js (1)

4-13: Excellent language-aware design!

The introduction of languageConfig and the loop-based rendering successfully removes language-specific hardcoding. This design:

  • Centralizes language-specific configuration
  • Makes adding new languages straightforward (just extend languageConfig)
  • Generates examples for all configured languages automatically

This aligns perfectly with the PR objective to make README components language-aware.

Also applies to: 38-40

@Adi-204
Copy link
Member

Adi-204 commented Jan 10, 2026

@lightning-sagar Did you go through both CodeRabbit comments carefully?
The first one is a straightforward formatting improvement. The second one is not related to logic at all—it only suggests adding JSDoc comments and even provides guidance on what can be used.
Read this points carefully especially point 10 so that PR review is much easier.

@lightning-sagar
Copy link
Contributor Author

@lightning-sagar Did you go through both CodeRabbit comments carefully? The first one is a straightforward formatting improvement. The second one is not related to logic at all—it only suggests adding JSDoc comments and even provides guidance on what can be used. Read this points carefully especially point 10 so that PR review is much easier.

sorry about the confusion, I do read both coderabbit comments...,. but I confused, what you meant by “this is valid” that is why I asked for confirmation.... sorry about that

@Adi-204
Copy link
Member

Adi-204 commented Jan 10, 2026

@lightning-sagar oh ok I just mean that comment from coderabbit is valid and please do the changes suggested by coderabbit

@sonarqubecloud
Copy link

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

lgtm!

@Adi-204
Copy link
Member

Adi-204 commented Jan 10, 2026

/rtm

@asyncapi-bot asyncapi-bot merged commit a640160 into asyncapi:master Jan 10, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintainers work Jan 10, 2026
@derberg derberg moved this from Done to Archive in Maintainers work Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Archive

Development

Successfully merging this pull request may close these issues.

Refactor components to not be hardcoded to one language

3 participants