Skip to content

Instantly share code, notes, and snippets.

@asonge
Created July 13, 2017 15:21
Show Gist options
  • Save asonge/3fe2b0ad3ab3641a1fa1d360f60e65d6 to your computer and use it in GitHub Desktop.
Save asonge/3fe2b0ad3ab3641a1fa1d360f60e65d6 to your computer and use it in GitHub Desktop.
Make you hrl
{:ok, trees} = :code.lib_dir(:public_key)
|> Path.join("include/OTP-PUB-KEY.hrl")
|> :epp_dodger.parse_file()
constants = trees
|> Enum.map(&:erl_syntax_lib.strip_comments/1)
|> Enum.reject(&match?({:record, _},:erl_syntax_lib.analyze_attribute(&1)))
|> Enum.map(fn {:tree, :attribute, {:attr, _, _, :none}, {:attribute, {:atom, _, :define}, [{:atom,_,_}=a,b]}} ->
{:erl_syntax.concrete(a), :erl_syntax.concrete(b)};
_ -> nil
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment