Skip to content

fix: make snakemake variable colorful in functions ... #44

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

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

Conversation

Hocnonsense
Copy link
Contributor

@Hocnonsense Hocnonsense commented Apr 4, 2025

... and also make string without assignment (so called 'docstring' in python syntaxes) as colorful as other strings.

The README is updated as well and more descriptions about the keywords are added

image

Summary by CodeRabbit

  • Documentation

    • Updated and expanded the user guide with clearer explanations and examples for Snakemake keywords, rules, parameters, and usage sections.
  • New Features

    • Enhanced syntax highlighting for Snakemake scripts, offering more accurate visual representation of function calls, arguments, string formats, and embedded shell commands.

Copy link

coderabbitai bot commented Apr 4, 2025

📝 Walkthrough

Walkthrough

The changes standardize formatting and update documentation and syntax definitions for the Snakemake project. The launch configuration now uses spaces instead of tabs for the "version" attribute. The README has been expanded and clarified to detail keywords, rules, modules, functions, and related usage examples along with a new TODO section. Additionally, the syntax files have been revised by removing deprecated patterns and introducing new ones—such as for function calls, function arguments, string handling, and shell commands—to improve the parsing consistency of Snakemake files.

Changes

File(s) Change Summary
.vscode/launch.json Replaced tab indentation with spaces for the "version" attribute.
README.md Enhanced documentation for Snakemake keywords, rules, modules, and functions; added examples and a new TODO section.
src/yaml/snakemake.syntax.yaml, syntaxes/snakemake.tmLanguage.json Revised syntax definitions by removing outdated patterns and adding new ones (e.g., function-call, function-arguments, quoteall, snakemakenames, rulesrefernce, snakestrings, shellzone); updated captures for improved parsing consistency.

Suggested labels

help wanted

Suggested reviewers

  • johanneskoester

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration 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

@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

🧹 Nitpick comments (3)
syntaxes/snakemake.tmLanguage.json (1)

162-176: Review of the Quotessmall Pattern Configuration
The quotessmall block now delegates string handling to #quoteall and further includes #snakemakenames. While this structure is consistent with the new model, consider verifying that the naming conveys the intended hierarchy to future maintainers.

src/yaml/snakemake.syntax.yaml (2)

7-7: Removal of Shellzone Inclusion
Commenting out (or removing) the "#shellzone" inclusion simplifies the overall patterns list. Verify that shell command highlighting is still addressed within another part of the syntax definitions.


