Ruby 核心文档质量

发布于 2024-10-09 13:51:04 字数 1431 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巨坚强 2024-10-16 13:51:04

您必须记住,Ruby 是一种面向对象的语言,标准库中的许多对象都是构建在其他对象之上的。此外,许多模块还通过模块进行了扩展,从而添加了新功能。

因此,在文档中您需要了解对象是建立在哪些东西之上的。就 File 而言,它构建在 IO 之上,将具有您期望在标准“文件”类中找到的许多功能。

我同意 Ruby 的一些文档是脱节的。我认为获得一本好书很重要;我推荐我们称之为“The Pickaxe Book”的一本,又名“Programming Ruby”。还有许多其他好书,以及一些很好的在线文档,但这是一本很棒的入门书。 [第一版]可在线免费获取;它有点过时但仍然有用。

我建议浏览一些与此类似的其他问题以获得更多建议。

我还保持 Ruby 1.9 的 Core关键字文档。最后,Ruby-Docs 站点 的顶部指出了很多有用的信息,尽管您确实这样做了必须注意文档适用于哪个版本。

最后,不要忽略内置帮助:命令行中的 ri 是您自己计算机上的快速信息源,其中应包含核心和标准库以及所有 gem 的文档你已经安装了。 ri open 会告诉您定义“open”的所有位置。 ri File.open 将为您提供有关该命令的大量信息。


当我开始使用 Ruby 时,学习该语言的最大障碍是文档。我仍然发现获取有关 PerlPython,并且感觉 Ruby 应该使用这些作为示例。但这并没有改变我使用 Ruby 的乐趣。这是一门很棒的语言,一旦克服了最初的困难,我就会越来越喜欢它。

@phoffer 在上面的评论中推荐 RubyDoc.info 。我没看过那个网站,但看起来不错。我喜欢它清楚地显示了类继承的内容。

You have to remember that Ruby is an object-oriented language, and a lot of objects in the Standard Library, are built on-top of other objects. In addition, many are extended by modules, which add in new functionality.

So, in the documentation you need to see what things an Object is built-upon. In File's case, it's built on top of IO, which will have a lot of the functionality you'd expect to find in a standard "file" class.

I agree that some of Ruby's documentation is disjointed. I think it's important to get a good book; I recommend the one we refer to as "The Pickaxe Book", AKA "Programming Ruby". There are many other good books, along with some good documentation on line, but this is a great go-to book. The [first edition] is available for free online; It is a bit outdated but still useful.

I'd recommend browsing through some of the other questions similar to this on SO for more suggestions.

I also keep links open to Ruby 1.9's Core and Keyword docs. And, finally, the top of the Ruby-Docs site points to lots of good info though you do have to pay attention to which version the docs are for.

Finally, don't ignore the built-in help: ri at the command-line is a fast source of info on your own machine that should contain documentation for the core and standard library, plus all the gems you have installed. ri open would have told you all the places "open" was defined. ri File.open would have given you a lot of information about that command.


When I started with Ruby, the biggest impediment to learning the language was the documentation. I still find it a lot easier to get info about Perl and Python, and feel like Ruby should use those as examples. That doesn't change my enjoyment of using Ruby though. It's a great language and once getting over the initial hump I like it more and more.

@phoffer recommends RubyDoc.info in the comment above. I hadn't seen that site but it looks good. I like that it shows what a class inherits from clearly.

负佳期 2024-10-16 13:51:04

您是对的,1.9 之前的文档中存在有关 File#open 的错误。

Kernel 下有一个 open 记录,是的,您实际上可以说 File.open 正如您所指出的,它只是没有记录在 FileIO 中。

我的建议是使用 1.9 文档< /强>...

You are correct, there is a bug in the pre-1.9 documentation regarding File#open.

There is an open documented under Kernel, and yes, you can in fact say File.open as you noted, it just isn't documented either in File or in IO.

My advice is to just use 1.9 docs...

〃温暖了心ぐ 2024-10-16 13:51:04

我当前的版本是 ruby​​ 2.0.0 和 ri 4.0.1 (ri -v)。我在输入 ri File.open => 时遇到了同样的问题。 “对 File.open 一无所知”

在互联网上搜寻后,我发现了这段代码 来源

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

该页面也很好地解释了为什么应该使用 ri 而不是 google。

编辑:代码修复了“对 File.open 一无所知”的产量。安装需要一些时间,因此请打开一个新选项卡。

My current version is ruby 2.0.0 and ri 4.0.1 (ri -v). I have been stumbling with the same problem where I type ri File.open => "Nothing known about File.open"

After scourging the internet I found this code Source

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

The page is also a good read to why you should use ri instead of google.

Edit: The code fixed the "Nothing known about File.open" yield. It takes some time to install so open a new tab.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文