[ruby/rdoc] Improve rubocop setup
(https://github.com/ruby/rdoc/pull/1139) * Rename rake rubocop to rake format_generated_files * Add rubocop rules to ensure spaces are applied consistently * Improve rubocop related CI workflows https://github.com/ruby/rdoc/commit/27932d001c
This commit is contained in:
parent
573c2893dc
commit
239d54dfbc
@ -70,7 +70,7 @@ class RDoc::Alias < RDoc::CodeObject
|
|||||||
# HTML id-friendly version of +#new_name+.
|
# HTML id-friendly version of +#new_name+.
|
||||||
|
|
||||||
def html_name
|
def html_name
|
||||||
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
|
@ -268,8 +268,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|||||||
when 'const_get' then 'const'
|
when 'const_get' then 'const'
|
||||||
when 'new' then
|
when 'new' then
|
||||||
$1.split('::').last. # ClassName => class_name
|
$1.split('::').last. # ClassName => class_name
|
||||||
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
||||||
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
||||||
downcase
|
downcase
|
||||||
else
|
else
|
||||||
$2
|
$2
|
||||||
@ -291,7 +291,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|||||||
def html_name
|
def html_name
|
||||||
require 'cgi/util'
|
require 'cgi/util'
|
||||||
|
|
||||||
CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -183,8 +183,8 @@ class RDoc::TopLevel < RDoc::Context
|
|||||||
"#<%s:0x%x %p modules: %p classes: %p>" % [
|
"#<%s:0x%x %p modules: %p classes: %p>" % [
|
||||||
self.class, object_id,
|
self.class, object_id,
|
||||||
base_name,
|
base_name,
|
||||||
@modules.map { |n,m| m },
|
@modules.map { |n, m| m },
|
||||||
@classes.map { |n,c| c }
|
@classes.map { |n, c| c }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -254,8 +254,8 @@ class RDoc::TopLevel < RDoc::Context
|
|||||||
q.text "base name: #{base_name.inspect}"
|
q.text "base name: #{base_name.inspect}"
|
||||||
q.breakable
|
q.breakable
|
||||||
|
|
||||||
items = @modules.map { |n,m| m }
|
items = @modules.map { |n, m| m }
|
||||||
items.concat @modules.map { |n,c| c }
|
items.concat @modules.map { |n, c| c }
|
||||||
q.seplist items do |mod| q.pp mod end
|
q.seplist items do |mod| q.pp mod end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ class RDoc::Generator::POT::MessageExtractor
|
|||||||
extract_text(klass.comment_location, klass.full_name)
|
extract_text(klass.comment_location, klass.full_name)
|
||||||
|
|
||||||
klass.each_section do |section, constants, attributes|
|
klass.each_section do |section, constants, attributes|
|
||||||
extract_text(section.title ,"#{klass.full_name}: section title")
|
extract_text(section.title, "#{klass.full_name}: section title")
|
||||||
section.comments.each do |comment|
|
section.comments.each do |comment|
|
||||||
extract_text(comment, "#{klass.full_name}: #{section.title}")
|
extract_text(comment, "#{klass.full_name}: #{section.title}")
|
||||||
end
|
end
|
||||||
|
@ -260,7 +260,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
|
|
||||||
def add_word_pair(start, stop, name, exclusive = false)
|
def add_word_pair(start, stop, name, exclusive = false)
|
||||||
raise ArgumentError, "Word flags may not start with '<'" if
|
raise ArgumentError, "Word flags may not start with '<'" if
|
||||||
start[0,1] == '<'
|
start[0, 1] == '<'
|
||||||
|
|
||||||
bitmap = @attributes.bitmap_for name
|
bitmap = @attributes.bitmap_for name
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
@word_pair_map[pattern] = bitmap
|
@word_pair_map[pattern] = bitmap
|
||||||
end
|
end
|
||||||
|
|
||||||
@protectable << start[0,1]
|
@protectable << start[0, 1]
|
||||||
@protectable.uniq!
|
@protectable.uniq!
|
||||||
|
|
||||||
@exclusive_bitmap |= bitmap if exclusive
|
@exclusive_bitmap |= bitmap if exclusive
|
||||||
|
@ -24,7 +24,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|||||||
def init_tags
|
def init_tags
|
||||||
add_tag :BOLD, '+b', '-b'
|
add_tag :BOLD, '+b', '-b'
|
||||||
add_tag :EM, '+_', '-_'
|
add_tag :EM, '+_', '-_'
|
||||||
add_tag :TT, '' , '' # we need in_tt information maintained
|
add_tag :TT, '', '' # we need in_tt information maintained
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -683,7 +683,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
parsers = Hash.new { |h,parser| h[parser] = [] }
|
parsers = Hash.new { |h, parser| h[parser] = [] }
|
||||||
|
|
||||||
RDoc::Parser.parsers.each do |regexp, parser|
|
RDoc::Parser.parsers.each do |regexp, parser|
|
||||||
parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
|
parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
|
||||||
|
@ -440,7 +440,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|||||||
# Scans #content for rb_include_module
|
# Scans #content for rb_include_module
|
||||||
|
|
||||||
def do_includes
|
def do_includes
|
||||||
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
|
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c, m|
|
||||||
next unless cls = @classes[c]
|
next unless cls = @classes[c]
|
||||||
m = @known_classes[m] || m
|
m = @known_classes[m] || m
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|||||||
|
|
||||||
entries << [entry_name, entry_body] if entry_name
|
entries << [entry_name, entry_body] if entry_name
|
||||||
|
|
||||||
entries.reject! do |(entry,_)|
|
entries.reject! do |(entry, _)|
|
||||||
entry == nil
|
entry == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user