Hide #to_s in docs.

This commit is contained in:
Markus Reiter 2024-04-26 14:04:55 +02:00
parent fe4ef62aa9
commit c76170a456
No known key found for this signature in database
GPG Key ID: 245293B51702655B
28 changed files with 93 additions and 34 deletions

View File

@ -61,7 +61,10 @@ class PATH
def to_str
@paths.join(File::PATH_SEPARATOR)
end
alias to_s to_str
# @!visibility private
sig { returns(String) }
def to_s = to_str
sig { params(other: T.untyped).returns(T::Boolean) }
def ==(other)

View File

@ -149,6 +149,7 @@ module Cask
cask.config
end
# @!visibility private
sig { returns(String) }
def to_s
"#{summarize} (#{self.class.english_name})"

View File

@ -325,9 +325,9 @@ module Cask
@ruby_source_checksum = { sha256: ruby_source_sha256 }
end
# Alias for {#token}.
#
# @api internal
# @api public
# @!visibility private
sig { returns(String) }
def to_s = token
# @!visibility private

View File

@ -39,6 +39,8 @@ module Cask
private_class_method :caveat
# @!visibility private
sig { returns(String) }
def to_s
(@custom_caveats + @built_in_caveats.values).join("\n")
end

View File

@ -29,9 +29,9 @@ module Cask
pairs.to_yaml
end
def to_s
pairs.inspect
end
# @!visibility private
sig { returns(String) }
def to_s = pairs.inspect
end
end
end

View File

@ -17,6 +17,7 @@ module Cask
@errors = errors
end
# @!visibility private
sig { returns(String) }
def to_s
<<~EOS
@ -48,6 +49,7 @@ module Cask
#
# @api private
class CaskNotInstalledError < AbstractCaskErrorWithToken
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' is not installed."
@ -65,6 +67,7 @@ module Cask
@message = message
end
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' has been #{message}"
@ -82,6 +85,7 @@ module Cask
@conflicting_cask = conflicting_cask
end
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' conflicts with '#{conflicting_cask}'."
@ -92,6 +96,7 @@ module Cask
#
# @api private
class CaskUnavailableError < AbstractCaskErrorWithToken
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' is unavailable#{reason.empty? ? "." : ": #{reason}"}"
@ -102,6 +107,7 @@ module Cask
#
# @api private
class CaskUnreadableError < CaskUnavailableError
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' is unreadable#{reason.empty? ? "." : ": #{reason}"}"
@ -119,6 +125,7 @@ module Cask
@tap = tap
end
# @!visibility private
sig { returns(String) }
def to_s
s = super
@ -157,6 +164,7 @@ module Cask
#
# @api private
class CaskAlreadyCreatedError < AbstractCaskErrorWithToken
# @!visibility private
sig { returns(String) }
def to_s
%Q(Cask '#{token}' already exists. Run #{Formatter.identifier("brew edit --cask #{token}")} to edit it.)
@ -167,6 +175,7 @@ module Cask
#
# @api private
class CaskCyclicDependencyError < AbstractCaskErrorWithToken
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' includes cyclic dependencies on other Casks#{reason.empty? ? "." : ": #{reason}"}"
@ -177,6 +186,7 @@ module Cask
#
# @api private
class CaskSelfReferencingDependencyError < CaskCyclicDependencyError
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' depends on itself."
@ -187,6 +197,7 @@ module Cask
#
# @api private
class CaskUnspecifiedError < CaskError
# @!visibility private
sig { returns(String) }
def to_s
"This command requires a Cask token."
@ -197,6 +208,7 @@ module Cask
#
# @api private
class CaskInvalidError < AbstractCaskErrorWithToken
# @!visibility private
sig { returns(String) }
def to_s
"Cask '#{token}' definition is invalid#{reason.empty? ? "." : ": #{reason}"}"
@ -225,6 +237,7 @@ module Cask
@reason = reason
end
# @!visibility private
sig { returns(String) }
def to_s
s = +"Failed to quarantine #{path}."
@ -243,6 +256,7 @@ module Cask
#
# @api private
class CaskQuarantinePropagationError < CaskQuarantineError
# @!visibility private
sig { returns(String) }
def to_s
s = +"Failed to quarantine one or more files within #{path}."
@ -261,6 +275,7 @@ module Cask
#
# @api private
class CaskQuarantineReleaseError < CaskQuarantineError
# @!visibility private
sig { returns(String) }
def to_s
s = +"Failed to release #{path} from quarantine."

View File

@ -24,9 +24,9 @@ class Dependency
@tap, = tap_with_name
end
def to_s
name
end
# @!visibility private
sig { returns(String) }
def to_s = name
def ==(other)
instance_of?(other.class) && name == other.name && tags == other.tags

View File

@ -16,6 +16,7 @@ class UsageError < RuntimeError
@reason = reason
end
# @!visibility private
sig { returns(String) }
def to_s
s = "Invalid usage"
@ -110,6 +111,7 @@ class FormulaOrCaskUnavailableError < RuntimeError
"Did you mean #{similar_formula_names.to_sentence two_words_connector: " or ", last_word_connector: " or "}?"
end
# @!visibility private
sig { returns(String) }
def to_s
s = "No available formula or cask with the name \"#{name}\". #{did_you_mean}".strip
@ -129,6 +131,7 @@ class TapFormulaOrCaskUnavailableError < FormulaOrCaskUnavailableError
@tap = tap
end
# @!visibility private
sig { returns(String) }
def to_s
s = super
@ -148,6 +151,7 @@ class FormulaUnavailableError < FormulaOrCaskUnavailableError
" (dependency of #{dependent})" if dependent && dependent != name
end
# @!visibility private
sig { returns(String) }
def to_s
"No available formula with the name \"#{name}\"#{dependent_s}. #{did_you_mean}".strip
@ -160,6 +164,8 @@ end
module FormulaClassUnavailableErrorModule
attr_reader :path, :class_name, :class_list
# @!visibility private
sig { returns(String) }
def to_s
s = super
s += "\nIn formula file: #{path}"
@ -204,6 +210,7 @@ end
module FormulaUnreadableErrorModule
attr_reader :formula_error
# @!visibility private
sig { returns(String) }
def to_s
"#{name}: " + formula_error.to_s
@ -232,6 +239,8 @@ class TapFormulaUnavailableError < FormulaUnavailableError
super "#{tap}/#{name}"
end
# @!visibility private
sig { returns(String) }
def to_s
s = super
s += "\nPlease tap it and then try again: brew tap #{tap}" unless tap.installed?

View File

@ -1731,9 +1731,10 @@ class Formula
[name, *oldnames, *aliases].compact
end
def to_s
name
end
# @api public
# @!visibility private
sig { returns(String) }
def to_s = name
# @!visibility private
sig { returns(String) }

View File

@ -37,6 +37,8 @@ class KegOnlyReason
!by_macos?
end
# @!visibility private
sig { returns(String) }
def to_s
return @explanation unless @explanation.empty?

View File

@ -27,6 +27,8 @@ module Homebrew
@text.include? string
end
# @!visibility private
sig { returns(String) }
def to_s
@text
end

View File

@ -107,10 +107,9 @@ class GitRepository
popen_git("log", "-1", "--pretty=%B", commit, "--", safe:, err: :out)&.strip
end
# @!visibility private
sig { returns(String) }
def to_s
pathname.to_s
end
def to_s = pathname.to_s
private

View File

@ -50,6 +50,7 @@ class Keg
EOS
end
# @!visibility private
sig { returns(String) }
def to_s
s = []
@ -68,6 +69,7 @@ class Keg
# Error for when a directory is not writable.
class DirectoryNotWritableError < LinkError
# @!visibility private
sig { returns(String) }
def to_s
<<~EOS
@ -155,7 +157,7 @@ class Keg
extend Forwardable
def_delegators :path,
:to_s, :hash, :abv, :disk_usage, :file_count, :directory?, :exist?, :/,
:to_path, :hash, :abv, :disk_usage, :file_count, :directory?, :exist?, :/,
:join, :rename, :find
def initialize(path)
@ -175,7 +177,9 @@ class Keg
path.parent
end
alias to_path to_s
# @!visibility private
sig { returns(String) }
def to_s = path.to_s
# @!visibility private
sig { returns(String) }

View File

@ -108,6 +108,7 @@ class Locale
locale_groups.find { |locales| locales.any? { |locale| include?(locale) } }
end
# @!visibility private
sig { returns(String) }
def to_s
[@language, @script, @region].compact.join("-")

View File

@ -38,6 +38,7 @@ class Mktemp
@quiet = true
end
# @!visibility private
sig { returns(String) }
def to_s
"[Mktemp: #{tmpdir} retain=#{@retain} quiet=#{@quiet}]"

View File

@ -13,9 +13,9 @@ class Option
@description = description
end
def to_s
flag
end
# @!visibility private
sig { returns(String) }
def to_s = flag
def <=>(other)
return unless other.is_a?(Option)
@ -140,6 +140,7 @@ class Options
alias to_ary to_a
# @!visibility private
sig { returns(String) }
def to_s
@options.map(&:to_s).join(" ")

View File

@ -32,14 +32,18 @@ class PkgVersion
version.head?
end
def to_s
sig { returns(String) }
def to_str
if revision.positive?
"#{version}_#{revision}"
else
version.to_s
end
end
alias to_str to_s
# @!visibility private
sig { returns(String) }
def to_s = to_str
def <=>(other)
return unless other.is_a?(PkgVersion)

View File

@ -294,6 +294,7 @@ class ResourceStageContext
# The {Resource} that is being staged.
attr_reader :resource
# The {Mktemp} in which {#resource} is staged.
attr_reader :staging
@ -305,6 +306,7 @@ class ResourceStageContext
@staging = staging
end
# @!visibility private
sig { returns(String) }
def to_s
"<#{self.class}: resource=#{resource} staging=#{staging}>"

View File

@ -314,10 +314,13 @@ class Bottle
end
sig { returns(String) }
def to_s
def to_str
"#{name}--#{version}#{extname}"
end
alias to_str to_s
# @!visibility private
sig { returns(String) }
def to_s = to_str
sig { returns(String) }
def json

View File

@ -18,6 +18,7 @@ module Homebrew
@column = column
end
# @!visibility private
sig { returns(String) }
def to_s
"#{line}#{column&.to_s&.prepend(":")}"

View File

@ -403,6 +403,7 @@ class Tab
tabfile.atomic_write(to_json)
end
# @!visibility private
sig { returns(String) }
def to_s
s = []

View File

@ -155,9 +155,9 @@ class Tap
# @api public
attr_reader :name
# Alias for {#name}.
#
# @api public
# @!visibility private
sig { returns(String) }
def to_s = name
# The full name of this {Tap}, including the `homebrew-` prefix.

View File

@ -16,6 +16,7 @@ class URL
@specs.freeze
end
# @!visibility private
sig { returns(String) }
def to_s
@url

View File

@ -202,6 +202,7 @@ module Utils
end
end
# @!visibility private
sig { returns(String) }
def to_s
to_sym.to_s

View File

@ -73,6 +73,7 @@ module GitHub
@end_column = Integer(end_column) if end_column
end
# @!visibility private
sig { returns(String) }
def to_s
metadata = @type.to_s

View File

@ -85,6 +85,7 @@ module PyPI
]
end
# @!visibility private
sig { returns(String) }
def to_s
if valid_pypi_package?

View File

@ -100,6 +100,7 @@ module Tty
end
end
# @!visibility private
sig { returns(String) }
def to_s
return "" unless color?

View File

@ -81,10 +81,13 @@ class Version
end
sig { returns(String) }
def to_s
def to_str
value.to_s
end
alias to_str to_s
# @!visibility private
sig { returns(String) }
def to_s = to_str
sig { returns(T::Boolean) }
def numeric?
@ -704,11 +707,6 @@ class Version
version.to_i
end
sig { returns(String) }
def to_s
version.to_s
end
sig { returns(String) }
def to_str
raise NoMethodError, "undefined method `to_str' for #{self.class}:NULL" if null?
@ -716,6 +714,10 @@ class Version
T.must(version).to_str
end
# @!visibility private
sig { returns(String) }
def to_s = version.to_s
sig { params(options: T.untyped).returns(String) }
def to_json(*options)
version.to_json(*options)