shell_docs (stdlib v3.15.2)
This module can be used to render function and type documentation to be printed in a shell. This is the module that is used to render the docs accessed through the shell through c:h/1,2,3
. Example:
1> h(maps,new,0).
-spec new() -> Map when Map :: #{}.
Since:
OTP 17.0
Returns a new empty map.
Example:
> maps:new().
#{}
This module formats and renders EEP-48 documentation of the format application/erlang+html
. For more information about this format see Documentation Storage in Erl_Docgen's User's Guide. It can also render any other format of "text" type, although those will be rendered as is.
Link to this section Summary
Types
The HTML tags allowed in application/erlang+html
.
The HTML tags allowed in application/erlang+html
.
The HTML tags allowed in application/erlang+html
.
The configuration of how the documentation should be rendered.
The record holding EEP-48 documentation for a module. You can use code:get_doc/1 to fetch this information from a module.
Functions
This function can be used to do whitespace normalization of application/erlang+html
documentation.
Render the documentation for a module or function.
Render the documentation of a callback in a module.
Render the documentation of a type in a module.
This function can be used to find out which tags are supported by application/erlang+html
documentation.
This function can be used to do a basic validation of the doc content of application/erlang+html
format.
Link to this section Types
-type chunk_element() :: term().
Specs
chunk_element() :: {chunk_element_type(), chunk_element_attrs(), chunk_elements()} | binary().
-type chunk_element_attr() :: term().
Specs
chunk_element_attr() :: {atom(), unicode:chardata()}.
-type chunk_element_attrs() :: term().
Specs
chunk_element_attrs() :: [chunk_element_attr()].
-type chunk_element_block_type() :: term().
Specs
chunk_element_block_type() :: p | 'div' | br | pre | ul | ol | li | dl | dt | dd | h1 | h2 | h3 | h4 | h5 | h6.
The HTML tags allowed in application/erlang+html
.
-type chunk_element_inline_type() :: term().
Specs
chunk_element_inline_type() :: a | code | em | strong | i | b.
The HTML tags allowed in application/erlang+html
.
-type chunk_element_type() :: term().
Specs
chunk_element_type() :: chunk_element_inline_type() | chunk_element_block_type().
The HTML tags allowed in application/erlang+html
.
-type chunk_elements() :: term().
Specs
chunk_elements() :: [chunk_element()].
-type config() :: term().
Specs
config() :: #{encoding => unicode | latin1, columns => pos_integer(), ansi => boolean()}.
The configuration of how the documentation should be rendered.
- encoding
- Configure the encoding that should be used by the renderer for graphical details such as bullet-points. By default
shell_docs
uses the value returned byio:getopts()
. - ansi
- Configure whether ansi escape codes should be used to render graphical details such as bold and underscore. By default
shell_docs
will try to determine if the receiving shell supports ansi escape codes. It is possible to override the automated check by setting the kernel configuration parametershell_docs_ansi
to aboolean()
value. - columns
- Configure how wide the target documentation should be rendered. By default
shell_docs
used the value returned byio:columns()
.
-type docs_v1() :: term().
Specs
docs_v1() :: #docs_v1{}.
The record holding EEP-48 documentation for a module. You can use code:get_doc/1 to fetch this information from a module.
Link to this section Functions
Specs
normalize(Docs) -> NormalizedDocs when Docs :: chunk_elements(), NormalizedDocs :: chunk_elements().
This function can be used to do whitespace normalization of application/erlang+html
documentation.
Specs
render(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().
Render the documentation for a module or function.
Specs
render(Module, Docs, Config) -> unicode:chardata() when Module :: module(), Docs :: docs_v1(), Config :: config(); (Module, Function, Docs) -> Res when Module :: module(), Function :: atom(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, function_missing}.
Specs
render(Module, Function, Docs, Config) -> Res when Module :: module(), Function :: atom(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, function_missing}; (Module, Function, Arity, Docs) -> Res when Module :: module(), Function :: atom(), Arity :: arity(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, function_missing}.
Specs
render(Module, Function, Arity, Docs, Config) -> Res when Module :: module(), Function :: atom(), Arity :: arity(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, function_missing}.
Specs
render_callback(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().
Render the documentation of a callback in a module.
Specs
render_callback(Module, Docs, Config) -> unicode:chardata() when Module :: module(), Docs :: docs_v1(), Config :: config(); (Module, Callback, Docs) -> Res when Module :: module(), Callback :: atom(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, callback_missing}.
Specs
render_callback(Module, Callback, Docs, Config) -> Res when Module :: module(), Callback :: atom(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, callback_missing}; (Module, Callback, Arity, Docs) -> Res when Module :: module(), Callback :: atom(), Arity :: arity(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, callback_missing}.
Specs
render_callback(Module, Callback, Arity, Docs, Config) -> Res when Module :: module(), Callback :: atom(), Arity :: arity(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, callback_missing}.
Specs
render_type(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().
Render the documentation of a type in a module.
Specs
render_type(Module, Docs, Config) -> unicode:chardata() when Module :: module(), Docs :: docs_v1(), Config :: config(); (Module, Type, Docs) -> Res when Module :: module(), Type :: atom(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, type_missing}.
Specs
render_type(Module, Type, Docs, Config) -> Res when Module :: module(), Type :: atom(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, type_missing}; (Module, Type, Arity, Docs) -> Res when Module :: module(), Type :: atom(), Arity :: arity(), Docs :: docs_v1(), Res :: unicode:chardata() | {error, type_missing}.
Specs
render_type(Module, Type, Arity, Docs, Config) -> Res when Module :: module(), Type :: atom(), Arity :: arity(), Docs :: docs_v1(), Config :: config(), Res :: unicode:chardata() | {error, type_missing}.
Specs
supported_tags() -> [chunk_element_type()].
This function can be used to find out which tags are supported by application/erlang+html
documentation.
Specs
validate(Module) -> ok when Module :: module() | docs_v1().
This function can be used to do a basic validation of the doc content of application/erlang+html
format.