Skip to content

Add support for Rails Annotations and CodeStatistics#206

Merged
januszm merged 1 commit intoslim-template:masterfrom
taketo1113:rails-codestatistics
Dec 11, 2025
Merged

Add support for Rails Annotations and CodeStatistics#206
januszm merged 1 commit intoslim-template:masterfrom
taketo1113:rails-codestatistics

Conversation

@taketo1113
Copy link
Collaborator

This Pull Request adds support for Rails Annotations and CodeStatistics.

Annotations

This Pull Request enables the rails notes command recognize TODO comments inside .slim files.

Expected behavior

Annotations inside .slim files are detected.

/app/views/ports/show.html.slim

/TODO: some comment
div
  | sample
$ rails notes
  * [    3] [TODO] some comment

Actual behavior

Annotations inside .slim files are not detected.

/app/views/ports/show.html.slim

/TODO: some comment
div
  | sample
$ rails notes

Details

Below is an example from Rails that shows how additional extensions can be registered for annotations:

# Registers new Annotations File Extensions
Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }

CodeStatistics

This change enables .slim files to be counted by the rails stats command.
Rails 8.2 (main branch) introduced a new method, Rails::CodeStatistics#register_extension, which allows gems to register additional file extensions.
When running on Rails 8.2 or later, this Pull Request registers the slim extension with Rails::CodeStatistics.

For reference, here is an example of how to register an extension:

Rails::CodeStatistics.register_extension("slim")

@taketo1113
Copy link
Collaborator Author

I opened the Issue (#207) because I encountered a situation where the slim-rails version was downgraded during local testing this feature.

@taketo1113
Copy link
Collaborator Author

I have rebased to add CI for Rails 8.1.

@januszm januszm merged commit 5fd31dc into slim-template:master Dec 11, 2025
41 checks passed
@taketo1113 taketo1113 deleted the rails-codestatistics branch December 11, 2025 12:39
@taketo1113
Copy link
Collaborator Author

Thank you for reviewing.

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.

2 participants