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

Merged
merged 16 commits into from
Jun 5, 2024
Merged

Highlighting multi-line comments #2150

merged 16 commits into from
Jun 5, 2024

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

Copy link
Contributor

coderabbitai bot commented Apr 22, 2024

Walkthrough

Walkthrough

The changes introduce JavaScript logic and CSS styles to highlight comments in code blocks within the view.html.erb file. A new function highlightComments() processes and styles comments, which are colored green using a new SCSS variable. Event listeners are added to ensure this function runs on page load and navigation events. These updates improve the readability and visual distinction of comments in the code view.

Changes

File Change Summary
app/views/submissions/view.html.erb Added highlightComments() function, event listeners for DOMContentLoaded and navigate, and updated HTML elements for better readability.
app/assets/stylesheets/annotations.scss Added styling for comments in code blocks, setting the color to green (#008000).
app/assets/stylesheets/_variables.scss Added a new SCSS variable $autolab-highlight-comments with the color #008000.

Assessment against linked issues

Objective Addressed Explanation
Ensure multi-line comments are highlighted correctly (#1732)
Add a new SCSS variable for comment color (#1732)
Introduce JavaScript function to process and style comments (#1732)
Update event listeners to call the new function on page load and navigation events (#1732)

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54ea9c9 and 1eeae38.

Files selected for processing (1)
  • app/views/submissions/view.html.erb (2 hunks)

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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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 Outdated 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

@20wildmanj
Copy link
Contributor

Screenshot 2024-05-21 at 8 57 23 AM

seems like the issue with #include getting turned into a comment also happens with #define. Functionally though the multi-line comments seem to work a lot more reliably now. Might be worth looking into updating highlight.js since it seems like the local highlight.pack.js was last updated in 2015, so these issues might have been fixed in later releases. Other than nit, LGTM for the most part.

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

Outside diff range and nitpick comments (1)
app/views/submissions/view.html.erb (1)

126-131: Ensure accessibility and usability in UI elements.

The navigation buttons and download link could benefit from improved accessibility features. Consider adding aria-label attributes to provide better context for screen readers. For example:

<a href="<%= download_file_url(@submission) %>" class="btn small" title="Download" aria-label="Download submission">Download</a>
<button class="btn small" onclick="resetLayout()" aria-label="Reset layout of the page">Reset Layout</button>

Adding these attributes helps users with screen readers understand the function of these buttons without needing to rely solely on visual cues.

app/views/submissions/view.html.erb Show resolved Hide resolved
@KesterTan KesterTan added this pull request to the merge queue Jun 5, 2024
Merged via the queue into master with commit 7439e90 Jun 5, 2024
5 checks passed
@KesterTan KesterTan deleted the highlighting branch June 5, 2024 18:42
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