如何安装Ruby ri文档?

时间:2022-11-04 07:16:01

I've recently installed Ruby 1.9.1 on Windows 7, and apparently it doesn't come with the standard ri documentation. So when I do 'ri Array', I get:

我最近在Windows 7上安装了Ruby 1.9.1,显然它没有附带标准的ri文档。所以当我做'ri Array'时,我得到:

C:\>ri Array

Nothing known about Array

Is there a way I can install this documentation so that the above works?

有没有办法安装这个文档,以便上述工作?

7 个解决方案

#1


6  

Seems you have installer Ruby 1.9.1 distributed by the RubyInstaller project.

似乎你有RubyInstaller项目分发的安装程序Ruby 1.9.1。

You can use the Windows Help Files (CHM) that came with the installer instead of the ri documentation.

您可以使用安装程序附带的Windows帮助文件(CHM)而不是ri文档。

The problem of the RI documentation is that some versions of RDoc have problems generating it and also generated more than 10 thousands files which slowed down the installers considerably.

RI文档的问题在于某些版本的RDoc在生成它时遇到问题,并且还生成了超过10,000个文件,这大大减慢了安装程序的速度。

#2


29  

In case people on other platforms need to install their ri docs (like I did). This article gives the why and the how:

如果其他平台上的人需要安装他们的ri文档(就像我一样)。本文给出了原因和方法:

http://jstorimer.com/ri.html

http://jstorimer.com/ri.html

The command is:

命令是:

gem rdoc --all --ri --no-rdoc

#3


20  

If you are using rvm you should rvm docs generate (or just rvm docs generate-ri)

如果你使用rvm,你应该rvm docs generate(或者只是rvm docs generate-ri)

See this info (2011August) about rvm and ri

关于rvm和ri,请参阅此信息(2011年8月)

#4


7  

None of the proposed solutions worked for me. In the end the solution I found was super simple, so I'll leave it here. (I'm running ruby 2.2.4 on win7 x64 in case that's relevant)

所提出的解决方案都不适合我。最后我找到的解决方案非常简单,所以我会把它放在这里。 (我在win7 x64上运行ruby 2.2.4,如果相关的话)

(captain obvious alert: ruby must be installed and in your PATH)

(船长明显提醒:必须安装ruby并在你的路径中)

-open cmd

- 打开cmd

-$ gem install rdoc-data

-$ rdoc-data --install

And you're set! test that it worked by running:

你就定了!通过运行测试它是否有效:

-$ ri Array It should give you all the lovely documentation for the class!

- $ ri数组它应该为你提供课堂上所有可爱的文档!

Hope this helps!

希望这可以帮助!

ps. I just noticed that this is the solution that Luis Lavena proposed in a comment, but his comment wasn't clear to me so I had continued searching. Basically this is the same solution but explained more clearly so that that doesn't happen to anyone else :)

PS。我只是注意到这是Luis Lavena在评论中提出的解决方案,但他的评论对我来说并不清楚,所以我继续搜索。基本上这是相同的解决方案,但更清楚地解释,这样就不会发生在其他任何人身上:)

Cheers!

干杯!

#5


4  

RVM does not automatically generate and install each Ruby's ri / rdoc documentation. You can generate using the following command: rvm docs generate

RVM不会自动生成和安装每个Ruby的ri / rdoc文档。您可以使用以下命令生成:rvm docs generate

#6


0  

All the Ruby Docs are at http://www.ruby-doc.org

所有Ruby Docs都在http://www.ruby-doc.org

So the array documentation is at:

因此阵列文档位于:

http://ruby-doc.org/core/classes/Array.html

http://ruby-doc.org/core/classes/Array.html

Never tried it on windows but because its saying Nothing Known about X its not that its not installed just not got anything there.

从来没有尝试过在Windows上,但是因为它说没有知道关于X它不是没有安装它只是没有得到任何东西。

Try installing a gem as you can then ri GEM_CLASS as that should provide defentions, should let us see if its missing documentation or if ri's not looking in the right place

尝试安装一个gem,然后你可以ri GEM_CLASS,因为它应该提供防御,应该让我们看看它是否缺少文档或ri没有找到正确的位置

#7


0  

Things are still largely the same with Ruby Installer 2.4.1.2 (year 2017). If I run ri Array, it shows Array < Object and nothing else. If I run ri "Array#each", I get the familiar "Nothing known..." message. In short, the ri-format documentation on Ruby core and standard libraries are missing.

Ruby Installer 2。4。1。2(2017年)的情况基本相同。如果我运行ri Array,它会显示Array 而不显示其他内容。如果我运行ri“array#each”,我会得到熟悉的“nothing>

Here's how I got my copy of core/stdlib ri-documentation. Of course, Ruby must be installed prior to this.

