From 44ff9d1d3e1d4d303b58d44daf24f69e002fe5f4 Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Sun, 5 Aug 2018 21:53:49 +0200 Subject: [PATCH 1/2] Fix identical link generation prevention --- src/compiler/crystal/tools/doc/generator.cr | 3 +++ src/compiler/crystal/types.cr | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/crystal/tools/doc/generator.cr b/src/compiler/crystal/tools/doc/generator.cr index a470ec673c86..48b21f7223d8 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 } From aa40d12280da12df27a96d92d0dbb45ffd53408c Mon Sep 17 00:00:00 2001 From: r00ster <35064754+r00ster91@users.noreply.github.com> Date: Sun, 5 Aug 2018 22:39:50 +0200 Subject: [PATCH 2/2] Format --- src/compiler/crystal/tools/doc/generator.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/crystal/tools/doc/generator.cr b/src/compiler/crystal/tools/doc/generator.cr index 48b21f7223d8..bfc60282ed4c 100644 --- a/src/compiler/crystal/tools/doc/generator.cr +++ b/src/compiler/crystal/tools/doc/generator.cr @@ -394,7 +394,7 @@ class Crystal::Doc::Generator 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} + 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