Skip to content

Commit

Permalink
Change the Link module to improve YARD documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Mar 30, 2024
1 parent dfa0e81 commit b8e4c86
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions lib/tty/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,64 @@
require_relative "link/version"

module TTY
# Responsible for detecting and generating terminal hyperlinks
#
# @api public
module Link
# Raised to signal an error condition
#
# @api public
class Error < StandardError; end

# The ANSI escape sequence code
#
# @return [String]
#
# @api private
ESC = "\u001B["

# The operating system command code
#
# @return [String]
#
# @api private
OSC = "\u001B]"

# The bell control code
#
# @return [String]
#
# @api private
BEL = "\u0007"

# The parameters separator
#
# @return [String]
#
# @api private
SEP = ";"

# The iTerm terminal name pattern
#
# @return [Regexp]
#
# @api private
ITERM = /iTerm(\s*\d+){0,1}.app/x.freeze

# Parse version number
#
# @example
# TTY::Link.parse_version("1234")
# # => {major: 0, minor: 12, patch: 34}
#
# @example
# TTY::Link.parse_version("1.2.3")
# # => {major: 1, minor: 2, patch: 3}
#
# @param [String] version
# the version to parse
#
# @return [Hash{Symbol => Integer, nil}]
#
# @api private
def parse_version(version)
Expand All @@ -28,7 +73,18 @@ def parse_version(version)
end
module_function :parse_version

# Check if link is supported
# Detect terminal hyperlink support
#
# @example
# TTY::Link.support_link?
# # => true
#
# @example
# TTY::Link.support_link?(output: $stderr)
# # => false
#
# @param [IO] output
# the output stream, defaults to $stdout
#
# @return [Boolean]
#
Expand All @@ -54,10 +110,15 @@ def support_link?(output: $stdout)
end
module_function :support_link?

# Render terminal link
# Generate terminal hyperlink
#
# @example
# TTY::Link.link_to("TTY Toolkit", "https://ttytoolkit.org")
#
# @param [String] name
# the name for the URL
# @param [String] url
# the URL target
#
# @return [String]
#
Expand Down

0 comments on commit b8e4c86

Please sign in to comment.