What is the module name compiled in Livebook?

I am not sure why it complains module not found if I try this in Livebook.

defmodule MyModule do
  @moduledoc """
    This is an code-on-chain example:
      Shows how to get the current block height on diff chain.

  @author "Ken Chen"

  @doc """
  Get module doc
  def get_module_doc, do: @moduledoc

{:docs_v1, _, _, _, %{"en" => module_doc}, _meta, doc_elements} = Code.fetch_docs(MyModule)

Livebook does not persist modules to disk at the moment. Documentation can only be written for modules written in disk.


I see. By the way, if I would like to get the AST of one module, is it a must to read the module from a file and then use Code.sting_to_quoted? Is there a way to directly convert from the module in run time?

Elixir transpiles to Erlang, so for already compiled modules you can only hope that the module was compiled with debug_info and then you can fetch the abstract_code using beam lib.

But I wouldn’t actually rely on anything like this. The best thing you can do during development is just to find the sources by yourself

1 Like

I see, thanks very much.