[Ruby笔记]9.Ruby文档工具 ri ruby-doc Windows CMD.exe Powershell

来源:互联网 发布:2017淘宝双十一攻略 编辑:程序博客网 时间:2024/06/05 06:46

在Windows上安装ruby-doc ri 工具

安装步骤

Ruby的命令行文档工具ri ,一般安装步骤[1]

1.在终端运行 gem install rdoc-data 安装2.然后需要生成 ri 数据,在终端运行     rdoc-data –install     gem rdoc –all –overwrite      gem rdoc --all --ri --no-rdoc

可能会遭遇的问题:

An existing connection was forcibly closed by the remote host.
[你的连接已经被远程主机强制关闭]

解决办法:

挂VPN或者修改镜像[2]

Ruby China 官方 RubyGems 镜像、Ruby 镜像 正式上线!gem source -a https://gems.ruby-china.org

在Powershell中使用ri命令

遭遇问题:与remove-item产生冲突

rubyri 会与powershell中的remove-item冲突

PS C:\Users\Administrator> ri ArrayRemove-Item : 找不到路径“C:\Users\Administrator\Array”,因为该路径不存在。所在位置 行:1 字符: 3+ ri <<<<  Array    + CategoryInfo          : ObjectNotFound: (C:\Users\Administrator\Array:String) [Remove-Item], ItemNotFoundExcepti   on    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

解决办法:使用ri.cmd命令

也就是不用ri,使用ri.cmd命令[3]

PS C:\Users\Administrator> ri.cmd String#upcaseString#upcase(from ruby core)Implementation from (unknown)------------------------------------------------------------------------------missing documentation atC:/Ruby23-x64/share/ri/2.3.0/system/String/upcase-i.ri

在Cmd.exe中可直接使用ri命令

  • 打开Windows命令行工具Cmd.exe
  • 查看一下ruby的版本以及ri的版本
C:\Users\Administrator>ruby --versionruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]C:\Users\Administrator>ri --versionri.cmd 4.2.1
  • 使用ri查看String#upcase的信息
C:\Users\Administrator>ri String#upcaseString#upcase(from ruby core)Implementation from (unknown)------------------------------------------------------------------------------missing documentation atC:/Ruby23-x64/share/ri/2.3.0/system/String/upcase-i.ri
  • 在命令行直接输入ri可以看到引导信息
C:\Users\Administrator>riEnter the method name you want to look up.You can use tab to autocomplete.Enter a blank line to exit.>>

直接查看chm格式的工具文档

PS C:\Ruby23-x64\doc> ls    目录: C:\Ruby23-x64\docMode                LastWriteTime     Length Name----                -------------     ------ -----a---         2009/4/18     12:35    3072340 bookofruby.pdf-a---         2016/3/13     22:02    1107558 ruby23-core.chm-a---         2016/3/13     22:03     367466 ruby23-language.chm-a---         2016/3/13     22:03    3588376 ruby23-stdlib.chm-a---         2016/3/13     22:03      33484 ruby23.chm

引用

[1]http://shashanzhao.com/archives/866.html
[2]http://ruby-china.org/
[3]http://stuff.martinsgill.co.uk/powershell-which/

元気だして~  ∧_∧ (*´ω`)∧∧l|l  /⌒,つ⌒ヽ ) (  (  _)'`'`""'`'`""'`'`""http://emoji.vis.ne.jp/genki_dashite.htm
0 0
原创粉丝点击