有没有办法找出我的ri命令的哪一部分没有显示Ruby的文档:
$ ruby --version
ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]
$ ri --version
ri 3.12.2
$ ri String
Nothing known about String
Run Code Online (Sandbox Code Playgroud)
当我使用撬:
$ pry --version
Pry version 0.9.12 on Ruby 1.9.3
$ pry
[1] pry(main)> ri String
# shows String documentation
[2] pry(main)> ri String.split
error: 'String.split' not found
[3] pry(main)> ri String.strip
String.strip not found, maybe you meant:
String#strip_heredoc
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能显示文档?
fme*_*dez 28
如果您正在使用RVM管理Ruby安装,则可以执行以下操作:
rvm docs generate
Run Code Online (Sandbox Code Playgroud)
如果没有,请尝试这样做:
gem install rdoc-data
rdoc-data --install
Run Code Online (Sandbox Code Playgroud)
然后ri再次尝试该命令.
hor*_*guy 12
使用pry,最好安装pry-docgem,然后使用show-doc命令:
[17] pry(main)> show-doc String#inspect
From: string.c (C Method):
Owner: String
Visibility: public
Signature: inspect()
Number of lines: 6
Returns a printable version of _str_, surrounded by quote marks,
with special characters escaped.
str = "hello"
str[3] = "\b"
str.inspect #=> "\"hel\\bo\""
[18] pry(main)> show-doc Array#pop
From: array.c (C Method):
Owner: Array
Visibility: public
Signature: pop(*arg1)
Number of lines: 11
Removes the last element from self and returns it, or
nil if the array is empty.
If a number n is given, returns an array of the last n elements
(or less) just like array.slice!(-n, n) does. See also
Array#push for the opposite effect.
a = [ "a", "b", "c", "d" ]
a.pop #=> "d"
a.pop(2) #=> ["b", "c"]
a #=> ["a"]
[19] pry(main)>
Run Code Online (Sandbox Code Playgroud)
注意:如果您愿意,也可以使用?别名show-doc.
| 归档时间: |
|
| 查看次数: |
12084 次 |
| 最近记录: |