情報は力ではない

UE4 とか Blender とか。

vim-ocaml-stdlib-helpを作った。

最近、OCamlを勉強していて、VimOCamlを書いてます。その時に標準ライブラリの機能を調べたいなと思うのだけれど、いちいちブラウザで調べるのも面倒なのでVim pluginを作りました。

github.com

使い方は

:OCamlStdLibHelp {module-name}

という感じです。例えば

:OCamlStdLibHelp Array

とすれば

module Array: sig .. end
Array operations.
val length : 'a array -> int
Return the length (number of elements) of the given array.
val get : 'a array -> int -> 'a
Array.get a n returns the element number n of array a.
   The first element has number 0.
   The last element has number Array.length a - 1.
   You can also write a.(n) instead of Array.get a n.


   Raise Invalid_argument "index out of bounds"
   if n is outside the range 0 to (Array.length a - 1).
val set : 'a array -> int -> 'a -> unit
Array.set a n x modifies array a in place, replacing
   element number n with x.
   You can also write a.(n) <- x instead of Array.set a n x.


   Raise Invalid_argument "index out of bounds"
   if n is outside the range 0 to Array.length a - 1.

といった感じで出力されます。割と雑に作ってるので、まだ読みづらいです。

この標準ライブラリのドキュメントは The standard library から引っ張ってきています。

このサイトのHTMLは<p>タグが閉じられていないのでYQLを使ってタグが閉じられたHTMLを取得しています。

YQL - Yahoo Developer Network

あとはVital.Web.HTTPとVital.Web.XMLを用いてスクレイピングをしている感じです。

github.com

これらの方法はmattnさんのブログを見て作成をしました。

mattn.kaoriya.net

今後

まだ出力結果が見づらいので、そこを変更したい。また、コマンド実行時にVimをブロックしてしまうので非同期処理にしたいなと考えています。