以下是我获取core / stdlib ri文档的副本。当然,必须在此之前安装Ruby。

  1. Get ruby's source code that most closely matches my version from their Github releases page.
  2. 从他们的Github发布页面获取与我的版本最匹配的ruby源代码。
  3. Extract the .zip or .tar.gz archive to some folder
  4. 将.zip或.tar.gz存档解压缩到某个文件夹
  5. Open cmd.exe/Powershell, cd to that folder and run rdoc --all --ri
    • This command parses .c files, .rb files, and a few other file types in the current directory recursively and generates ri-documentation to ~/.rdoc directory.
    • 此命令以递归方式解析当前目录中的.c文件,.rb文件和一些其他文件类型,并生成〜/ .rdoc目录的ri文档。
    • Took about 5 minutes on my laptop with i7-3520M processor to complete, with no errors.
    • 使用i7-3520M处理器在我的笔记本电脑上花了大约5分钟完成,没有任何错误。
  6. 打开cmd.exe / Powershell,cd到该文件夹​​并运行rdoc --all --ri此命令以递归方式解析当前目录中的.c文件,.rb文件和其他一些文件类型,并生成ri-documentation到〜/ .rdoc目录。使用i7-3520M处理器在我的笔记本电脑上花了大约5分钟完成,没有任何错误。
  7. Delete the archive and the directory containing the source code because we don't need them anymore.
  8. 删除存档和包含源代码的目录,因为我们不再需要它们了。

Now if you try running ri Array or ri "Array#each" you'll get the documentation in all its glory.

现在,如果您尝试运行ri Array或ri“Array#each”,您将获得所有荣耀的文档。

tl;dr

Run rdoc --all --ri on directory containing source code for same ruby version as your installed version.

在包含与安装版本相同的ruby版本的源代码的目录上运行rdoc --all --ri。


Appendix Z: Comments on other answers

  1. The rvm docs generate-ri could work, but you have to use Cygwin or Ubuntu on Windows (if on Windows 10) to use rvm.
  2. rvm docs generate-ri可以工作,但你必须在Windows上使用Cygwin或Ubuntu(如果在Windows 10上)才能使用rvm。
  3. gem rdoc --all --ri --no-rdoc installs ri-documentation for all your gems. It doesn't install the core/stdlib documentations.
  4. gem rdoc --all --ri --no-rdoc为你的所有宝石安装ri文档。它不会安装core / stdlib文档。
  5. gem install rdoc-data followed by rdoc-data --install only works for Ruby versions up to 2.3.0.
  6. gem install rdoc-data后跟rdoc-data --install仅适用于最高2.3.0的Ruby版本。

#1


6  

Seems you have installer Ruby 1.9.1 distributed by the RubyInstaller project.

似乎你有RubyInstaller项目分发的安装程序Ruby 1.9.1。

You can use the Windows Help Files (CHM) that came with the installer instead of the ri documentation.

您可以使用安装程序附带的Windows帮助文件(CHM)而不是ri文档。

The problem of the RI documentation is that some versions of RDoc have problems generating it and also generated more than 10 thousands files which slowed down the installers considerably.

RI文档的问题在于某些版本的RDoc在生成它时遇到问题,并且还生成了超过10,000个文件,这大大减慢了安装程序的速度。

#2


29  

In case people on other platforms need to install their ri docs (like I did). This article gives the why and the how:

如果其他平台上的人需要安装他们的ri文档(就像我一样)。本文给出了原因和方法:

http://jstorimer.com/ri.html

http://jstorimer.com/ri.html

The command is:

命令是:

gem rdoc --all --ri --no-rdoc

#3


20  

If you are using rvm you should rvm docs generate (or just rvm docs generate-ri)

如果你使用rvm,你应该rvm docs generate(或者只是rvm docs generate-ri)

See this info (2011August) about rvm and ri

关于rvm和ri,请参阅此信息(2011年8月)

#4


7  

None of the proposed solutions worked for me. In the end the solution I found was super simple, so I'll leave it here. (I'm running ruby 2.2.4 on win7 x64 in case that's relevant)

所提出的解决方案都不适合我。最后我找到的解决方案非常简单,所以我会把它放在这里。 (我在win7 x64上运行ruby 2.2.4,如果相关的话)

(captain obvious alert: ruby must be installed and in your PATH)

(船长明显提醒:必须安装ruby并在你的路径中)

-open cmd

- 打开cmd

-$ gem install rdoc-data

-$ rdoc-data --install

And you're set! test that it worked by running:

你就定了!通过运行测试它是否有效:

-$ ri Array It should give you all the lovely documentation for the class!

- $ ri数组它应该为你提供课堂上所有可爱的文档!

Hope this helps!

希望这可以帮助!

