Skip to content

Commit 5ce4a5d

Browse files
committed
Stop documenting visitor implementation details
These result in so many methods that are searchable and give no actual benefit. Toplevel docs are all you need to understand the usecase.
1 parent e993cce commit 5ce4a5d

5 files changed

Lines changed: 12 additions & 19 deletions

File tree

templates/lib/prism/compiler.rb.erb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ module Prism
1818
#
1919
class Compiler < Visitor
2020
# Visit an individual node.
21-
def visit(node)
21+
def visit(node) # :nodoc:
2222
node&.accept(self)
2323
end
2424

2525
# Visit a list of nodes.
26-
def visit_all(nodes)
26+
def visit_all(nodes) # :nodoc:
2727
nodes.map { |node| node&.accept(self) }
2828
end
2929

3030
# Visit the child nodes of the given node.
31-
def visit_child_nodes(node)
31+
def visit_child_nodes(node) # :nodoc:
3232
node.each_child_node.map { |node| node.accept(self) }
3333
end
3434

3535
<%- nodes.each_with_index do |node, index| -%>
3636
<%= "\n" if index != 0 -%>
37-
# Compile a <%= node.name %> node
38-
def visit_<%= node.human %>(node)
37+
def visit_<%= node.human %>(node) # :nodoc:
3938
node.each_child_node.map { |node| node.accept(self) }
4039
end
4140
<%- end -%>

templates/lib/prism/dispatcher.rb.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ module Prism
7373
end
7474
<%- nodes.each do |node| -%>
7575

76-
# Dispatch enter and leave events for <%= node.name %> nodes and continue
77-
# walking the tree.
78-
def visit_<%= node.human %>(node)
76+
def visit_<%= node.human %>(node) # :nodoc:
7977
listeners[:on_<%= node.human %>_enter]&.each { |listener| listener.on_<%= node.human %>_enter(node) }
8078
super
8179
listeners[:on_<%= node.human %>_leave]&.each { |listener| listener.on_<%= node.human %>_leave(node) }

templates/lib/prism/dot_visitor.rb.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ module Prism
106106
end
107107
<%- nodes.each do |node| -%>
108108

109-
# Visit a <%= node.name %> node.
110-
def visit_<%= node.human %>(node)
109+
def visit_<%= node.human %>(node) # :nodoc:
111110
table = Table.new("<%= node.name %>")
112111
id = node_id(node)
113112
<%- if (node_flags = node.flags) -%>

templates/lib/prism/inspect_visitor.rb.erb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ module Prism
1717
private_constant :Replace
1818

1919
# The current prefix string.
20-
attr_reader :indent
20+
attr_reader :indent # :nodoc:
2121

2222
# The list of commands that we need to execute in order to compose the
2323
# final string.
24-
attr_reader :commands
24+
attr_reader :commands # :nodoc:
2525

26-
# Initializes a new instance of the InspectVisitor.
27-
def initialize(indent = +"")
26+
def initialize(indent = +"") # :nodoc:
2827
@indent = indent
2928
@commands = []
3029
end
@@ -37,7 +36,7 @@ module Prism
3736
end
3837

3938
# Compose the final string.
40-
def compose
39+
def compose # :nodoc:
4140
buffer = +""
4241
replace = nil
4342

@@ -66,8 +65,7 @@ module Prism
6665
end
6766
<%- nodes.each do |node| -%>
6867

69-
# Inspect a <%= node.name %> node.
70-
def visit_<%= node.human %>(node)
68+
def visit_<%= node.human %>(node) # :nodoc:
7169
commands << [inspect_node(<%= node.name.inspect %>, node), indent]
7270
<%- (fields = [node.flags || Prism::Template::Flags.empty, *node.fields]).each_with_index do |field, index| -%>
7371
<%- pointer = index == fields.length - 1 ? "└── " : "├── " -%>

templates/lib/prism/mutation_compiler.rb.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module Prism
55
class MutationCompiler < Compiler
66
<%- nodes.each_with_index do |node, index| -%>
77
<%= "\n" if index != 0 -%>
8-
# Copy a <%= node.name %> node
9-
def visit_<%= node.human %>(node)
8+
def visit_<%= node.human %>(node) # :nodoc:
109
<%- fields = node.fields.select { |field| [Prism::Template::NodeField, Prism::Template::OptionalNodeField, Prism::Template::NodeListField].include?(field.class) } -%>
1110
<%- if fields.any? -%>
1211
node.copy(<%= fields.map { |field| "#{field.name}: #{field.is_a?(Prism::Template::NodeListField) ? "visit_all" : "visit"}(node.#{field.name})" }.join(", ") %>)

0 commit comments

Comments
 (0)