Alexey Nikitin
SPb Fprog meetup
29 October 2018
tank-bohr
tank_bohr
EDoc is the Erlang program documentation generator. Inspired by the Javadoc tool for the Java programming language, EDoc is adapted to the conventions of the Erlang world, and has several features not found in Javadoc.
defmodule CrispyRobot do
@doc """
## Examples
iex> CrispyRobot.sqr(5)
26
"""
def sqr(x) do
x * x
end
end
defmodule CrispyRobotTest do
use ExUnit.Case
doctest CrispyRobot
end
$ mix test
Compiling 1 file (.ex)
1) doctest CrispyRobot.sqr/1 (1) (CrispyRobotTest)
test/crispy_robot_test.exs:3
Doctest failed
code: CrispyRobot.sqr(5) === 26
left: 25
right: 26
stacktrace:
lib/crispy_robot.ex:5: CrispyRobot (module)
Finished in 0.03 seconds
1 doctest, 1 failure
Randomized with seed 50281
Attr - module attributes, in ETF
CInf - compilation info, in ETF
Dbgi - dubug info, in ETF
ExpT - functions exported by module
ImpT - external functions used by module
LocT - local functions
AtU8 - atoms
Line - source code line table
Code - the actual bytecode
beam_lib:chunks(PathToBeam,
["Attr", "CInf", "Dbgi", "ExpT"]).
DocsChunkData = term_to_binary(Docs, [compressed]),
ExtraChunks = [{<<"Docs">>, DocsChunkData}],
compile:file(Src, [{extra_chunks, ExtraChunks}]).