ps. I just noticed that this is the solution that Luis Lavena proposed in a comment, but his comment wasn't clear to me so I had continued searching. Basically this is the same solution but explained more clearly so that that doesn't happen to anyone else :)

PS。我只是注意到这是Luis Lavena在评论中提出的解决方案,但他的评论对我来说并不清楚,所以我继续搜索。基本上这是相同的解决方案,但更清楚地解释,这样就不会发生在其他任何人身上:)

Cheers!

干杯!

#5


4  

RVM does not automatically generate and install each Ruby's ri / rdoc documentation. You can generate using the following command: rvm docs generate

RVM不会自动生成和安装每个Ruby的ri / rdoc文档。您可以使用以下命令生成:rvm docs generate

#6


0  

All the Ruby Docs are at http://www.ruby-doc.org

所有Ruby Docs都在http://www.ruby-doc.org

So the array documentation is at:

因此阵列文档位于:

http://ruby-doc.org/core/classes/Array.html

http://ruby-doc.org/core/classes/Array.html

Never tried it on windows but because its saying Nothing Known about X its not that its not installed just not got anything there.

从来没有尝试过在Windows上,但是因为它说没有知道关于X它不是没有安装它只是没有得到任何东西。

Try installing a gem as you can then ri GEM_CLASS as that should provide defentions, should let us see if its missing documentation or if ri's not looking in the right place

尝试安装一个gem,然后你可以ri GEM_CLASS,因为它应该提供防御,应该让我们看看它是否缺少文档或ri没有找到正确的位置

#7


0  

Things are still largely the same with Ruby Installer 2.4.1.2 (year 2017). If I run ri Array, it shows Array < Object and nothing else. If I run ri "Array#each", I get the familiar "Nothing known..." message. In short, the ri-format documentation on Ruby core and standard libraries are missing.

Ruby Installer 2。4。1。2(2017年)的情况基本相同。如果我运行ri Array,它会显示Array 而不显示其他内容。如果我运行ri“array#each”,我会得到熟悉的“nothing>

Here's how I got my copy of core/stdlib ri-documentation. Of course, Ruby must be installed prior to this.

以下是我获取core / stdlib ri文档的副本。当然,必须在此之前安装Ruby。

  1. Get ruby's source code that most closely matches my version from their Github releases page.
  2. 从他们的Github发布页面获取与我的版本最匹配的ruby源代码。
  3. Extract the .zip or .tar.gz archive to some folder
  4. 将.zip或.tar.gz存档解压缩到某个文件夹
  5. Open cmd.exe/Powershell, cd to that folder and run rdoc --all --ri
    • This command parses .c files, .rb files, and a few other file types in the current directory recursively and generates ri-documentation to ~/.rdoc directory.
    • 此命令以递归方式解析当前目录中的.c文件,.rb文件和一些其他文件类型,并生成〜/ .rdoc目录的ri文档。
    • Took about 5 minutes on my laptop with i7-3520M processor to complete, with no errors.
    • 使用i7-3520M处理器在我的笔记本电脑上花了大约5分钟完成,没有任何错误。
  6. 打开cmd.exe / Powershell,cd到该文件夹​​并运行rdoc --all --ri此命令以递归方式解析当前目录中的.c文件,.rb文件和其他一些文件类型,并生成ri-documentation到〜/ .rdoc目录。使用i7-3520M处理器在我的笔记本电脑上花了大约5分钟完成,没有任何错误。
  7. Delete the archive and the directory containing the source code because we don't need them anymore.
  8. 删除存档和包含源代码的目录,因为我们不再需要它们了。

Now if you try running ri Array or ri "Array#each" you'll get the documentation in all its glory.

现在,如果您尝试运行ri Array或ri“Array#each”,您将获得所有荣耀的文档。

tl;dr

Run rdoc --all --ri on directory containing source code for same ruby version as your installed version.

在包含与安装版本相同的ruby版本的源代码的目录上运行rdoc --all --ri。


Appendix Z: Comments on other answers

  1. The rvm docs generate-ri could work, but you have to use Cygwin or Ubuntu on Windows (if on Windows 10) to use rvm.
  2. rvm docs generate-ri可以工作,但你必须在Windows上使用Cygwin或Ubuntu(如果在Windows 10上)才能使用rvm。
  3. gem rdoc --all --ri --no-rdoc installs ri-documentation for all your gems. It doesn't install the core/stdlib documentations.
  4. gem rdoc --all --ri --no-rdoc为你的所有宝石安装ri文档。它不会安装core / stdlib文档。
  5. gem install rdoc-data followed by rdoc-data --install only works for Ruby versions up to 2.3.0.
  6. gem install rdoc-data后跟rdoc-data --install仅适用于最高2.3.0的Ruby版本。