Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor the 'Edit this page on GitHub' workflow (#3221) #3546

Closed
wants to merge 2 commits into from

Conversation

ChaitanyaKadu03
Copy link

@ChaitanyaKadu03 ChaitanyaKadu03 commented Jan 5, 2025

Description

This Pull Request addresses the broken or incorrect “Edit this page on GitHub” links by modifying two key files:

  1. config/edit-page-config.json

    • Changed tree/master references to blob/master.
    • Updated paths for /tools/generator, /tools/cli, and other sections:
      - "https://github.com/asyncapi/generator/tree/master/docs"
      + "https://github.com/asyncapi/generator/blob/master/apps/generator/docs"
      
      - "https://github.com/asyncapi/cli/tree/master/docs"
      + "https://github.com/asyncapi/cli/blob/master/docs"
      
      - "https://github.com/asyncapi/extensions-catalog/tree/master/extensions"
      + "https://github.com/asyncapi/extensions-catalog/blob/master/extensions"
      
      (etc.)
  2. components/layout/DocsLayout.tsx

    • Modified the link logic to remove the trailing slash via last.slice(0, -1):
      - <a target="_blank" rel="noopener noreferrer" href={`${target?.href}/${last}`} className="ml-1 underline">
      + <a target="_blank" rel="noopener noreferrer" href={`${target?.href}/${last.slice(0, -1)}`} className="ml-1 underline">

These changes ensure the “Edit this page” link directs contributors to the correct markdown files on GitHub.

Related Issue

Closes #3221.

Additional Notes

Recording.2025-01-06.001601.1.mp4

Checklist

  • Issue #3221 is linked and will close automatically on merge.
  • All commits are signed or follow the commit message guidelines.

@sambhavgupta0705 @anshgoyalevil @akshatnema

Summary by CodeRabbit

  • Bug Fixes
    • Corrected GitHub documentation links for AsyncAPI generator, CLI, and extensions catalog to point directly to specific files.
    • Fixed edit page link generation to ensure accurate URL construction.

Copy link

coderabbitai bot commented Jan 5, 2025

Walkthrough

The pull request introduces changes to improve the GitHub edit link functionality. In the DocsLayout component, a modification is made to the generateEditLink function, adjusting how the URL is constructed. Additionally, the edit-page-config.json file is updated to correct documentation links, changing from tree to blob endpoints for various AsyncAPI project documentation links.

Changes

File Change Summary
components/layout/DocsLayout.tsx Modified generateEditLink function to slice the last character when constructing the GitHub edit link
config/edit-page-config.json Updated GitHub documentation links for AsyncAPI generator, CLI, and extensions catalog from tree to blob endpoints

Assessment against linked issues

Objective Addressed Explanation
Fix incorrect "Edit this page on GitHub" links [#3221]

Poem

🐰 A rabbit's tale of links so bright,
Slicing URLs with coding might,
From tree to blob, we hop along,
Fixing paths where they belong,
GitHub's edit page now shines just right! 🔗


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2efd2c8 and b9cc3c4.

📒 Files selected for processing (1)
  • components/layout/DocsLayout.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/layout/DocsLayout.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Jan 5, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b9cc3c4
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/677adf2e45a0b30008e72c92
😎 Deploy Preview https://deploy-preview-3546--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.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Jan 5, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 39
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

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

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fb0a3bf and 2efd2c8.

📒 Files selected for processing (2)
  • components/layout/DocsLayout.tsx (1 hunks)
  • config/edit-page-config.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • config/edit-page-config.json
🧰 Additional context used
🪛 GitHub Actions: PR testing - if Node project
components/layout/DocsLayout.tsx

[error] 63-63: Prettier formatting error: Attributes should be on separate lines for better readability in target='_blank' rel='noopener noreferrer' href element

🔇 Additional comments (1)
components/layout/DocsLayout.tsx (1)

63-63: Validate slicing logic for the post ID
Removing the last character from last will break the link if there is no trailing slash or extra character at the end. Consider checking whether the post ID actually ends with a slash (or any undesired character) before slicing.

You can run a quick search to confirm that post.id or last always has an extra trailing slash:

✅ Verification successful

Let me gather more context about how post.id is structured and used.


Let me check how the post.id is structured by looking at where it's defined and any test files.


Let me try a different approach to understand the post structure and usage.


Let me check the post type definition and any example usage.


Based on the code analysis, I can now provide a final response:

The slicing logic is safe and intentional
The code in DocsLayout.tsx shows that last is derived from post.id using substring(post.id.lastIndexOf('/') + 1), which means it already contains just the final segment after the last slash. The slice(0, -1) operation is intentionally removing the trailing character (likely a file extension) to construct the correct GitHub edit URL based on the editOptions configuration.

Additionally, there's a safety check with if (isHrefToFile) last = '' that prevents any potential issues when the target is a direct file path.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential references or usage of 'post.id' or 'last' in the codebase to confirm trailing slash patterns:
rg 'post\.id|last\s*=' -A 3

Length of output: 619


Script:

#!/bin/bash
# Search for assignments or declarations of post.id to understand its structure
ast-grep --pattern 'post.id = $_'

# Also search for any direct usage of post.id
rg "post\.id" -B 2 -A 2

# Let's also check the structure of the entire component
cat components/layout/DocsLayout.tsx

Length of output: 9292


Script:

#!/bin/bash
# Search for IPost interface definition to understand post.id structure
ast-grep --pattern 'interface IPost {
  $$$
}'

# Look for any test files that might show example post.id values
rg -g '*.test.*' -g '*.spec.*' "post\.id"

# Check for any mock data files that might contain example posts
fd -e json -e ts mock

Length of output: 116


Script:

#!/bin/bash
# Look for the IPost type definition
rg "interface IPost" -A 15

# Check the getAllPosts implementation since it's used in the component
rg "getAllPosts" -A 5

# Look for any files that might contain post data structure
fd -e ts -e tsx -e json . | rg -i "post|docs"

Length of output: 5326


Script:

#!/bin/bash
# Check the post type definition
cat types/post.ts

# Look for any example usage in the codebase
rg -g '*.json' '"id":' -B 1 -A 3

# Check the edit options configuration
cat config/edit-page-config.json

Length of output: 20894

🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[error] 63-63: Prettier formatting error: Attributes should be on separate lines for better readability in target='_blank' rel='noopener noreferrer' href element

@@ -60,7 +60,7 @@ function generateEditLink(post: IPost) {
if (isHrefToFile) last = '';

return (
<a target='_blank' rel='noopener noreferrer' href={`${target?.href}/${last}`} className='ml-1 underline'>
<a target='_blank' rel='noopener noreferrer' href={`${target?.href}/${last.slice(0, -1)}`} className='ml-1 underline'>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve Prettier formatting error
The pipeline reports a formatting error for this anchor element. According to the style guidelines, each attribute should be placed on its own line.

Below is a proposed fix:

-    <a target='_blank' rel='noopener noreferrer' href={`${target?.href}/${last.slice(0, -1)}`} className='ml-1 underline'>
+    <a
+      target='_blank'
+      rel='noopener noreferrer'
+      href={`${target?.href}/${last.slice(0, -1)}`}
+      className='ml-1 underline'
+    >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a target='_blank' rel='noopener noreferrer' href={`${target?.href}/${last.slice(0, -1)}`} className='ml-1 underline'>
<a
target='_blank'
rel='noopener noreferrer'
href={`${target?.href}/${last.slice(0, -1)}`}
className='ml-1 underline'
>
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[error] 63-63: Prettier formatting error: Attributes should be on separate lines for better readability in target='_blank' rel='noopener noreferrer' href element

Semantic PR Title Check
Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (fb0a3bf) to head (b9cc3c4).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3546   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          668       668           
=========================================
  Hits           668       668           

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

@ChaitanyaKadu03 ChaitanyaKadu03 changed the title fix: Refactor the 'Edit this page on GitHub' workflow (#3221) fix: refactor the 'Edit this page on GitHub' workflow (#3221) Jan 5, 2025
@aeworxet
Copy link
Contributor

aeworxet commented Jan 6, 2025

@ChaitanyaKadu03

The GitHub issue participates in the AsyncAPI Bounty Program and is the responsibility of the assigned user.

You are welcome to choose another GitHub issue for contribution that does not have the bounty label.

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.

Refactor the edit-this-page-on-github workflow
4 participants