`

如何:生产CHM版的Rails手册

阅读更多

Update April 21, 2008: Delynn Berry now has a new CHM file up for Rails version 2.0.2 with a much better index and fewer broken links than what I was able to create. Get it here.

CHM (compiled HTML Help) is arguably one of the better Microsoft inventions and generating these files from Ruby on Rails documentation is should be easy using Rdoc.
A general article on the different ways of generating Rails offline documentation is here.

The Rdoc approach is described in this article:

http://wiki.rubyonrails.org/rails/pages/HowToGenerateChmForRails

Older (and possibly newer in the future) CHM files created using this technique are here: http://delynnberry.com/projects/rails-chm-documentation

These are the basic rdoc instructions:

The core command is:

rdoc -f chm -o chm_folder action* rails-*

which you have to run in

C:\ruby\lib\ruby\gems\1.8\gems\

(assuming c:\ruby is your ruby directory).

You might (or will likely) get this error:

rails-2.0.1/lib/rails_generator/generators/components/controller/templates/controller.rb:3:15: Expected class name or ‘<
<’. Got RubyToken::TkLT: “<”

This is the offending file:

C:\ruby\lib\ruby\gems\1.8\gems\rails-2.0.2\lib\rails_generator\generators\components\controller\templates\controller.rb

You can exclude this file by altering the command like so:

rdoc -f chm -o chm_folder action* rails-* -x controller.rb

It should then run up to this point.

Generating CHM…
C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `initialize’: Invalid argument - classes/<.html (Errno::EINVAL)
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `open’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `gen_into’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `each’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `gen_into’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1277:in `generate_html’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1197:in `generate’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/chm_generator.rb:38:in `generate’
        from C:/ruby/lib/ruby/1.8/rdoc/rdoc.rb:284:in `document’
        from C:/ruby/bin/rdoc:62

This is quite hard to work around and some suggest you should just compile help for the action* packages:

rdoc -f chm -o chm_folder action*

which contain enough documentation to get by with most daily tasks.

Update March 2, 2008: The technique described by Michael in the comments using the command

