我知道文档解释了这些工具,但我不理解这些解释。有人能举一两个例子吗?
发布于 2011-08-02 12:56:54
对于erl_tidy,最简单也是最直接的方法是直接从Eshell中使用它
$ erl
1> m(erl_tidy).
% output snipped
2> erl_tidy:dir(). % recursively tidy the present directory and its children
% output snipped
3> erl_tidy:dir("", [{recursive, false}]). % just the present directory
reading module `./bad.erl'.
made backup of file `./bad.erl'.
writing to file `./bad.erl'.
4>在这种情况下,bad.erl从
-module(bad).
-compile(export_all).
bad(0)->1;bad(1)->2;bad(N)->3.bad()->0.给整洁的人
-module(bad).
-compile(export_all).
bad ( 0 ) -> 1 ; bad ( 1 ) -> 2 ; bad ( N ) -> 3 . bad ( ) -> 0 ...。好吧,它不是魔术师:-)
也可以通过erl的参数调用erl_tidy,如下所示
$ # unix prompt
$ erl -s erl_tidy dir
tidying directory `./wesnoth'.
tidying directory `./wesnoth/Vix'.
tidying directory `./wesnoth/Vix/utils'.
...然而,erl_lint则完全不同。要了解如何使用它,首先要了解this string evaluation example中发生了什么。erl_lint被设计成作用于Erlang源代码的中间表示,而不是它的字符串。
https://stackoverflow.com/questions/6903903
复制相似问题