0

I am updating my @doc while in iex> to test how it looks. The problem I am coming up against is that I have to exit iex to view the updated @doc documentation. Is there a way to reload the modules @doc variables when using r()?

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

Updated @doc to return :none instead of :falls_town and save file.

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 
David Gross
  • 1,863
  • 10
  • 14

1 Answers1

5

h/1 currently loads the documentation from the compiled .beam files. r/1 compiles the files in memory and does not write the .beam files to disk, which means that h/1 does not reload the docs when you run r/1:

When we reload the module in IEx, we recompile the module source code, updating its contents in memory. The original .beam file in disk, probably the one where the first definition of the module came from, does not change at all.

Source

You can compile the package and write the resulting .beam files to disk by running recompile/0 in iex (instead of r/1). After running that, you should see the new documentation in h/1.

Community
  • 1
  • 1
Dogbert
  • 212,659
  • 41
  • 396
  • 397