Sha256: cf91c23a5ed4b63ce06744bb2116685be35c207ffa5f1efc699709f8d0fdf177

Contents?: true

Size: 1006 Bytes

Versions: 28

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

module Reek
  # Generate versioned links to our documentation
  module DocumentationLink
    HELP_LINK_TEMPLATE = 'https://github.com/troessner/reek/blob/v%<version>s/docs/%<item>s.md'

    module_function

    # Build link to the documentation about the given subject for the current
    # version of Reek. The subject can be either a smell type like
    # 'FeatureEnvy' or a general subject like 'Rake Task'.
    #
    # @param subject [String]
    # @return [String] the full URL for the relevant documentation
    def build(subject)
      Kernel.format(HELP_LINK_TEMPLATE, version: Version::STRING, item: name_to_param(subject))
    end

    # Convert the given subject name to a form that is acceptable in a URL.
    def name_to_param(name)
      # Splits the subject on the start of capitalized words, optionally
      # preceded by a space. The space is discarded, the start of the word is
      # not.
      name.split(/ *(?=[A-Z][a-z])/).join('-')
    end
  end
end

Version data entries

28 entries across 26 versions & 2 rubygems

Version Path
reek-6.1.4 lib/reek/documentation_link.rb
reek-6.1.3 lib/reek/documentation_link.rb
reek-6.1.2 lib/reek/documentation_link.rb
reek-6.1.1 lib/reek/documentation_link.rb
reek-6.1.0 lib/reek/documentation_link.rb
reek-6.0.6 lib/reek/documentation_link.rb
reek-6.0.5 lib/reek/documentation_link.rb
reek-6.0.4 lib/reek/documentation_link.rb
reek-6.0.3 lib/reek/documentation_link.rb
reek-6.0.2 lib/reek/documentation_link.rb
reek-6.0.1 lib/reek/documentation_link.rb
reek-6.0.0 lib/reek/documentation_link.rb
reek-5.6.0 lib/reek/documentation_link.rb
reek-5.5.0 lib/reek/documentation_link.rb
reek-5.4.1 lib/reek/documentation_link.rb
reek-5.4.0 lib/reek/documentation_link.rb
reek-5.3.2 lib/reek/documentation_link.rb
reek-5.3.1 lib/reek/documentation_link.rb
reek-5.3.0 lib/reek/documentation_link.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/lib/reek/documentation_link.rb