Skip to content

Conversation

@akshatnema
Copy link
Member

@akshatnema akshatnema commented Apr 26, 2025

Docstrings generation was requested by @akshatnema.

The following files were modified:

  • scripts/adopters/index.ts
  • scripts/build-docs.ts
  • scripts/build-meetings.ts
  • scripts/build-newsroom-videos.ts
  • scripts/build-pages.ts
  • scripts/build-post-list.ts
  • scripts/build-rss.ts
  • scripts/build-tools.ts
  • scripts/casestudies/index.ts
  • scripts/compose.ts
  • scripts/dashboard/build-dashboard.ts
  • scripts/finance/index.ts
  • scripts/index.ts
  • scripts/markdown/check-edit-links.ts
  • scripts/markdown/check-markdown.ts
  • scripts/tools/combine-tools.ts
  • scripts/tools/extract-tools-github.ts
  • scripts/tools/tools-object.ts
  • scripts/utils.ts
  • scripts/utils/readAndWriteJson.ts
  • utils/redirect.ts

Description

Related issue(s)

Summary by CodeRabbit

  • Documentation
    • Expanded and clarified end-user documentation and in-code comments for various features, including blog posts, case studies, adopters, finance info, tools, dashboard, and markdown validation processes. No functional changes were made; all updates enhance clarity and completeness of feature descriptions.

Docstrings generation was requested by @akshatnema.

* #3761 (comment)

The following files were modified:

* `scripts/adopters/index.ts`
* `scripts/build-docs.ts`
* `scripts/build-meetings.ts`
* `scripts/build-newsroom-videos.ts`
* `scripts/build-pages.ts`
* `scripts/build-post-list.ts`
* `scripts/build-rss.ts`
* `scripts/build-tools.ts`
* `scripts/casestudies/index.ts`
* `scripts/compose.ts`
* `scripts/dashboard/build-dashboard.ts`
* `scripts/finance/index.ts`
* `scripts/index.ts`
* `scripts/markdown/check-edit-links.ts`
* `scripts/markdown/check-markdown.ts`
* `scripts/tools/combine-tools.ts`
* `scripts/tools/extract-tools-github.ts`
* `scripts/tools/tools-object.ts`
* `scripts/utils.ts`
* `scripts/utils/readAndWriteJson.ts`
* `utils/redirect.ts`
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 26, 2025

Walkthrough

This change set comprehensively updates and expands JSDoc comments throughout a wide range of script files and utility modules. The documentation improvements clarify function behaviors, detail parameters and return values, and explicitly describe error handling across build scripts for posts, RSS feeds, case studies, adopters, finance, tools, and utility functions. No changes are made to the implementation logic, function signatures, or control flow in any file; all modifications are strictly confined to enhancing code documentation for clarity, completeness, and maintainability.

Changes

File(s) Change Summary
scripts/adopters/index.ts
scripts/build-docs.ts
scripts/build-meetings.ts
scripts/build-newsroom-videos.ts
scripts/build-pages.ts
scripts/build-post-list.ts
scripts/build-rss.ts
scripts/build-tools.ts
scripts/casestudies/index.ts
scripts/compose.ts
scripts/dashboard/build-dashboard.ts
scripts/finance/index.ts
scripts/index.ts
scripts/markdown/check-edit-links.ts
scripts/markdown/check-markdown.ts
scripts/tools/combine-tools.ts
scripts/tools/extract-tools-github.ts
scripts/tools/tools-object.ts
scripts/utils.ts
scripts/utils/readAndWriteJson.ts
utils/redirect.ts
Expanded and clarified JSDoc comments for all major exported/public functions. The new comments provide detailed descriptions of function behavior, parameters, return values, and error handling. No changes were made to any function implementation, control flow, or signatures. All updates are strictly limited to documentation improvements for clarity and completeness.

Sequence Diagram(s)

No sequence diagrams generated, as the changes are limited to documentation updates and do not affect control flow or introduce new features.

Possibly related PRs

  • asyncapi/website#3770: Updates and expands JSDoc comments for the same set of script files, indicating directly related documentation improvements.
  • asyncapi/website#3137: Adds tests and error handling to buildNavTree and addDocButtons in scripts/build-docs.ts, targeting the same functions whose documentation is updated in this PR.
  • asyncapi/website#3423: Migrates build scripts from JavaScript to TypeScript and updates documentation, sharing context with this PR's documentation enhancements.

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • devilkiller-ag
  • sambhavgupta0705
  • asyncapi-bot-eve
  • Mayaleeeee

Poem

🐇
In fields of docs, I hop with glee,
Expanding comments for all to see.
Functions explained, no code rearranged,
Behaviors and errors, clearly exchanged.
With every hop, the docs grow bright—
A garden of clarity, pure delight!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented Apr 26, 2025

