Skip to content

feat(comments): add comment support#6885

Open
JuergenRB wants to merge 1 commit intousebruno:mainfrom
juergenrb-forks:feature/comments
Open

feat(comments): add comment support#6885
JuergenRB wants to merge 1 commit intousebruno:mainfrom
juergenrb-forks:feature/comments

Conversation

@JuergenRB
Copy link
Copy Markdown

@JuergenRB JuergenRB commented Jan 21, 2026

This PR only adds comment support functionality (#1371)
The changes are additive and don't modify existing behavior.

Example:

# Top-level comment before meta block

meta {
  # Comment inside meta block
  name: Test Request with Comments
  type: http
  // Another comment style
  seq: 1
}

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for comments in request and environment files
    • Both # and // comment styles are now recognized throughout the language, including in meta, headers, parameters, variables, assertions, and other blocks
  • Tests

    • Added comprehensive test coverage for comment parsing in various contexts and configurations

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

Copilot AI review requested due to automatic review settings January 21, 2026 22:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comment support to the Bruno language parser, allowing users to add # and // style comments in .bru files, collection files, and environment files. Comments can appear at the top level, between blocks, and inside dictionary, list, and assert blocks.

Changes:

  • Extended grammar rules to recognize comment syntax in all file types
  • Added semantic handling to filter out comments during parsing
  • Created comprehensive test coverage for comment functionality across different block types

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/bruno-lang/v2/src/bruToJson.js Updated grammar to support comments in BruFiles, dictionaries, lists, and assert blocks
packages/bruno-lang/v2/src/collectionBruToJson.js Added comment support to collection file grammar
packages/bruno-lang/v2/src/envToJson.js Extended environment file grammar to handle comments
packages/bruno-lang/v2/tests/comments.spec.js Comprehensive test suite covering various comment scenarios in bru files
packages/bruno-lang/v2/tests/envComments.spec.js Test cases for comment support in environment files
packages/bruno-lang/v2/tests/examples/examples.spec.js Added tests for example files with comments
packages/bruno-lang/v2/tests/examples/fixtures/bru/example-with-comments.bru Example fixture demonstrating comment usage
packages/bruno-lang/v2/tests/examples/fixtures/bru/test-comments-in-blocks.bru Test fixture with comments in various block types
packages/bruno-lang/v2/tests/examples/fixtures/json/example-with-comments.json Expected JSON output for example-with-comments.bru
packages/bruno-lang/v2/tests/examples/fixtures/json/test-comments-in-blocks.json Expected JSON output for test-comments-in-blocks.bru

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

Walkthrough

This PR extends the Bruno language parser to recognize and handle comments (starting with # or //) in BRU files and environment files. Comments are parsed as valid grammar elements but filtered out from the final AST, allowing inline documentation without affecting serialized output.

Changes

Cohort / File(s) Summary
Grammar Extensions
packages/bruno-lang/v2/src/bruToJson.js, packages/bruno-lang/v2/src/collectionBruToJson.js, packages/bruno-lang/v2/src/envToJson.js
Added comment and commentstart rules to recognize single-line comments. Extended BruFile and BruEnvFile productions to accept comments. Introduced pairitem/assertpairitem/listentry routing to allow comments within block structures (headers, params, vars, assert). Semantic handlers return null for comments; pairlist/assertpairlist/listitems filter out null entries, effectively stripping comments from final AST.
Test Suite
packages/bruno-lang/v2/tests/comments.spec.js, packages/bruno-lang/v2/tests/envComments.spec.js
Added 282 lines testing comment parsing in BRU files (# and // in meta, headers, params, vars, assert, auth blocks) and 54 lines testing env file comments. Verify comments are ignored while meaningful fields are preserved.
Fixture Tests & Examples
packages/bruno-lang/v2/tests/examples/examples.spec.js, packages/bruno-lang/v2/tests/examples/fixtures/bru/*, packages/bruno-lang/v2/tests/examples/fixtures/json/*
Added two new fixture-driven tests (example-with-comments, test-comments-in-blocks) with corresponding BRU and JSON fixtures demonstrating complete requests with inline comments at various nesting levels (meta, headers, params, vars, assert, tests, docs).

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested Labels

size/L

Suggested Reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno

Poem

Comments bloom in Bru's design,
Marked with # or // so fine,
Parsed but filtered, clean and neat,
Making documentation sweet. 💬✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(comments): add comment support' clearly and concisely describes the main objective of the changeset—adding comment functionality to the Bru language parser.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants