From f5fc88727f7a4929eb7e52efd24fb45ef6ed1d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=88king?= Date: Mon, 17 Sep 2012 23:01:03 -0600 Subject: [PATCH] Pull docs from Wiki. --- lib/pry-docmore.rb | 587 +-------------------------------------- pry-docmore.wiki | 2 +- spec/pry-docmore_spec.rb | 2 +- 3 files changed, 14 insertions(+), 577 deletions(-) diff --git a/lib/pry-docmore.rb b/lib/pry-docmore.rb index 9e2a416..65de708 100644 --- a/lib/pry-docmore.rb +++ b/lib/pry-docmore.rb @@ -1,589 +1,26 @@ +# encoding: utf-8 class Pry class Docmore - def self.split_docs doc_string - Hash[doc_string.split(/\.\.\.\n/).map { |e| e.split(/\s+/,2) }] + def self.find_docs pattern + input = Dir['pry-docmore.wiki/*.md'].map do |file_name| + if file_name.match pattern + item = $1 + item.sub! '⁄', '/' # Had to use Unicode "Fraction Slash" in filename. + [ item, File.read(file_name) ] + end + end.compact + Hash[input] end @DOCS = [ { label: 'Keyword', source: 'ruby source, lex.c, circa line 219', - explanations: self.split_docs(%q{ -alias -@abstract The alias keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -and -@abstract The and keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -begin -@abstract The begin keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -BEGIN -@abstract The BEGIN keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -break -@abstract The break keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -case -@abstract The case keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -class -@abstract The class keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -def -@abstract The def keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -defined? -@abstract The defined? keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -do -@abstract The do keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -else -@abstract The else keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -elsif -@abstract The elsif keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -__ENCODING__ -@abstract The __ENCODING__ keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -end -@abstract The end keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -END -@abstract The END keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -ensure -@abstract The ensure keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -false -@abstract The false keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -__FILE__ -@abstract The __FILE__ keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -for -@abstract The for keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -if -@abstract The if keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -in -@abstract The in keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -__LINE__ -@abstract The __LINE__ keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -module -@abstract The module keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -next -@abstract The next keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -nil -@abstract The nil keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -not -@abstract The not keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -or -@abstract The or keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -redo -@abstract The redo keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -rescue -@abstract The rescue keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -retry -@abstract The retry keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -return -@abstract The return keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -self -@abstract The self keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -super -@abstract The super keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -then -@abstract The then keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -true -@abstract The true keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -undef -@abstract The undef keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -unless -@abstract The unless keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -until -@abstract The until keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -when -@abstract The when keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -while -@abstract The while keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... -yield -@abstract The yield keyword is ... -@example ... -@param name desc -@see http://... or Obj#meth -... - }) + explanations: find_docs(%r/Ruby Keyword: (.+)\.md/) }, { label: 'Global Variable', source: 'Started from: http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables', - explanations: self.split_docs(%q{ -$SAFE -@abstract The $SAFE global ...pry-docmore TODO! -@example ... -@param name desc -@see http://... or Obj#meth -... -$KCODE -@abstract The $KCODE global ...pry-docmore TODO! -@example ... -@param name desc -@see http://... or Obj#meth -... -$-K -@abstract The $-K global ...pry-docmore TODO! -@example ... -@param name desc -@see http://... or Obj#meth -... -$LOADED_FEATURES -@abstract The $LOADED_FEATURES global ...pry-docmore TODO! -@example ... -@param name desc -@see http://... or Obj#meth -... -$-W -@abstract The $-W global ...pry-docmore TODO! -@example ... -@param name desc -@see http://... or Obj#meth -... -$PROGRAM_NAME -@abstract The $PROGRAM_NAME global Same as $0 - Contains the name of the script being executed. May be assignable. -@example ... -@param name desc -@see http://... or Obj#meth -... -$! -@abstract The $! global is the exception information message set by 'raise'. -@example ... -@param name desc -@see http://... or Obj#meth -... -$@ -@abstract The $@ global Array of backtrace of the last exception thrown. -@example ... -@param name desc -@see http://... or Obj#meth -... -$& -@abstract The $& global is the string matched by the last successful match. -@example ... -@param name desc -@see http://... or Obj#meth -... -$` -@abstract The $` global is the string to the left of the last successful match. -@example ... -@param name desc -@see http://... or Obj#meth -... -$' -@abstract The $' global is the string to the right of the last successful match. -@example ... -@param name desc -@see http://... or Obj#meth -... -$+ -@abstract The $+ global is the highest group matched by the last successful match. -@example ... -@param name desc -@see http://... or Obj#meth -... -$1 -@abstract The $1 global is the 1st group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$2 -@abstract The $2 global is the 2nd group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$3 -@abstract The $3 global is the 3rd group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$4 -@abstract The $4 global is the 4th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$5 -@abstract The $5 global is the 5th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$6 -@abstract The $6 global is the 6th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$7 -@abstract The $7 global is the 7th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$8 -@abstract The $8 global is the 8th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$9 -@abstract The $9 global is the 9th group of the last successful match. May be > 1. -@example ... -@param name desc -@see http://... or Obj#meth -... -$~ -@abstract The $~ global is the information about the last match in the current scope. -@example ... -@param name desc -@see http://... or Obj#meth -... -$= -@abstract The $= global is the flag for case insensitive, nil by default. -@example ... -@param name desc -@see http://... or Obj#meth -... -$/ -@abstract The $/ global is the input record separator, newline by default. -@example ... -@param name desc -@see http://... or Obj#meth -... -$\ -@abstract The $\ global is the output record separator for the print and IO#write. Default is nil. -@example ... -@param name desc -@see http://... or Obj#meth -... -$, -@abstract The $, global is the output field separator for the print and Array#join. -@example ... -@param name desc -@see http://... or Obj#meth -... -$; -@abstract The $; global is the default separator for String#split. -@example ... -@param name desc -@see http://... or Obj#meth -... -$. -@abstract The $. global is the current input line number of the last file that was read. -@example ... -@param name desc -@see http://... or Obj#meth -... -$< -@abstract The $< global is the virtual concatenation file of the files given on command line (or from $stdin if no files were given). -@example ... -@param name desc -@see http://... or Obj#meth -... -$> -@abstract The $> global is the default output for print, printf. $stdout by default. -@example ... -@param name desc -@see http://... or Obj#meth -... -$_ -@abstract The $_ global is the last input line of string by gets or readline. -@example ... -@param name desc -@see http://... or Obj#meth -... -$0 -@abstract The $0 global Same as $PROGRAM_NAME. Contains the name of the script being executed. May be assignable. -@example ... -@param name desc -@see http://... or Obj#meth -... -$* -@abstract The $* global Command line arguments given for the script sans args. -@example ... -@param name desc -@see http://... or Obj#meth -... -$$ -@abstract The $$ global is the process number of the Ruby running this script. -@example ... -@param name desc -@see http://... or Obj#meth -... -$? -@abstract The $? global is the status of the last executed child process. -@example ... -@param name desc -@see http://... or Obj#meth -... -$: -@abstract The $: global Load path for scripts and binary modules by load or require. -@example ... -@param name desc -@see http://... or Obj#meth -... -$" -@abstract The $" global is the array contains the module names loaded by require. -@example ... -@param name desc -@see http://... or Obj#meth -... -$DEBUG -@abstract The $DEBUG global is the status of the -d switch. -@example ... -@param name desc -@see http://... or Obj#meth -... -$FILENAME -@abstract The $FILENAME global Current input file from $<. Same as $<.filename. -@example ... -@param name desc -@see http://... or Obj#meth -... -$LOAD_PATH -@abstract The $LOAD_PATH global is the alias to the $:. -@example ... -@param name desc -@see http://... or Obj#meth -... -$stderr -@abstract The $stderr global is the current standard error output. -@example ... -@param name desc -@see http://... or Obj#meth -... -$stdin -@abstract The $stdin global is the current standard input. -@example ... -@param name desc -@see http://... or Obj#meth -... -$stdout -@abstract The $stdout global is the current standard output. -@example ... -@param name desc -@see http://... or Obj#meth -... -$VERBOSE -@abstract The $VERBOSE global is the verbose flag, which is set by the -v switch. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-0 -@abstract The $-0 global is the alias to $/. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-a -@abstract The $-a global True if option -a is set. Read-only variable. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-d -@abstract The $-d global is the alias to $DEBUG. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-F -@abstract The $-F global is the alias to $;. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-i -@abstract The $-i global In in-place-edit mode, this variable holds the extension, otherwise nil. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-I -@abstract The $-I global is the alias to $:. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-l -@abstract The $-l global True if option -l is set. Read-only variable. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-p -@abstract The $-p global True if option -p is set. Read-only variable. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-v -@abstract The $-v global is an alias to $VERBOSE. -@example ... -@param name desc -@see http://... or Obj#meth -... -$-w -@abstract The $-w global True if option -w is set. -@example ... -@param name desc -@see http://... or Obj#meth -}) + explanations: find_docs(%r/Ruby Global (\S+)/) }, ] def self.explain thing diff --git a/pry-docmore.wiki b/pry-docmore.wiki index 5de0074..f200fce 160000 --- a/pry-docmore.wiki +++ b/pry-docmore.wiki @@ -1 +1 @@ -Subproject commit 5de00745ffec3065ccbf6846ab5aa1b05f9b850a +Subproject commit f200fcef71b0c32a630e63702d608cdae2e1785c diff --git a/spec/pry-docmore_spec.rb b/spec/pry-docmore_spec.rb index 7708e6e..224d9cd 100644 --- a/spec/pry-docmore_spec.rb +++ b/spec/pry-docmore_spec.rb @@ -41,7 +41,7 @@ def it_explains_each args args[:cases].each do |e| e[args[:specifically]].each do |v| self.example.metadata[:description_args] = v + description - multiline_content = %r/\n.+\n.+/ + multiline_content = %r/.+\n.+/ Pry::Docmore.explain(v).should match multiline_content end end