diff --git a/src/compiler/crystal/tools/doc/generator.cr b/src/compiler/crystal/tools/doc/generator.cr index a470ec673c86..bfc60282ed4c 100644 --- a/src/compiler/crystal/tools/doc/generator.cr +++ b/src/compiler/crystal/tools/doc/generator.cr @@ -393,6 +393,9 @@ class Crystal::Doc::Generator filename = filename[1..-1] if filename.starts_with? File::SEPARATOR filename = filename[4..-1] if filename.starts_with? SRC_SEP + # Prevent identical link generation in the "Defined in:" section in the docs because of macros + next if locations.any? { |loc| loc.filename == filename && loc.line_number == location.line_number } + show_line_number = locations.any? do |location| if location.filename == filename location.show_line_number = true diff --git a/src/compiler/crystal/types.cr b/src/compiler/crystal/types.cr index 1e7410cf683c..8720de000800 100644 --- a/src/compiler/crystal/types.cr +++ b/src/compiler/crystal/types.cr @@ -705,8 +705,7 @@ module Crystal # Adds a location to this type. def add_location(location : Location) locations = @locations ||= [] of Location - # The `unless` prevents that identical links are being generated in the "Defined in:" section in the docs because of macros - locations << location unless locations.any? { |loc| loc.filename == location.filename && loc.line_number == location.line_number } + locations << location end getter(types) { {} of String => NamedType }