如何从命令行获取 Ruby 文档 [英] How to get the Ruby documentation from the command line

查看:47
本文介绍了如何从命令行获取 Ruby 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找出我的 ri 命令的哪一部分没有显示 Ruby 的文档:

Is there a way to find out which part of my ri command that is not showing Ruby's documentation:

 $ 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

当我使用 pry 时:

When I use pry:

 $ 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

我应该怎么做才能显示文档?

What should I do to make the documentation appear?

推荐答案

如果您使用 RVM 来管理您的 Ruby 安装,您可以这样做:

If you're using RVM to manage your Ruby installations you can do this:

rvm docs generate

如果没有,请尝试这样做:

If not, try doing this:

gem install rdoc-data
rdoc-data --install

然后再次尝试 ri 命令.

then try the ri command again.

这篇关于如何从命令行获取 Ruby 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