gpt4 book ai didi

ruby - 为 ruby​​ 2.5 生成文档

转载 作者:行者123 更新时间:2023-12-04 17:36:30 26 4
gpt4 key购买 nike

在 Ubuntu 18.04 上安装了 ruby​​ 2.5 我尝试使用 ri 命令得到以下结果:

$ ri String
Nothing known about String

回答similar questions ,建议提供给:

<强>1。使用 rvm 命令生成文档

$ rvm docs generate

我没有使用 rvm 安装,所以我想这个选项对我来说是关闭的。

<强>2。为已安装的 gem 生成文档

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

这给出了以下错误信息:

ERROR:  Unable to document did_you_mean-1.2.0, /usr/share/rubygems-integration/all/gems/did_you_mean-1.2.0 is missing, skipping
ERROR: Unable to document minitest-5.10.3, /usr/share/rubygems-integration/all/gems/minitest-5.10.3 is missing, skipping
ERROR: Unable to document net-telnet-0.1.1, /usr/share/rubygems-integration/all/gems/net-telnet-0.1.1 is missing, skipping
ERROR: Unable to document power_assert-0.2.7, /usr/share/rubygems-integration/all/gems/power_assert-0.2.7 is missing, skipping
ERROR: Unable to document rake-12.3.1, /usr/share/rubygems-integration/all/gems/rake-12.3.1 is missing, skipping
Parsing documentation for rdoc-4.3.0
Parsing documentation for rdoc-data-4.1.0
ERROR: Unable to document test-unit-3.2.5, /usr/share/rubygems-integration/all/gems/test-unit-3.2.5 is missing, skipping

<强>3。使用 rdoc-data --install

$ gem install rdoc-data
$ rdoc-data --install

这返回了错误信息:

NOTE: Gem.datadir is deprecated; use spec.datadir instead. It will be removed on or after 2016-10-01.
Gem.datadir called from /var/lib/gems/2.5.0/gems/rdoc-data-4.1.0/lib/rdoc/data.rb:50.
Your ruby version 2.5 is not supported, only 1.8, 1.9, 2.0, 2.1, 2.2, 2.3

也许这安装了一个过时版本的 rdoc-data gem?如果是这样,有什么办法可以解决这个问题吗?

<强>4。从源代码生成文档

$ tar xvfz ~/Downloads/ruby-2_5_4.tar.gz
$ cd ruby-2_5_4
$ rdoc --all --ri

这给出了错误:

Traceback (most recent call last):
1: from /usr/local/bin/rdoc:23:in `<main>'
/usr/local/bin/rdoc:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.5.0/gems/rdoc-6.0.1/exe/rdoc (LoadError)

事实上,exe 目录包含文件 rdoc2.5 而不是普通的 rdoc

所以。从这里去哪里?

最佳答案

通常情况下,完整记录我已经尝试过的内容显示了前进的方向,而第四次尝试的错误消息让我想知道 rdoc2.5 是否在路径中可用,这是。

以下对我有用:

$ rdoc2.5 --all --ri
Parsing sources...
100% [831/831] vsnprintf.c

Generating RI format into /home/christians/.rdoc...

Files: 831

Classes: 1324 ( 565 undocumented)
Modules: 284 ( 121 undocumented)
Constants: 1313 ( 526 undocumented)
Attributes: 1066 ( 251 undocumented)
Methods: 10078 (2161 undocumented)

Total: 14065 (3624 undocumented)
74.23% documented

Elapsed: 26.8s

尽管我只能使用 ri2.5 命令查看文档。常规 ri 命令返回一个不同的错误,表明我可能已经使用这些实验性解决方案之一破坏了某些东西:

$ ri String
Traceback (most recent call last):
1: from /usr/local/bin/ri:23:in `<main>'
/usr/local/bin/ri:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.5.0/gems/rdoc-6.0.1/exe/ri (LoadError)

这让我想知道我的 ruby​​ 安装是否像它应该的那样干净。 dpkg 命令报告安装了以下 ruby​​ 包:

$ dpkg -l | grep ruby
ii libruby2.5:amd64 2.5.1-1ubuntu1.2 amd64 Libraries necessary to run Ruby 2.5
ii rake 12.3.1-1 all ruby make-like utility
ii ruby 1:2.5.1 amd64 Interpreter of object-oriented scripting language Ruby (default version)
ii ruby-did-you-mean 1.2.0-2 all smart error messages for Ruby > 2.3
ii ruby-minitest 5.10.3-1 all Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii ruby-net-telnet 0.1.1-2 all telnet client library
ii ruby-power-assert 0.3.0-1 all library showing values of variables and method calls in an expression
ii ruby-test-unit 3.2.5-1 all unit testing framework for Ruby
ii ruby2.5 2.5.1-1ubuntu1.2 amd64 Interpreter of object-oriented scripting language Ruby
ii rubygems-integration 1.11 all integration of Debian Ruby packages with Rubygems

也许最好从头开始重新安装所有与 ruby​​ 相关的东西?


更新:我删除了与 ruby​​ 相关的所有内容,并手动删除了/usr/local/bin 中的几个命令(ri 和 rdoc)。我使用 apt install ruby​​ 重新安装,一切似乎都很好。文档在安装后生成并可用。

关于ruby - 为 ruby​​ 2.5 生成文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56532624/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com