Given the following code:
defmodule MathOps do
@moduledoc """
This module provides math operations
"""
@doc """
This function returns the sum of input
"""
@spec add(integer, integer) :: map
def add(a, b) do
%{"result" => Integer.to_string(a + b)}
end
end
I’d like to load the file and turn it into a json spec like so:
{
"module": "MathOps",
"doc": "This module provides math operations",
"defs": [
{
"name": "add",
"doc": "This function returns the sum of input",
"params": [
{"name": "a", "type": "integer", "default": null},
{"name": "b", "type": "integer", "default": null}
],
"return_type": "map"
}
]
}
Any ideas/guidance would be greatly appreciated