Skip to content

Commit

Permalink
[DOC] Add missing documents
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 11, 2024
1 parent 78afdab commit 33956ce
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
34 changes: 30 additions & 4 deletions lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# See OptionParser for documentation.
#


#--
# == Developer Documentation (not for RDoc output)
#
Expand Down Expand Up @@ -425,6 +424,7 @@
# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
#
class OptionParser
# The version string
OptionParser::Version = "0.4.0"

# :stopdoc:
Expand All @@ -438,6 +438,8 @@ class OptionParser
# and resolved against a list of acceptable values.
#
module Completion
# :nodoc:

def self.regexp(key, icase)
Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
end
Expand Down Expand Up @@ -510,6 +512,8 @@ class OptionMap < Hash
# RequiredArgument, etc.
#
class Switch
# :nodoc:

attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block

#
Expand Down Expand Up @@ -715,10 +719,10 @@ def parse(arg, argv)
conv_arg(arg)
end

def self.incompatible_argument_styles(*)
def self.incompatible_argument_styles(*) # :nodoc:
end

def self.pattern
def self.pattern # :nodoc:
Object
end

Expand Down Expand Up @@ -804,6 +808,8 @@ def pretty_head # :nodoc:
# matching pattern and converter pair. Also provides summary feature.
#
class List
# :nodoc:

# Map from acceptable argument types to pattern and converter pairs.
attr_reader :atype

Expand Down Expand Up @@ -1185,6 +1191,11 @@ def self.terminate(arg = nil)
end

@stack = [DefaultList]
#
# Returns the global top option list.
#
# Do not use directly.
#
def self.top() DefaultList end

#
Expand Down Expand Up @@ -1297,10 +1308,24 @@ def ver
end
end

#
# Shows warning message with the program name
#
# +mesg+:: Message, defaulted to +$!+.
#
# See Kernel#warn.
#
def warn(mesg = $!)
super("#{program_name}: #{mesg}")
end

#
# Shows message with the program name then aborts.
#
# +mesg+:: Message, defaulted to +$!+.
#
# See Kernel#abort.
#
def abort(mesg = $!)
super("#{program_name}: #{mesg}")
end
Expand Down Expand Up @@ -2342,7 +2367,8 @@ def self.extend_object(obj)
super
obj.instance_eval {@optparse = nil}
end
def initialize(*args)

def initialize(*args) # :nodoc:
super
@optparse = nil
end
Expand Down
16 changes: 16 additions & 0 deletions lib/optparse/ac.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# frozen_string_literal: false
require_relative '../optparse'

#
# autoconf-like options.
#
class OptionParser::AC < OptionParser
# :stopdoc:
private

def _check_ac_args(name, block)
Expand All @@ -14,6 +18,7 @@ def _check_ac_args(name, block)
end

ARG_CONV = proc {|val| val.nil? ? true : val}
private_constant :ARG_CONV

def _ac_arg_enable(prefix, name, help_string, block)
_check_ac_args(name, block)
Expand All @@ -29,16 +34,27 @@ def _ac_arg_enable(prefix, name, help_string, block)
enable
end

# :startdoc:

public

# Define <tt>--enable</tt> / <tt>--disable</tt> style option
#
# Appears as <tt>--enable-<i>name</i></tt> in help message.
def ac_arg_enable(name, help_string, &block)
_ac_arg_enable("enable", name, help_string, block)
end

# Define <tt>--enable</tt> / <tt>--disable</tt> style option
#
# Appears as <tt>--disable-<i>name</i></tt> in help message.
def ac_arg_disable(name, help_string, &block)
_ac_arg_enable("disable", name, help_string, block)
end

# Define <tt>--with</tt> / <tt>--without</tt> style option
#
# Appears as <tt>--with-<i>name</i></tt> in help message.
def ac_arg_with(name, help_string, &block)
_check_ac_args(name, block)

Expand Down
9 changes: 9 additions & 0 deletions lib/optparse/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# OptionParser internal utility

class << OptionParser
#
# Shows version string in packages if Version is defined.
#
# +pkgs+:: package list
#
def show_version(*pkgs)
progname = ARGV.options.program_name
result = false
Expand Down Expand Up @@ -47,6 +52,8 @@ def show_version(*pkgs)
result
end

# :stopdoc:

def each_const(path, base = ::Object)
path.split(/::|\//).inject(base) do |klass, name|
raise NameError, path unless Module === klass
Expand All @@ -68,4 +75,6 @@ def search_const(klass, name)
end
end
end

# :startdoc:
end

0 comments on commit 33956ce

Please sign in to comment.