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

Highlighting multi-line comments #2150

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Highlighting multi-line comments #2150

wants to merge 13 commits into from

Conversation

KesterTan
Copy link
Contributor

@KesterTan KesterTan commented Apr 22, 2024

Fixes #1732.

Before, multi-line comments were not highlighted:
Screenshot 2024-04-22 at 4 50 42 PM

With this change:
Screenshot 2024-04-22 at 4 51 06 PM

How Has This Been Tested?

  • Try out with different submissions and check that multi-line comments are now highlighted.
  • Other code highlighted is not affected.
  • You can still leave behind annotations etc.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Summary by CodeRabbit

  • New Features

    • Implemented comment highlighting in code blocks, enhancing readability by styling comments in green.
  • Style

    • Improved indentation and formatting of existing HTML and Ruby code for better readability.
  • Refactor

    • Added a new SCSS variable for comment highlight color, ensuring consistent styling across the app.

Copy link
Contributor

coderabbitai bot commented Apr 22, 2024

Walkthrough

Walkthrough

The changes introduce JavaScript logic to combine and highlight code blocks with comments in the view, ensuring comments are styled separately. Additionally, new styling for comments is added in the stylesheets, and a new color variable is defined for consistency. Event listeners are also added to trigger the highlighting function upon loading and navigation.

Changes

Files Change Summary
app/views/submissions/view.html.erb Added JavaScript logic to highlight comments, event listeners for DOMContentLoaded and navigate, improved formatting.
app/assets/stylesheets/annotations.scss Added styling for comments, setting their color to green (#008000).
app/assets/stylesheets/_variables.scss Added a new variable $autolab-highlight-comments with the color #008000.

Assessment against linked issues

Objective Addressed Explanation
Syntax highlighting for multiple line comments (Issue #1732)

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4c3cbb6 and 0fd4684.
Files selected for processing (1)
  • app/views/submissions/view.html.erb (2 hunks)
Additional comments not posted (1)
app/views/submissions/view.html.erb (1)

98-103: Ensure event listeners are correctly set up.

The event listeners for DOMContentLoaded and custom navigate events are correctly set up to call the highlightComments function. Ensure that these event listeners do not introduce any performance issues, especially if the highlightComments function is computationally expensive.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

app/views/submissions/view.html.erb Outdated Show resolved Hide resolved
app/views/submissions/view.html.erb Outdated Show resolved Hide resolved
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: 2

app/views/submissions/view.html.erb Outdated Show resolved Hide resolved
app/views/submissions/view.html.erb Outdated Show resolved Hide resolved
@KesterTan KesterTan requested review from a team and 20wildmanj and removed request for a team April 22, 2024 21:52
@20wildmanj
Copy link
Contributor

20wildmanj commented Apr 25, 2024

It seems that on initial load, the highlighting works, but switching to other files breaks the highlighting (the file will revert back to broken highlighting

highlighting-broke.mov

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

app/views/submissions/view.html.erb Outdated Show resolved Hide resolved
@20wildmanj
Copy link
Contributor

Discussed offline that this PR still has some issues with highlighting, so needs a second attempt / revision.

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

app/views/submissions/view.html.erb Show resolved Hide resolved
app/views/submissions/view.html.erb Show resolved Hide resolved
app/views/submissions/view.html.erb Show resolved Hide resolved
@KesterTan
Copy link
Contributor Author

Updated highlighting code highlights code even if we change files.

Highlighting code also takes into account keywords such as "#include', previously these were flagged out as comments.

Screenshot 2024-05-15 at 2 42 21 PM

To check that it works as expected, check that the output is the same as that in: https://highlightjs.org/demo

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.

No syntax highlighting for multiple line comments
2 participants