78-84: Structure for Small Quotes
The quotessmall block now uses an inclusion-based approach (referencing #quoteall and #snakemakenames) to handle smaller quoted strings in a consistent manner.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd8d7ed and 0fb89a4.

📒 Files selected for processing (4)
  • .vscode/launch.json (1 hunks)
  • README.md (1 hunks)
  • src/yaml/snakemake.syntax.yaml (4 hunks)
  • syntaxes/snakemake.tmLanguage.json (10 hunks)
🔇 Additional comments (39)
.vscode/launch.json (1)

6-6: Indentation Standardization: Using Spaces Instead of Tabs
Changing the indentation for the "version" attribute to spaces improves consistency across configuration files. This update is purely stylistic and does not affect functionality.

README.md (2)

29-41: Clearer Documentation for Keywords and Functions
Linking the "Keywords and Functions" header directly to src/keywords.yaml enhances discoverability and clarifies where users can find the syntax definitions. The accompanying explanations and code examples make it easier to understand the expected format in a snakefile.


104-108: Expanded TODO Section for Future Enhancements
The updated TODO list now includes tasks to recognize file strings after keywords (like include:, conda, snakefile) and to add bash coloring to docstrings within the shell: block. These items clearly lay out future improvement directions and help maintain a forward-looking roadmap.

syntaxes/snakemake.tmLanguage.json (18)

10-10: Addition of Snakestrings Pattern
Including "#snakestrings" in the patterns array consolidates string handling by replacing the previous multiple quote patterns. This change improves maintainability and ensures consistency throughout the syntax file.


40-40: Integration of Function Call Pattern
Adding the "#function-call" pattern into the overall patterns array ensures that function calls are detected and highlighted correctly. This contributes to more accurate syntax parsing.


43-43: Consolidating String Handling with #quoteall
The inclusion of "#quoteall" helps centralize the handling of quoted strings, replacing the older separate quote patterns. This consolidation leads to a simpler and more unified approach.


46-46: Enhanced Recognition with #snakemakenames
Introducing "#snakemakenames" aids in better recognizing identifiers (such as classes, rules, or functions) within Snakemake scripts, aligning with the updated syntax rules.


53-80: Refactored Function Call Pattern
The function-call block now clearly defines the regular function call syntax with well-structured boundaries and nested includes (for classes, functions, special variables, etc.). This improves both clarity and maintainability.


81-148: Robust Function Arguments Pattern
The function-arguments block is comprehensive—it handles argument separation, unpacks operators, and includes validation for assignments. Its use of nested includes for names and expressions covers a broad set of scenarios reliably.


149-161: Maintaining Legacy Quote Patterns via #quoteall
Although the quoteall pattern still references the older quote patterns (#quotessmall, #quotesmid, #quotesbig), this design ensures backward compatibility while transitioning to the new unified strings approach.


177-191: Consistent Configuration for the Quotes Mid Pattern
The quotesmid pattern is set up in the same fashion as the other quote blocks, ensuring that medium-length strings are parsed consistently.


192-206: Consistent Configuration for the Quotes Big Pattern
The quotesbig block follows the established pattern by including #quoteall and #snakemakenames, which helps correctly parse larger string constructs.


187-194: Introduced snakemakenames Pattern in Repository
The new snakemakenames block aggregates various includes (classes, rules references, objects, rule arguments, and functions) to streamline identifier recognition. This is a helpful addition for maintaining a consistent syntax highlighting scheme.


351-361: Rules Reference Pattern Accuracy
The rulesrefernce block accurately captures rule and checkpoint references (e.g., rules.<identifier>), ensuring that these elements are clearly highlighted.


363-370: Object Identifiers Highlighting
The objects block is succinct and effectively marks well-known Snakemake entities (like snakemake, rules, etc.), aiding in their immediate identification.


372-382: Function Rule Argument Pattern Improvement
The ruleargargs block is refined to capture rule-specific arguments with improved naming specificity, ensuring that these elements are highlighted uniformly.


384-391: Consistent Rule Arguments Capture
The ruleargs block standardizes how rule arguments are recognized, resulting in reliable and consistent highlighting across Snakemake scripts.


392-399: Efficient Built-in Function Highlighting
The functions block clearly specifies a regex to capture built-in Snakemake functions. This ensures that key functionalities are easily distinguishable within the code.


400-425: Enhanced Snakestrings Pattern for Docstrings
The newly introduced snakestrings pattern consolidates various string quoting styles (including docstrings) and sets clear boundaries for string definitions, thereby improving syntax accuracy.


426-440: Embedded Shell Command Highlighting
The shellzone block correctly identifies and scopes shell command sections within Snakemake files. Its use of the while clause ensures proper handling of nested shell fragments.


441-460: Dedicated Pattern for Shell Strings
The snakeshellstrings block is well-configured to handle shell-specific string constructs. It preserves proper string delimiters as found in Python, ensuring that embedded shell strings are highlighted correctly.

src/yaml/snakemake.syntax.yaml (18)

8-8: Addition of Snakestrings Pattern
Adding "#snakestrings" to the patterns list in the YAML file aligns this file with the TM Language JSON updates and centralizes string handling.


18-18: Integration of Function Call Pattern
The inclusion of "#function-call" in the YAML file ensures that function call constructs are parsed consistently with the JSON definition, enhancing overall syntax support.


19-19: Utilization of Unified Quote Handling with #quoteall
Switching to the "#quoteall" pattern replaces the older segmented quote patterns, resulting in a more streamlined approach to parsing various string literals.


20-20: Enhanced Identifier Recognition with #snakemakenames
The addition of "#snakemakenames" improves the recognition of identifiers across the syntax, aligning with the new approach taken in the JSON file.


24-41: Refined Function Call Pattern in YAML
The function-call block now clearly defines how function calls are recognized, including a comment that clarifies its purpose. Nested includes (for classes, functions, and special variables) reinforce consistency with the overall syntax rules.


73-77: Unified Quote Handling Using #quoteall
The quoteall block aggregates the previously separate quote patterns into one unified structure. This change simplifies future maintenance and ensures consistent string parsing across the file.


85-91: Configuration for Medium Quotes
The quotesmid pattern is configured similarly to the other quote blocks, ensuring that medium-length strings adhere to the same parsing rules for improved consistency.


92-98: Configuration for Big Quotes
The quotesbig block mirrors the configuration of the smaller quote patterns, ensuring that even larger string structures are handled reliably.


187-194: Introduced snakemakenames Pattern
The new snakemakenames block consolidates various identifier includes (classes, rules references, objects, and functions), which streamlines the colorization of identifiers throughout Snakemake scripts.


195-199: Classes Pattern Verification
The classes block uses a clear regex to match class-like identifiers, ensuring these entities are highlighted consistently.


200-205: Accurate Rules Reference Matching
The rulesrefernce block is designed to detect patterns such as rules.<identifier>, providing precise highlighting for rule or checkpoint references.


206-210: Object Recognition Enhancements
The objects block effectively identifies key Snakemake objects, helping differentiate them from other identifiers in the code.


211-216: Rule Arguments with Additional Detail
The ruleargargs block captures compound expressions (such as input.variable), improving clarity when multiple argument references are in play.


217-220: Concise Rule Arguments Matching
The ruleargs block provides a streamlined pattern for recognizing rule arguments, which contributes to a consistent highlighting strategy.


221-224: Consistent Function Highlighting
The functions block matches and highlights built-in functions in a manner that is easy to read and maintain, following the improvements made in the JSON syntax file.


225-237: Introduction of snakestrings for Docstrings
The new snakestrings block centralizes the handling of various quoted strings (including docstrings) and defines clear start/end boundaries, thereby enhancing the accuracy of string highlighting.


238-244: Handling Embedded Shell Commands
The shellzone block is correctly defined to capture embedded shell command regions, ensuring that such sections are parsed with their proper context and indentation maintained.


245-256: Embedded Shell String Extraction
The snakeshellstrings block provides a dedicated mechanism to handle shell-specific quoted strings, aligning with the syntax and formatting guidelines of embedded shell code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

1 participant