Skip to content

Commit

Permalink
Rename ditto to :ditto: (#6362)
Browse files Browse the repository at this point in the history
  • Loading branch information
j8r authored and straight-shoota committed Jan 12, 2020
1 parent 6cfae76 commit 11a6f9a
Show file tree
Hide file tree
Showing 25 changed files with 116 additions and 106 deletions.
2 changes: 1 addition & 1 deletion spec/compiler/semantic/doc_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe "Semantic: doc" do
def bar
end
# ditto
# :ditto:
def bar2
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/array.cr
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class Array(T)
self
end

# ditto
# :ditto:
def concat(other : Enumerable)
left_before_resize = @capacity - @size
len = @size
Expand Down
12 changes: 6 additions & 6 deletions src/big/big_int.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct BigInt < Int
end
end

# ditto
# :ditto:
def initialize(num : Int::Unsigned)
if num <= LibC::ULong::MAX
LibGMP.init_set_ui(out @mpz, num)
Expand All @@ -62,22 +62,22 @@ struct BigInt < Int
end
end

# ditto
# :ditto:
def initialize(num : Float::Primitive)
LibGMP.init_set_d(out @mpz, num)
end

# ditto
# :ditto:
def self.new(num : BigFloat)
num.to_big_i
end

# ditto
# :ditto:
def self.new(num : BigDecimal)
num.to_big_i
end

# ditto
# :ditto:
def self.new(num : BigRational)
num.to_big_i
end
Expand Down Expand Up @@ -397,7 +397,7 @@ struct BigInt < Int
String.new(to_cstr)
end

# ditto
# :ditto:
def to_s(io : IO) : Nil
str = to_cstr
io.write_utf8 Slice.new(str, LibC.strlen(str))
Expand Down
2 changes: 1 addition & 1 deletion src/bit_array.cr
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct BitArray
io << ']'
end

# ditto
# :ditto:
def inspect(io : IO) : Nil
to_s(io)
end
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Crystal::Macros
def `(command) : MacroId
end

# ditto
# :ditto:
def system(command) : MacroId
end

Expand Down Expand Up @@ -276,19 +276,19 @@ module Crystal::Macros
def <(other : NumberLiteral) : BoolLiteral
end

# ditto
# :ditto:
def <=(other : NumberLiteral) : BoolLiteral
end

# ditto
# :ditto:
def >(other : NumberLiteral) : BoolLiteral
end

# ditto
# :ditto:
def >=(other : NumberLiteral) : BoolLiteral
end

# ditto
# :ditto:
def <=>(other : NumberLiteral) : NumberLiteral
end

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/program.cr
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ module Crystal
named_tuple_of(entries)
end

# ditto
# :ditto:
def named_tuple_of(entries : Array(NamedArgumentType))
named_tuple.instantiate_named_args(entries)
end
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/semantic/path_lookup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Crystal
(path.global? ? program : self).lookup_path(path.names, lookup_in_namespace, include_private, location)
end

# ditto
# :ditto:
def lookup_path(names : Array(String), lookup_in_namespace = true, include_private = false, location = nil) : Type | ASTNode | Nil
type = self
names.each_with_index do |name, i|
Expand Down
13 changes: 9 additions & 4 deletions src/compiler/crystal/semantic/top_level_visitor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1056,13 +1056,18 @@ class Crystal::TopLevelVisitor < Crystal::SemanticVisitor
end
end

def check_ditto(node)
def check_ditto(node : Def | Assign | FunDef | Const) : Nil
return if !@program.wants_doc?
stripped_doc = node.doc.try &.strip
if stripped_doc == ":ditto:" || stripped_doc == "ditto"
if stripped_doc == ":ditto:"
node.doc = @last_doc
elsif stripped_doc == "ditto"
# TODO: remove after 0.33.0
@program.warning_failures << "`ditto` is no longer supported. Use `:ditto:` instead"
node.doc = @last_doc
else
@last_doc = node.doc
end

@last_doc = node.doc
end

def annotations_doc(annotations)
Expand Down
11 changes: 8 additions & 3 deletions src/compiler/crystal/tools/doc/generator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,14 @@ class Crystal::Doc::Generator
toplevel_items.any? { |item| must_include? item }
end

def nodoc?(str : String?)
return false unless str
str.starts_with?(":nodoc:") || str.starts_with?("nodoc")
def nodoc?(str : String?) : Bool
return false if !str || !@program.wants_doc?
# TODO: remove after 0.33.0
if str.starts_with?("nodoc")
@program.warning_failures << "`nodoc` is no longer supported. Use `:nodoc:` instead"
return true
end
str.starts_with?(":nodoc:")
end

def nodoc?(obj)
Expand Down
12 changes: 6 additions & 6 deletions src/complex.cr
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ struct Complex
@real == other.real && @imag == other.imag
end

# ditto
# :ditto:
def ==(other : Number)
self == other.to_c
end

# ditto
# :ditto:
def ==(other)
false
end
Expand Down Expand Up @@ -235,7 +235,7 @@ struct Complex
Complex.new(@real + other.real, @imag + other.imag)
end

# ditto
# :ditto:
def +(other : Number)
Complex.new(@real + other, @imag)
end
Expand All @@ -250,7 +250,7 @@ struct Complex
Complex.new(@real - other.real, @imag - other.imag)
end

# ditto
# :ditto:
def -(other : Number)
Complex.new(@real - other, @imag)
end
Expand All @@ -260,7 +260,7 @@ struct Complex
Complex.new(@real * other.real - @imag * other.imag, @real * other.imag + @imag * other.real)
end

# ditto
# :ditto:
def *(other : Number)
Complex.new(@real * other, @imag * other)
end
Expand All @@ -278,7 +278,7 @@ struct Complex
end
end

# ditto
# :ditto:
def /(other : Number)
Complex.new(@real / other, @imag / other)
end
Expand Down
8 changes: 4 additions & 4 deletions src/csv/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CSV::Builder
end
end

# ditto
# :ditto:
def row(*values)
row values
end
Expand Down Expand Up @@ -119,7 +119,7 @@ class CSV::Builder
end
end

# ditto
# :ditto:
def <<(value : Nil | Bool | Number)
case @quoting
when .all?
Expand All @@ -133,7 +133,7 @@ class CSV::Builder
end
end

# ditto
# :ditto:
def <<(value)
self << value.to_s
end
Expand All @@ -145,7 +145,7 @@ class CSV::Builder
end
end

# ditto
# :ditto:
def concat(*values)
concat values
end
Expand Down
6 changes: 3 additions & 3 deletions src/dir/glob.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Dir
glob(patterns)
end

# ditto
# :ditto:
def self.[](patterns : Enumerable(String)) : Array(String)
glob(patterns)
end
Expand All @@ -24,7 +24,7 @@ class Dir
glob(patterns, match_hidden: match_hidden)
end

# ditto
# :ditto:
def self.glob(patterns : Enumerable(String), match_hidden = false) : Array(String)
paths = [] of String
glob(patterns, match_hidden: match_hidden) do |path|
Expand All @@ -46,7 +46,7 @@ class Dir
end
end

# ditto
# :ditto:
def self.glob(patterns : Enumerable(String), match_hidden = false, &block : String -> _)
Globber.glob(patterns, match_hidden: match_hidden) do |path|
yield path
Expand Down
12 changes: 6 additions & 6 deletions src/humanize.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct Number
end
end

# ditto
# :ditto:
def format(separator = '.', delimiter = ',', decimal_places : Int? = nil, *, group : Int = 3, only_significant : Bool = false) : String
String.build do |io|
format(io, separator, delimiter, decimal_places, group: group, only_significant: only_significant)
Expand Down Expand Up @@ -120,7 +120,7 @@ struct Number
end
end

# ditto
# :ditto:
def humanize(precision = 3, separator = '.', delimiter = ',', *, base = 10 ** 3, significant = true, prefixes = SI_PREFIXES) : String
String.build do |io|
humanize(io, precision, separator, delimiter, base: base, significant: significant, prefixes: prefixes)
Expand Down Expand Up @@ -222,7 +222,7 @@ struct Number
io << unit
end

# ditto
# :ditto:
def humanize(precision = 3, separator = '.', delimiter = ',', *, base = 10 ** 3, significant = true) : String
String.build do |io|
humanize(io, precision, separator, delimiter, base: base, significant: significant) do |magnitude, number|
Expand All @@ -231,14 +231,14 @@ struct Number
end
end

# ditto
# :ditto:
def humanize(io : IO, precision = 3, separator = '.', delimiter = ',', *, base = 10 ** 3, significant = true, prefixes : Proc) : Nil
humanize(io, precision, separator, delimiter, base: base, significant: significant) do |magnitude, number|
prefixes.call(magnitude, number)
end
end

# ditto
# :ditto:
def humanize(precision = 3, separator = '.', delimiter = ',', *, base = 10 ** 3, significant = true, prefixes : Proc) : Nil
String.build do |io|
humanize(io, precision, separator, delimiter, base: base, significant: significant, prefixes: prefixes)
Expand Down Expand Up @@ -299,7 +299,7 @@ struct Int
end
end

# ditto
# :ditto:
def humanize_bytes(precision : Int = 3, separator = '.', *, significant : Bool = true, format : BinaryPrefixFormat = :IEC) : String
String.build do |io|
humanize_bytes(io, precision, separator, significant: significant, format: format)
Expand Down
2 changes: 1 addition & 1 deletion src/io.cr
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ abstract class IO
printf format_string, args
end

# ditto
# :ditto:
def printf(format_string, args : Array | Tuple) : Nil
String::Formatter(typeof(args)).new(format_string, args, self).format
nil
Expand Down
2 changes: 1 addition & 1 deletion src/iterator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module Iterator(T)
Iterator.stop
end

# ditto
# :ditto:
def self.stop
Stop::INSTANCE
end
Expand Down
6 changes: 3 additions & 3 deletions src/json/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ class JSON::Builder
null
end

# ditto
# :ditto:
def scalar(value : Bool)
bool(value)
end

# ditto
# :ditto:
def scalar(value : Int | Float)
number(value)
end

# ditto
# :ditto:
def scalar(value : String)
string(value)
end
Expand Down
4 changes: 2 additions & 2 deletions src/kernel.cr
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def printf(format_string, *args) : Nil
printf format_string, args
end

# ditto
# :ditto:
def printf(format_string, args : Array | Tuple) : Nil
STDOUT.printf format_string, args
end
Expand Down Expand Up @@ -353,7 +353,7 @@ def sprintf(format_string, *args) : String
sprintf format_string, args
end

# ditto
# :ditto:
def sprintf(format_string, args : Array | Tuple) : String
String.build(format_string.bytesize) do |str|
String::Formatter(typeof(args)).new(format_string, args, str).format
Expand Down
Loading

0 comments on commit 11a6f9a

Please sign in to comment.