Deploy Preview for asyncapi-website ready!

Name Link
🔨 Latest commit 2350d8c
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/680d199848d808000879f9b1
😎 Deploy Preview https://deploy-preview-4070--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 site configuration.

@codecov
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ed9bb80) to head (2350d8c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #4070   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          742       742           
  Branches       123       123           
=========================================
  Hits           742       742           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Contributor

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

🔭 Outside diff range comments (1)
scripts/adopters/index.ts (1)

18-20: ⚠️ Potential issue

Critical: Missing await on writeJSON.
Because writeJSON returns a Promise, omitting await means buildAdoptersList may resolve before the file is written, leading to race conditions.

Apply this fix:

-export async function buildAdoptersList() {
-  writeJSON('config/adopters.yml', resolve(currentDirPath, '../../config', 'adopters.json'));
+export async function buildAdoptersList() {
+  await writeJSON('config/adopters.yml', resolve(currentDirPath, '../../config', 'adopters.json'));
 }
🧹 Nitpick comments (19)
scripts/build-pages.ts (1)

40-47: Consider documenting return type.
Since copyAndRenameFiles performs file operations and does not return a value, adding an @returns {void} tag would improve clarity in the JSDoc.

scripts/build-meetings.ts (1)

12-19: Add missing return annotation.
The buildMeetings function is async and resolves with no value after writing the file. Consider adding an @returns {Promise<void>} tag to explicitly document this.

scripts/markdown/check-edit-links.ts (1)

63-70: Consider documenting thrown errors in checkUrls.
Currently, the JSDoc for checkUrls covers parameters and return values but omits any @throws tag. Since a failure in processBatch will reject the Promise and bubble up, it would be helpful to callers to know that this function may throw.

Apply this diff to add an @throws annotation:

  * @returns A promise that resolves to an array of path objects with broken links.
+ * @throws {Error} If processing any batch fails.
utils/redirect.ts (1)

6-15: Great enhancement of the useRedirect JSDoc.
The comment now clearly states the hook’s behavior, including language detection, URL determination, and loop prevention.

To tighten types, consider changing the return signature from any to a more accurate type, for example:

-export function useRedirect(to: string | undefined): any {
+export function useRedirect(to?: string): null {
scripts/build-tools.ts (1)

13-26: Solid JSDoc for buildTools.
The comment thoroughly covers GitHub data fetching, conversion, file writes, merging, and error semantics.

You might also add a @returns annotation to indicate the function returns a Promise<void>:

  * @throws {Error} If an error occurs during the build process.
+ * @returns {Promise<void>} Resolves when the tools data has been successfully built and written.
scripts/adopters/index.ts (1)

9-17: Docstring improvements are on point.
The description captures the YAML→JSON flow and file paths correctly.

Consider enhancing with @returns and @throws tags:

  * @param readPath - The path of the YAML file to read.
  * @param writePath - The destination JSON file path.
+ * @returns {Promise<void>} Resolves when the JSON file has been written.
+ * @throws {Error} If reading, conversion, or writing fails.
scripts/utils/readAndWriteJson.ts (1)

5-13: JSDoc for writeJSON is informative.
It accurately describes reading, conversion, writing, and error cases.

For completeness, consider adding a @returns annotation:

  * @throws {Error} If reading the file, converting its content to JSON, or writing fails.
+ * @returns {Promise<void>} Resolves when the JSON has been successfully written.
scripts/tools/combine-tools.ts (1)

49-59: Add @async tag for asynchronous function.

The JSDoc accurately describes the behavior of getFinalTool, but since it returns a promise and is declared as async, consider adding an @async annotation to the comment. This makes the asynchronous nature explicit for readers and tooling:

 /**
  * Enriches a tool object by processing its language and technology filters for display on the website.
+ * @async
  * @param toolObject - The original tool object containing filter tags.
  * @returns A promise that resolves to the updated tool object with enriched language and technology filters.
  */
 export async function getFinalTool(toolObject: AsyncAPITool): Promise<FinalAsyncAPITool> {
scripts/build-rss.ts (2)

7-11: Consider adding @async annotation.

The JSDoc for getAllPosts correctly states that it returns a promise, but adding an @async tag will make its asynchronous nature explicit:

 /**
  * Asynchronously retrieves all blog posts from the posts configuration file.
+ * @async
  * @returns A promise that resolves to the list of blog posts.
  */
 async function getAllPosts() { ... }

41-55: Include @async annotation for rssFeed.

The block documents parameters, return behavior, and errors well. Since rssFeed is declared async, adding an @async tag will improve clarity:

 /**
  * Generates and writes an RSS feed file for a specified blog post type.
+ * @async
  * @param type - The blog post type to include in the feed.
  * ...
  * @throws {Error} If any blog post is missing required fields or if an error occurs during the RSS feed generation or file writing process.
  */
 export async function rssFeed(...) { ... }
scripts/finance/index.ts (1)

18-27: Enhance JSDoc with @async and detailed param tags.

To improve clarity and tooling support, consider:

  1. Adding an @async annotation.
  2. Expanding @param props into individual @param tags for each destructured property.
 /**
- * Builds the finance information list by converting YAML configuration files to JSON format.
+ * @async
+ * Builds the finance information list by converting YAML configuration files to JSON format.
  *
- * @param props - An object containing configuration paths and the year used for locating the YAML files and determining the output directory.
+ * @param props.currentDir - The base directory path.
+ * @param props.configDir - Relative path to the config directory.
+ * @param props.financeDir - Subdirectory name for finance data.
+ * @param props.year - Year folder to process.
+ * @param props.jsonDataDir - Output directory for generated JSON files.
  * @returns A promise that resolves when the finance information list has been successfully built.
  * @throws {Error} If an error occurs during the conversion or file writing process.
  */
 export async function buildFinanceInfoList(...) { ... }
scripts/index.ts (1)

15-23: Add @async annotation to start JSDoc.

The start function orchestrates asynchronous tasks. Including an @async tag will make its async nature explicit:

 /**
+ * @async
  * Initiates the build process for the project's content.
  *
  * This asynchronous function orchestrates the creation of various content lists...
  * @throws {Error} If no numeric finance data is found in the finance directory.
  */
 async function start() { ... }
scripts/tools/extract-tools-github.ts (1)

12-20: Docstring clarifies behavior and error conditions
The updated JSDoc accurately describes search parameters, pagination, rate‐limit pause, return type, and thrown errors. Consider adding an @async tag to explicitly denote that this function is asynchronous for tooling that parses JSDoc.

scripts/tools/tools-object.ts (1)

28-41: Clear JSDoc for createToolObject
The docstring concisely explains parameter fallbacks and the constructed object. For consistency with other async utilities, you may add an @async tag.

scripts/markdown/check-markdown.ts (2)

133-142: Approve recursive file walker doc
The docstring thoroughly covers directory traversal, file filtering, validation invocation, and error conditions. For completeness, consider adding a @returns {Promise<void>} tag.


193-198: Approve main orchestration doc
The comment accurately summarizes concurrent frontmatter validation and exit behavior. Adding @returns {Promise<void>} would align it with other async functions.

scripts/dashboard/build-dashboard.ts (1)

226-234: Suggest adding @returns tag
The doc covers @param and @throws for writeToFile but omits a @returns {Promise<void>}. Including it would improve consistency.

scripts/build-post-list.ts (2)

117-127: Clarify mutation and return behavior in spec-version handler
The docstring describes the branching logic well, but it doesn’t explicitly state that the input details object is mutated in-place. Consider:

  • Adding @returns {Details} to indicate the return type.
  • Mentioning side-effects on the passed-in object.

152-171: Enhance async traversal doc with return type
Great coverage of parameters, recursion, and error cases for walkDirectories. For completeness:

  • Add a @returns {Promise<void>} tag.
  • Note that resultObj is mutated as a side effect.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed9bb80 and 2350d8c.

📒 Files selected for processing (21)
  • scripts/adopters/index.ts (1 hunks)
  • scripts/build-docs.ts (2 hunks)
  • scripts/build-meetings.ts (1 hunks)
  • scripts/build-newsroom-videos.ts (1 hunks)
  • scripts/build-pages.ts (2 hunks)
  • scripts/build-post-list.ts (6 hunks)
  • scripts/build-rss.ts (3 hunks)
  • scripts/build-tools.ts (1 hunks)
  • scripts/casestudies/index.ts (1 hunks)
  • scripts/compose.ts (1 hunks)
  • scripts/dashboard/build-dashboard.ts (9 hunks)
  • scripts/finance/index.ts (1 hunks)
  • scripts/index.ts (1 hunks)
  • scripts/markdown/check-edit-links.ts (5 hunks)
  • scripts/markdown/check-markdown.ts (4 hunks)
  • scripts/tools/combine-tools.ts (1 hunks)
  • scripts/tools/extract-tools-github.ts (1 hunks)
  • scripts/tools/tools-object.ts (2 hunks)
  • scripts/utils.ts (1 hunks)
  • scripts/utils/readAndWriteJson.ts (1 hunks)
  • utils/redirect.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (27)
scripts/utils.ts (1)

3-13: Well-documented conversion utility.
The JSDoc for convertToJson clearly outlines behavior, parameters, return type, and error conditions, matching the function logic precisely.

scripts/build-pages.ts (1)

22-29: Comprehensive doc for capitalizeJsxTags.
The updated comment accurately describes the regex-based capitalization behavior, parameter, and return value.

scripts/compose.ts (1)

24-32: Clear and concise JSDoc for genFrontMatter.
The docstring effectively explains the front matter structure, parameters, and return value, aligning with the implementation.

scripts/build-newsroom-videos.ts (1)

14-21: Excellent JSDoc enhancement.
The docstring for buildNewsroomVideos thoroughly details parameters, return type, and error conditions, matching the implementation without introducing inconsistencies.

scripts/markdown/check-edit-links.ts (4)

22-34: Comprehensive JSDoc for processBatch looks solid.
The added documentation accurately describes the HTTP HEAD request behavior, timeout handling, skip logic, return values, and error propagation.


99-106: JSDoc for determineEditLink is clear and complete.
The description accurately covers path normalization, edit option matching, fallback logic, and null return cases. Parameter and return annotations are precise.


133-145: Excellent documentation for generatePaths.
The recursive traversal, skip logic, URL/path transformation, result accumulation, and error handling are all well-described.


190-197: Well-detailed JSDoc for main.
The overall workflow, configuration loading, path generation, URL checking, logging of invalid links, and error throwing are all clearly explained.

scripts/build-rss.ts (1)

19-26: Documentation for clean is clear and concise.

The JSDoc thoroughly covers the purpose, behavior, and return value of the clean function, detailing all HTML entities handled. No changes needed here.

scripts/casestudies/index.ts (1)

7-17: JSDoc for buildCaseStudiesList is comprehensive and accurate.

The comment clearly documents the function’s behavior, parameters, return value, and error conditions, aligning well with the implementation.

scripts/tools/tools-object.ts (1)

70-81: Comprehensive JSDoc for convertTools
The updated comment accurately outlines filtering by filename, YAML-to-JSON conversion, schema validation, fuzzy category assignment, and error handling. Inclusion of an @throws tag is appropriate here.

scripts/markdown/check-markdown.ts (2)

11-16: Approve URL validation doc
The JSDoc clearly describes the purpose, parameter, and return value of isValidURL.


42-52: Approve frontmatter validation doc for blogs
The expanded doc details required fields and their format checks in validateBlogs, enhancing clarity for future maintainers.

scripts/build-docs.ts (2)

9-23: Approve buildNavTree JSDoc
This JSDoc effectively explains tree initialization, item sorting, the “reference/specification” special case, and error conditions. All parameters and throws cases are documented.


163-174: Approve addDocButtons JSDoc
The docstring clearly describes sequential document traversal, welcome page inclusion, and prev/next link logic, including parameter and return types.

scripts/dashboard/build-dashboard.ts (8)

24-31: Approve monthsSince JSDoc
Clear description of month calculation using a 30-day approximation, with correct @param and @returns.


41-50: Approve getLabel JSDoc
The comment accurately explains label extraction logic, including edge cases where no match is found.


58-68: Approve getDiscussions JSDoc
Excellent detail on recursive pagination, rate-limit warnings, pause logic, and return value.


110-119: Approve getDiscussionByID JSDoc
Comprehensive description of conditional PR vs. issue fetching, return types, and error handling.


138-148: Approve processHotDiscussions JSDoc
Well‐detailed summary of comment pagination, interaction count computation (including PR reviews), and score normalization.


196-204: Approve getHotDiscussions JSDoc
Clear documentation of batching, rate-limit pauses, sorting, bot filtering, and result sizing.


254-259: Approve mapGoodFirstIssues JSDoc
The documentation precisely explains transformation logic, filtered labels, and return structure.


280-289: Approve start orchestration JSDoc
Comprehensive summary of dashboard data fetching, processing, concurrent operations, and error logging, with correct @param and @returns.

scripts/build-post-list.ts (4)

29-38: Slug extractor docstring provides clear intent
The JSDoc for slugifyToC accurately describes its purpose, parameters, and return values. It clearly outlines the matching regex, input validation, and fallback behavior.


53-60: Capitalization helper documentation is concise and precise
The docstring for capitalize succinctly explains the transformation logic and covers the splitting/joining behavior. It’s clear and complete.


94-106: Version details parser docstring is well-structured
The JSDoc for getVersionDetails thoroughly documents how the version is parsed, normalized, and returned with weight. Parameters and return fields are clearly defined.


278-292: Post list builder docstring is comprehensive
The JSDoc for buildPostList clearly outlines validation, processing steps, error handling, @param, @returns, and @throws. No changes needed.

@akshatnema akshatnema merged commit c3af0ab into master Apr 26, 2025
31 of 32 checks passed
@akshatnema akshatnema deleted the add-docstrings branch April 26, 2025 17:48
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