edoc(3)
π NAME π
edoc β bestie, it's EDoc, the Erlang program documentation generator. That's the whole vibe. πβ¨
β¨ DESCRIPTION β¨
okay so this module is like. the main character of the whole EDoc situation β it's the front door, the user interface you actually talk to. Everything else is backstage. π
If you wanna go deeper, the lore lives here:
- π EDoc User Manual
- π Running EDoc
π¦ DATA TYPES π¦
edoc_module()::xmerl_scan:xmlElement().
This is the EDoc documentation data for one module, and it's expressed as an XML document in XMerL format, bestie. If you want the juicy details on what that actually looks like, go check edoc.dtd. π
entry()::
#entry{name :: function_name() | atom(),
args :: [atom() | list()],
line :: integer(),
export :: boolean(),
data :: entry_data()}.
These are the Module Entries β you get one per function, plus the module header and the module footer. Like little trading cards for each function. π
env()::#env{}.
The environment info EDoc needs so it can generate references and not wildly point at nothing. π§
module_meta()::
#module{name :: [] | atom(),
parameters :: none | [atom()],
functions :: ordset(function_name()),
exports :: ordset(function_name()),
attributes :: ordset({atom(), term()}),
records :: [{atom(), [{atom(), term()}]}],
encoding :: epp:source_encoding(),
file :: file:filename()}.
Module information. The receipts, basically. π§Ύ
tag()::
#tag{name :: atom(),
line :: integer(),
origin :: comment | code,
data :: term(),
form :: undefined | erl_parse:abstract_form()}.
Generic tag information. Heads up though β #tag.form only actually has a value if #tag.origin is code. Like, if the #tag{} represents a real code fragment and not a doc comment tag. Don't get it twisted. π
π₯ FUNCTIONS π₯
πΈ application(atom()) -> ok.
Literally just the same as application(Application, []). Nothing else going on here. π
πΈ application(App, Options) -> ok when App :: atom(), Options :: proplist().
Runs EDoc on an application that lives in its default app-directory. That's it, that's the whole job. If you want the full story, go read application/3. π
See also: application/1.
πΈ application(App, Dir, Options) -> ok when App :: atom(), Dir :: filename(), Options :: proplist().
Runs EDoc on an application that's hanging out in the directory you specify. It tries to set up good defaults for you automatically (so thoughtful, honestly π). And unless you say otherwise:
- π― The
docsubdirectory gets used as the target directory β but only if it exists. If it doesn't, the application directory itself gets used instead. - π The source code is assumed to live in the
srcsubdirectory, again only if it exists β otherwise it's assumed to be right there in the application directory itself. - π The
subpackagesoption gets turned on. Every source file it finds will be processed. All of them. No survivors. - π§΅ The
includesubdirectory gets automatically added to the include path. (This only matters if preprocessing is turned on, so don't stress.)
For the full deets β options included β go see run/2.
See also: application/2.
πΈ file(filename()) -> ok.
β οΈ Deprecated! Check file/2 for the details, bestie.
Equivalent to file(Name, []). π
πΈ file(Name, Options) -> ok when Name :: filename(), Options :: proplist().
β οΈ Deprecated, fr fr! This is part of the old interface to EDoc and it's mainly being kept around for backwards compatibility. The preferred way to generate docs is throughapplication/2orfiles/2. Use those. Please. π
What it does: reads a source code file and outputs formatted documentation to a corresponding file. Classic.
Options:
{dir, filename()}β tells it where the created file should go. (By default, the output gets written to the same directory as the source file. Cozy.){source_suffix, string()}β the suffix you expect the input file to have. The default is".erl".{file_suffix, string()}β the suffix for the file it creates. The default is".html".
For even more options, go peep get_doc/2 and layout/2.
If you're running EDoc from a Makefile or something similar, check out edoc_run:file/1. π οΈ
See also: read/2.
πΈ files(Files, Options) -> ok when Files :: [filename()], Options :: proplist().
This is the same as run(Files, Options). It runs EDoc over a given set of source files. Full deets, options and all, live in run/2. π
πΈ get_doc(filename()) -> {module(), edoc_module()}.
Same energy as get_doc(File, []). β¨
πΈ get_doc(File, Options) -> R when File :: filename(), Options :: proplist(), R :: {module(), edoc_module()} | {module(), edoc_module(), [entry()]}.
Reads a source code file and pulls out the EDoc documentation data. π§²
β οΈ Heads up: if you don't pass an environment parameter (that's get_doc/3, bestie), your hypertext links might come out wrong. Not wrong-wrong, but like. Not correct. Just so you know. π¬
Options:
{def, Macros}Macros = Macro | [Macro]Macro = {Name::atom(), Text::string() | MacroFun}MacroFun = fun((MacroArgument::string(), Line :: integer(), edoc_lib:edoc_env()) -> (Text::string()))
This one lets you specify a set of user-defined EDoc macros. The text that gets substituted for macro calls is given as either a string() or a function(). If you go the function route, it gets called with the macro argument text, the current line number, and the current environment β and the fun is supposed to return a string(). See Macro expansion for the whole story. πͺ
{hidden, boolean()}β if it'strue, documentation for hidden functions gets included too. Default isfalse.{private, boolean()}β if it'strue, documentation for private functions gets included too. Default isfalse.{todo, boolean()}β if it'strue, To-Do notes written with@todoor@TODOtags get included in the documentation. Default isfalse.
For further options, see read_source/2, read_comments/2 and edoc_lib:get_doc_env/3.
See also:get_doc/3,layout/2,read/2,run/2,edoc_extract:source/5.
πΈ get_doc(File, Env, Options) -> R when File :: filename(), Env :: env(), Options :: proplist(), R :: {module(), edoc_module()} | {module(), edoc_module(), [entry()]}.
Exactly like get_doc/2, but now you're handing it a specific environment parameter. π«Ά And Env here is an environment that was created by edoc_lib:get_doc_env/3. That's the one you want.
πΈ layout(edoc_module()) -> string().
Just layout(Doc, []). Same thing, fewer keystrokes. β¨οΈ
πΈ layout(Doc, Opts) -> term() when Doc :: edoc_module(), Opts :: proplist().
This one transforms EDoc module documentation data into text. And the default layout? It makes an HTML document. Of course it does. π
Options:
{layout, Module::atom()}β names a callback module to be used for formatting. That module has to export a function calledmodule(Doc, Options). The default callback module isedoc_layout, and if you want layout-specific options you should go readedoc_layout:module/2. π¨
See also:file/2,layout/1,read/2,run/2.
πΈ read(filename()) -> string().
You guessed it β read(File, []). π
πΈ read(File, Opts) -> string() when File :: filename(), Opts :: proplist().
Reads and processes a source file, then hands you back the resulting EDoc-text as a string. Options live in get_doc/2 and layout/2. π
See also: file/2.
πΈ read_comments(filename()) -> [comment()].
Yep, read_comments(File, []). πΈ
πΈ read_comments(File, Opts) -> [comment()] when File :: filename(), Opts :: proplist().
Pulls the comments out of an Erlang source code file. π§Ί If you want the deets on how comments are actually represented, go check the //syntax_tools/erl_comment_scan module. And rn? No options are available. Zero. None. That's the whole menu. π
πΈ read_source(filename()) -> [syntaxTree()].
Again β read_source(File, []). β¨
πΈ read_source(File, Opts) -> [syntaxTree()] when File :: filename(), Opts :: proplist().
Reads an Erlang source file and gives you back the list of "source code form" syntax trees. π³
Options:
{preprocess, boolean()}
If it's true, the source file gets read through the Erlang preprocessor (epp). Default is false. Also, no_preprocess is an alias for {preprocess, false}. πͺ
Normally you don't need preprocessing for EDoc to work β but if a file has definitions or uses of macros that are just. Too exotic. Then it will be impossible to read it without preprocessing. π
β οΈ Note: comments in included files will not be available to EDoc, even with this option turned on. Sorry bestie, that's just how it is.
{includes, Path::[string()]}β a list of directory names to search for include files, used when thepreprocessoption is turned on. It also gets used with the@headerfiletag. The default value is the empty list, and the directory of the source file is always automatically appended to the search path. No takebacks. π{macros, [{atom(), term()}]}β a list of pre-defined Erlang preprocessor (epp) macro definitions, used if thepreprocessoption is on. Default is the empty list. π§¬{report_missing_types, boolean()}β if it'strue, warnings get issued for missing types. Default isfalse. Andno_report_missing_typesis an alias for{report_missing_types, false}. π’{link_predefined_types, boolean()}β if it'strue, all predefined data types get a link to theerlangmodule. This one is meant to be used when generating documentation for the Erlang/OTP docs. Default isfalse. Andno_link_predefined_typesis an alias for{link_predefined_types, false}. π
See also: //syntax_tools/erl_syntax, get_doc/2. π¦
run(Files, Opts) -> ok
run(Files, Opts) -> ok
when Files :: [filename()], Opts :: proplist().
Runs EDoc on a given set of source files. Note that the doclet plugin module has its own particular options; see the doclet option below. π
Also see layout/2 for layout-related options, and get_doc/2 for options related to reading source files. π
Options
{app_default, string()}β Specifies the default base URI for unknown applications. π{application, App::atom()}β Specifies that the generated documentation describes the applicationApp. This mainly affects generated references. π{dir, filename()}β Specifies the target directory for the generated documentation. π{doc_path, [string()]}β Specifies a list of file system paths pointing to directories that contain EDoc-generated documentation. All paths for applications in the code path are automatically added. β¨{doclet, Module::atom()}β Specifies a callback module to be used for creating the documentation. The module must export a functionrun(Cmd, Ctxt). The default doclet module isedoc_doclet; seeedoc_doclet:run/2for doclet-specific options. π§{file_suffix, string()}β Specifies the suffix used for output files. The default value is".html". Note that this also affects generated references. π{new, boolean()}β If the value istrue, any existingedoc-infofile in the target directory will be ignored and overwritten. The default value isfalse. π{source_path, [filename()]}β Specifies a list of file system paths used to locate the source code for packages. π{source_suffix, string()}β Specifies the expected suffix of input files. The default value is".erl". πΈ{subpackages, boolean()}β If the value istrue, all subpackages of specified packages will also be included in the documentation. The default value isfalse.no_subpackagesis an alias for{subpackages, false}. Subpackage source files are found by recursively searching for source code files in subdirectories of the known source code root directories. (Also see thesource_pathoption.) Directory names must begin with a lowercase letter and contain only alphanumeric characters and underscore, or they will be ignored. (For example, a subdirectory namedtest-fileswill not be searched.) π
See also: application/2, files/2. π«Ά
And that's the whole run/2 situation, bestie. Shoutout to Ericsson AB for edoc 1.5 and the edoc(3) date hanging out in the footerβno cap, iconic. πβ¨
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms