Code.get_docs returning nil - beam file does not exist

Hello all. I’d appreciate some input on this.

To explain consider these two modules ModuleA and ModuleB

defmodule ModuleA do 
  @doc "ModuleA fun1"
   def fun1(x) do
      x
   end
end

defmodule ModuleB do
  require ModuleA
  :functions |> ModuleA.__info__ |> IO.inspect
  ModuleA |> Code.get_docs(:all) |> IO.inspect
end

If both modules are being compiled together, the get_docs in ModuleB returns nil. Only if ModuleA has been compiled previously does the get_docs in ModuleB succeed.

The crux of my question is how do I wait during the compilation of ModuleB for the beam file for ModuleA to exist?

Thanks in advance.

btw I’m using 1.6.3