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

Share comment generation logic #1747

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/java/org/prism/Nodes.java.erb
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public abstract class Nodes {
<%- nodes.each do |node| -%>

/**
<%- node.comment.each_line do |line| -%>
*<%= line.prepend(" ").rstrip %>
<%- node.each_comment_line do |line| -%>
*<%= line %>
<%- end -%>
*/
public static final class <%= node.name -%> extends Node {
Expand Down
4 changes: 2 additions & 2 deletions templates/javascript/src/nodes.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const <%= flag.name %> = {
<%- nodes.each do |node| -%>

/**
<%- node.comment.each_line do |line| -%>
*<%= line.prepend(" ").rstrip %>
<%- node.each_comment_line do |line| -%>
*<%= line %>
<%- end -%>
*/
export class <%= node.name -%> {
Expand Down
4 changes: 2 additions & 2 deletions templates/lib/prism/node.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module Prism
end
<%- nodes.each do |node| -%>

<%- node.comment.each_line do |line| -%>
#<%= line.prepend(" ").rstrip %>
<%- node.each_comment_line do |line| -%>
#<%= line %>
<%- end -%>
class <%= node.name -%> < Node
<%- node.fields.each do |field| -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/rbi/prism.rbi.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

module Prism
<%- nodes.each do |node| -%>
<%- node.comment.each_line do |line| -%>
#<%= line.prepend(" ").rstrip %>
<%- node.each_comment_line do |line| -%>
#<%= line %>
<%- end -%>
class <%= node.name -%> < Node
<%- node.fields.each do |field| -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/sig/prism.rbs.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Prism
<%- nodes.each do |node| -%>
<%- node.comment.each_line do |line| -%>
#<%= line.prepend(" ").rstrip %>
<%- node.each_comment_line do |line| -%>
#<%= line %>
<%- end -%>
class <%= node.name -%> < Node
<%- node.fields.each do |field| -%>
Expand Down
4 changes: 4 additions & 0 deletions templates/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ def initialize(config)
@comment = config.fetch("comment")
end

def each_comment_line
comment.each_line { |line| yield line.prepend(" ").rstrip }
end

def semantic_fields
@semantic_fields ||= @fields.select(&:semantic_field?)
end
Expand Down