4
votes
Erlang Source file generation from .beam file
Have you tried using recon:source/1?
I think it does exactly what you need.
If you don't want to use it, at least you can get inspiration from its source code:
-spec source(module()) -> iolist().
...
Only top scored, non community-wiki answers of a minimum length are eligible