rdoc -f chm -o chm_folder action* rails-* -x template/*

works fine to create a chm file. However, I use this technique only to create the index.hhk file which I then use in the following HTML Help “manual” process, which IMHO leads to a better linked document and nicely inlined source code:

  1. Download the Rails Project files from here: http://rubyforge.org/frs/?group_id=307 and unzip to your hard drive.
  2. Download HTML Help Workshop and install (which you need for the above rdoc technique as well).
  3. Start HTML Help Workshop and create a new project:

image

Give it a descriptive name (damn, is that a real wizard on the left?!; I guess those were the good old days):

image

In the Existing Files step, select just HTML files:

image

Click add:

image

Navigate to the <folder you unzipped rails to>\rails\doc\api:

image

Select only the index.html file:

image

The project is created.

Go to the Contents tab:

image

Give it a name and save:

image

Optionally do the same for index (I haven’t had any luck generating an index file).

Update March 2, 2008: Simply navigate to the index.hhk file generated using the

rdoc -f chm -o chm_folder action* rails-* -x template/*

command. This index will work only partly and many links will be dead but many work, so…

Set the project options as follows:

image

Make sure the Default file is set to “index.html”, not the full path:

image

Select “Automatically create content file (.hhc) when compiling”:

image

I was so far unable to create an index, so checking “Include keywords from HTML files” has no effect for me.

Set “Compile full-text search information”:

image

Fire “Save all and compile”. You should get a searchable CHM file with the Rails documentation.

image

Here is the resulting CHM file, now with (rudimentary and flaky) index. Enjoy.

Update March 2, 2008: I’ve uploaded a new version of the CHM file, now with an index I generated with the technique described by Michael (see comments below). However, the index works only party, many links are broken. But it’s better than nothing I guess.

And finally, some non-Windows CHM readers (thanks to Delynn Berry):

 

 

http://dirk.net/2007/12/30/generate-ruby-on-rails-chm-documentation/

分享到:
评论

相关推荐

    Flexible Rails: Flex3 on Rails2

    ### Flexible Rails: Flex3 on Rails2 #### 关于Flexible Rails 本书《Flexible Rails: Flex 3 on Rails 2》由Peter Armstrong撰写,旨在探讨如何结合使用Flex 3和Rails 2来开发高效的富互联网应用程序(Rich ...

    HeadFirst系列之:深入浅出Rails(中文版)高清完整PDF

    《深入浅出Rails》将使你的编程和生产力达到最大值。你将学习一切Rails scaffolding的基本原理,以创建自定义的交互式网络应用程序,全部使用Rails的一套丰富的工具和MVC框架。 你将掌握数据库交互、Ajax和XML的集成...

    Rails的精简版本Rails::API.zip

    Rails::API 是 Rails 的精简版本,针对不需要使用完整 Rails 功能的开发者。 Rails::API 移除了 ActionView 和其他一些渲染功能,不关心Web前端的开发者可更容易、快速地开发应用程序,因此运行速度比正常的 Rails ...

    rails_console_toolkit:可配置的 Rails 控制台助手

    RailsConsole 工具包 :wrench: :toolbox: 可配置的 Rails 控制台助手更快地查找记录,添加自定义助手,将您的控制台寿命提高 100%。安装将此行添加到应用程序的 Gemfile 中: gem 'rails_console_toolkit' 然后生成...

    ruby on rails 2.2.2 参考手册

    本参考手册是学习Rails 2.2.2的重要资源,特别适合初学者和有一定经验的开发者。它提供了详尽的API文档,帮助开发者深入理解Rails框架中的各个组件和方法。以下是一些关键的知识点: 1. **MVC架构**:Rails的核心...

    Rails上的API:使用Rails构建REST APIAPIs on Rails: Building REST APIs with Rails

    在本篇内容中,我们将深入探讨如何利用Ruby on Rails(简称Rails)这一强大的Web应用程序框架来构建可伸缩且易于维护的RESTful API。Rails以其简洁优雅的语法、高效的开发速度以及良好的社区支持而闻名,这使得它...

    rails-secrets:Rails 4.0的Rails 4.1 configsecrets.yml

    Rails的秘密 此gem将config/secrets.yml从Rails 4.1 config/secrets.yml移植到Rails 4.0应用程序。 安装 将此行添加到您的应用程序的Gemfile中: gem 'rails-secrets' 然后执行: $ bundle 或将其自己安装为: ...

    在rails中 使用RSpec生产CHM文档

    标题 "在Rails中使用RSpec生产CHM文档" 暗示了这个话题是关于如何在Ruby on Rails(简称Rails)框架中使用RSpec测试工具来创建帮助文档,特别是以CHM(Microsoft Compiled HTML Help)格式。CHM文件是一种常见的...

    rails-dummy:为测试和Rails引擎生成虚拟的Rails应用程序

    Rails ::虚拟 使用RSpec或Test :: Unit为引擎生成虚拟应用程序的简单任务。 安装 将此行添加到您的应用程序的Gemfile中: gem 'rails-dummy' 然后执行: $ bundle 或自己安装为: $ gem install rails-dummy ...

    rails 开发手册

    12. **部署**:手册还将涵盖如何将Rails应用部署到生产环境,如Heroku、AWS或自己的服务器,以及配置Nginx和Passenger等服务器。 通过深入学习和实践Rails开发手册中的内容,开发者能够掌握构建高效、可维护的Rails...

    rails3 api chm格式

    标题中的“rails3 api chm格式”指的是一个关于Rails 3框架API的离线帮助文档,采用CHM(Microsoft Compiled HTML Help)格式。这种格式通常用于制作电子书或技术文档,便于用户在没有网络连接的情况下查阅。Rails是...

    Web开发:Ruby on Rails.pdf

    Web开发:Ruby on Rails.pdf

    rails-settings:使用Ruby on Rails管理设置

    Rails的设置 Ruby gem通过将ActiveRecord实例的设置作为序列化的Hash存储在单独的数据库表中来处理ActiveRecord实例的设置。 包括命名空间和默认值。 要求 Ruby 2.4或更高版本 Rails 4.2或更高版本(包括Rails 6) ...

    Ruby on Rails教程:学习使用Rails进行Web开发Ruby on Rails Tutorial: Learn Web Development with Rails

    本书教您如何使用Ruby on Rails开发和部署真正的,具有工业实力的Web应用程序,Ruby on Rails是为诸如Twitter,Hulu,GitHub和Yellow Pages等顶级网站提供支持的开源Web框架。

    rails-timeago:时间标记的Rails助手,可以与jQuery Timeago插件一起使用

    rails-timeago提供了一个timeago_tag助手来创建可用于插件的时间标签。 安装 将此行添加到您的应用程序的Gemfile : gem 'rails-timeago' , '~&gt; 2.0' 然后执行: $ bundle 或将其自己安装为: $ gem install ...

    kickbox_rails:Kickbox.io Rails验证器

    $ rails g kickbox_rails:install 用法 # Rails class Person &lt; ActiveRecord::Base validates_kickbox_email_format :email # OR validates :email, kickbox_email_format: { message: 'Email

    rails本地安装包完整版

    在这个"rails本地安装包完整版"中,包含了Rails 2.1.0版本的关键组件,这些组件是Rails框架的核心部分。 1. **activesupport-2.1.0.gem**:ActiveSupport是Rails的一个重要库,提供了许多实用的工具和方法,如时间...

    Agile Web Development with Rails 4th edition(敏捷Web开发与Rails:程序指南 第四版)

    《敏捷Web开发与Rails:程序指南 第四版》是一本深度探讨使用Ruby on Rails框架进行敏捷Web应用开发的专业书籍。本书旨在帮助开发者充分利用Rails 4的特性,提高开发效率,实现快速迭代和高质量的代码编写。 Rails是...

    errawr-rails:使用Errawr在Rails中引发和渲染错误

    Errawr :: Rails 使用Errawr在Rails中引发和渲染错误安装将此行添加到您的应用程序的Gemfile中: gem 'errawr-rails'然后执行: $ bundle或将其自己安装为: $ gem install errawr-rails用法入门要开始在Rails中引发...

Global site tag (gtag.js) - Google Analytics