天天看點

[Ruby筆記]9.Ruby文檔工具 ri ruby-doc Windows CMD.exe Powershell在Windows上安裝ruby-doc ri 工具在Powershell中使用ri指令在Cmd.exe中可直接使用ri指令直接檢視chm格式的工具文檔引用

在Windows上安裝ruby-doc ri 工具

安裝步驟

Ruby的指令行文檔工具

ri

,一般安裝步驟[1]

在終端運作 gem install rdoc-data 安裝
然後需要生成 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産生沖突

ruby

ri

會與

powershell

中的

remove-item

沖突

PS C:\Users\Administrator> ri Array
Remove-Item : 找不到路徑“C:\Users\Administrator\Array”,因為該路徑不存在。
所在位置 行: 字元: 
+ 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#upcase
String#upcase

(from ruby core)
Implementation from (unknown)
------------------------------------------------------------------------------

missing documentation at
C:/Ruby23-x64/share/ri/./system/String/upcase-i.ri
           

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

  • 打開Windows指令行工具

    Cmd.exe

  • 檢視一下

    ruby

    的版本以及

    ri

    的版本
C:\Users\Administrator>ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]

C:\Users\Administrator>ri --version
ri.cmd 4.2.1
           
  • 使用

    ri

    檢視

    String#upcase

    的資訊
C:\Users\Administrator>ri String#upcase
String#upcase

(from ruby core)
Implementation from (unknown)
------------------------------------------------------------------------------

missing documentation at
C:/Ruby23-x64/share/ri/./system/String/upcase-i.ri
           
  • 在指令行直接輸入

    ri

    可以看到引導資訊
C:\Users\Administrator>ri

Enter 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\doc


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         //     :     bookofruby.pdf
-a---         //     :     ruby23-core.chm
-a---         //     :      ruby23-language.chm
-a---         //     :     ruby23-stdlib.chm
-a---         //     :       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