Skip to content

Commit

Permalink
extract Comment creation in Parser::C
Browse files Browse the repository at this point in the history
This is a prefactor for fixing comment format handling.
  • Loading branch information
flavorjones committed Oct 11, 2021
1 parent 3b8334a commit a3d366f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/rdoc/parser/c.rb
Expand Up @@ -439,7 +439,7 @@ def do_includes
next unless cls = @classes[c]
m = @known_classes[m] || m

comment = RDoc::Comment.new '', @top_level, :c
comment = new_comment '', @top_level, :c
incl = cls.add_include RDoc::Include.new(m, comment)
incl.record_location @top_level
end
Expand Down Expand Up @@ -521,7 +521,7 @@ def find_alias_comment class_name, new_name, old_name
\s*"#{Regexp.escape new_name}"\s*,
\s*"#{Regexp.escape old_name}"\s*\);%xm

RDoc::Comment.new($1 || '', @top_level, :c)
new_comment($1 || '', @top_level, :c)
end

##
Expand Down Expand Up @@ -560,7 +560,7 @@ def find_attr_comment var_name, attr_name, read = nil, write = nil
''
end

RDoc::Comment.new comment, @top_level, :c
new_comment comment, @top_level, :c
end

##
Expand Down Expand Up @@ -600,7 +600,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false

case type
when :func_def
comment = RDoc::Comment.new args[0], @top_level, :c
comment = new_comment args[0], @top_level, :c
body = args[1]
offset, = args[2]

Expand Down Expand Up @@ -630,7 +630,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false

body
when :macro_def
comment = RDoc::Comment.new args[0], @top_level, :c
comment = new_comment args[0], @top_level, :c
body = args[1]
offset, = args[2]

Expand Down Expand Up @@ -737,7 +737,7 @@ def find_class_comment class_name, class_mod
comment = ''
end

comment = RDoc::Comment.new comment, @top_level, :c
comment = new_comment comment, @top_level, :c
comment.normalize

look_for_directives_in class_mod, comment
Expand Down Expand Up @@ -782,7 +782,7 @@ def find_const_comment(type, const_name, class_name = nil)
table[const_name] ||
''

RDoc::Comment.new comment, @top_level, :c
new_comment comment, @top_level, :c
end

##
Expand Down Expand Up @@ -813,7 +813,7 @@ def find_override_comment class_name, meth_obj

return unless comment

RDoc::Comment.new comment, @top_level, :c
new_comment comment, @top_level, :c
end

##
Expand Down Expand Up @@ -947,7 +947,7 @@ def handle_constants(type, var_name, const_name, definition)

new_comment = "#{$1}#{new_comment.lstrip}"

new_comment = RDoc::Comment.new new_comment, @top_level, :c
new_comment = self.new_comment(new_comment, @top_level, :c)

con = RDoc::Constant.new const_name, new_definition, new_comment
else
Expand Down Expand Up @@ -1222,4 +1222,7 @@ def scan
@top_level
end

def new_comment text = nil, location = nil, language = nil
RDoc::Comment.new(text, location, language)
end
end

0 comments on commit a3d366f

Please sign in to comment.