erlang edoc 使用教程

来源:互联网 发布:淘宝购物券在哪里设置 编辑:程序博客网 时间:2024/05/21 20:05

edoc使用文档  org文档

生成的默认方法为

application(Application::atom()) -> okEquivalent to application(Application, []).application(Application::atom(), Options::proplist()) -> okapplication(Application::atom(), Dir::filename(), Options::proplist()) -> ok

假如你的工程目录是按照otp标准建立的,直接运行 eodc:application(your_project_name)

如果运行 application/1 出错有两种可能

1:工程中写的注释不符合edoc规范

       edoc 规范 链接 edoc规范

       比较需要注意的有

       (1)函数名必须与 @doc 后面的函数名一致

       (2)函数的参数以及返回类型必须是以下类型中的一种                             

    any()    arity()    atom()    binary()    bitstring()    bool()        (allowed, but use boolean() instead)    boolean()    byte()    char()    cons()    deep_string()    float()    function()    integer()    iodata()    iolist()    list()    maybe_improper_list()    mfa()    module()    nil()    neg_integer()    node()    non_neg_integer()    nonempty_improper_list()    nonempty_list()    nonempty_maybe_improper_list()    nonempty_string()    none()    number()    pid()    port()    pos_integer()    reference()    string()    term()    timeout()    tuple()

2:工程目录不是otp标准目录

     需要用 application/3 指定目录

     Dir = "../src"  %%是从erl -s 启动目录开始查找,可以是任意一个文件夹

     edoc:application(your_project_name, Dir, [])


生成以后可能发现中文注释有乱码

引用 langzhe 的解决方案 彻底解决erlang edoc中文乱码问题

补充

1:erlang  edoc的源文件默认在 C:\Program Files\erl5.10.3\lib 文件夹下

2:otp 16B edoc源代码 有变

    edoc_layout.erl 直接附带了 content 头

    直接替换编码就行。

xhtml(Title, CSS, Body) ->    xhtml(Title, CSS, Body, "latin1").xhtml(Title, CSS, Body, _Encoding) ->    [{html, [?NL,     {head, [?NL,     {meta, [{'http-equiv',"Content-Type"},     {content, "text/html; charset= UTF-8"}],      []},     ?NL,     {title, Title},     ?NL] ++ CSS},     ?NL,     {body, [{bgcolor, "white"}], Body},     ?NL]     },     ?NL].


搞定收工 -,- edoc生成出来还蛮清晰的,就是对于写注释的要求太高了    





原创粉丝点击