mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
documented :listing and other command options in command_set.rb, changed rdoc emphasizer and italic marktup to rendered bold (instead of green and blue)
This commit is contained in:
parent
34f63c65f6
commit
6ddff90001
2 changed files with 27 additions and 3 deletions
|
@ -50,12 +50,23 @@ class Pry
|
|||
end
|
||||
|
||||
# Defines a new Pry command.
|
||||
# @param [String] name The name of the command
|
||||
# @param [String, Regexp] name The name of the command. Can be
|
||||
# Regexp as well as String.
|
||||
# @param [String] description A description of the command.
|
||||
# @param [Hash] options The optional configuration parameters.
|
||||
# @option options [Boolean] :keep_retval Whether or not to use return value
|
||||
# of the block for return of `command` or just to return `nil`
|
||||
# (the default).
|
||||
# @option options [Array<String>] :requires_gem Whether the command has
|
||||
# any gem dependencies, if it does and dependencies not met then
|
||||
# command is disabled and a stub proc giving instructions to
|
||||
# install command is provided.
|
||||
# @option options [Boolean] :interpolate Whether string #{} based
|
||||
# interpolation is applied to the command arguments before
|
||||
# executing the command. Defaults to true.
|
||||
# @option options [String] :listing The listing name of the
|
||||
# command. That is the name by which the command is looked up by
|
||||
# help and by show-command. Necessary for regex based commands.
|
||||
# @yield The action to perform. The parameters in the block
|
||||
# determines the parameters the command will receive. All
|
||||
# parameters passed into the block will be strings. Successive
|
||||
|
@ -73,6 +84,19 @@ class Pry
|
|||
# # Good afternoon John!
|
||||
# # pry(main)> help greet
|
||||
# # Greet somebody
|
||||
# @example Regexp command
|
||||
# MyCommands = Pry::CommandSet.new do
|
||||
# command /number-(\d+)/, "number-N regex command", :listing => "number" do |num, name|
|
||||
# puts "hello #{name}, nice number: #{num}"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # From pry:
|
||||
# # pry(main)> _pry_.commands = MyCommands
|
||||
# # pry(main)> number-10 john
|
||||
# # hello john, nice number: 10
|
||||
# # pry(main)> help number
|
||||
# # number-N regex command
|
||||
def command(name, description="No description.", options={}, &block)
|
||||
|
||||
options = {
|
||||
|
|
|
@ -215,8 +215,8 @@ class Pry
|
|||
def process_rdoc(comment, code_type)
|
||||
comment = comment.dup
|
||||
comment.gsub(/<code>(?:\s*\n)?(.*?)\s*<\/code>/m) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }.
|
||||
gsub(/<em>(?:\s*\n)?(.*?)\s*<\/em>/m) { Pry.color ? "\e[32m#{$1}\e[0m": $1 }.
|
||||
gsub(/<i>(?:\s*\n)?(.*?)\s*<\/i>/m) { Pry.color ? "\e[34m#{$1}\e[0m" : $1 }.
|
||||
gsub(/<em>(?:\s*\n)?(.*?)\s*<\/em>/m) { Pry.color ? "\e[1m#{$1}\e[0m": $1 }.
|
||||
gsub(/<i>(?:\s*\n)?(.*?)\s*<\/i>/m) { Pry.color ? "\e[1m#{$1}\e[0m" : $1 }.
|
||||
gsub(/\B\+(\w*?)\+\B/) { Pry.color ? "\e[32m#{$1}\e[0m": $1 }.
|
||||
gsub(/((?:^[ \t]+.+(?:\n+|\Z))+)/) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }.
|
||||
gsub(/`(?:\s*\n)?(.*?)\s*`/) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }
|
||||
|
|
Loading…
Add table
Reference in a new issue