2017-03-26 19 views
0

我在更新iex中的@doc来测试它的外观。我遇到的问题是我必须退出iex才能查看更新的@doc文档。有没有办法在使用r()时重新加载模块@doc变量?r(module_name)不能在iex中重新加载@doc

iex -S mix 
iex> h Coordinate.island/1 
     ## Examples 
     iex> {:ok, coord } = Cordinate.start_link 
     Cordinate.island(coord) 
     :falls_town 

更新@doc返回:none而不是:falls_town并保存文件。

iex> r(Coordinate) 
iex> h Coordinate.island/1 
    # issue: still showing the old @doc example 
    ## Examples 
    iex> {:ok, coord } = Cordinate.start_link 
     Cordinate.island(coord) 
     :falls_town # should be :none 
+2

尝试在'iex -S mix'中运行'recompile()'而不是'r(...)'。 – Dogbert

+0

@Dogbert,工作非常感谢!所以我为了重新加载文档变量,你必须重新编译当前的Mix应用程序。 –

回答

5

h/1 currently loads the documentation from the compiled .beam filesr/1编译文件在内存中,不写.beam文件到磁盘,这意味着h/1当您运行r/1不会重新加载文档:

当我们重新加载在IEx标志的模块,我们重新编译模块源代码, 更新内存中的内容。磁盘中的原始.beam文件, 可能是第一个模块定义的来源, 根本不会改变。

Source

你可以编译打包,并通过运行iexrecompile/0(而不是r/1)程序将最终.beam文件到磁盘。运行后,您应该看到h/1中的新文档。