Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix identical link generation prevention for the "Defined in" section (docs) #6489

Merged
merged 2 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/crystal/tools/doc/generator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/crystal/types.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down