3.7 KiB
3.7 KiB
Hints
General
- Read the official documentation for typespecs.
- Read the official documentation about writing documentation.
- Read about using module attributes as annotations in the official Getting Started guide.
- Read about using typespecs in the official Getting Started guide.
1. Document the purpose of the form tools
- The module attribute
@moduledoc
can be used to write documentation for a module.
2. Document filling out fields with blank values
- The module attribute
@doc
can be used to write documentation for a function. - The module attribute
@spec
can be used to write a typespec for a function. - Place the
@doc
and@spec
attributes right before the first function clause of the function that those attributes describe. - Refer to the typespecs documentation for a list of all available types.
- The correct type for strings is defined in the
String
module.
3. Document splitting values into lists of uppercase letters
- The module attribute
@doc
can be used to write documentation for a function. - The module attribute
@spec
can be used to write a typespec for a function. - Place the
@doc
and@spec
attributes right before the first function clause of the function that those attributes describe. - Refer to the typespecs documentation for a list of all available types.
- The correct type for strings is defined in the
String
module. - A list is a parametrized type.
4. Document checking if a value fits a field with a max length
- The module attribute
@doc
can be used to write documentation for a function. - The module attribute
@spec
can be used to write a typespec for a function. - Place the
@doc
and@spec
attributes right before the first function clause of the function that those attributes describe. - Refer to the typespecs documentation for a list of all available types.
- The correct type for strings is defined in the
String
module. - Literal values can be used in a typespec.
- The pipe
|
can be used to represent a union of types.
5. Document different address formats
- The module attribute
@type
can be use to define a custom public type. - Types can be compound, e.g. when specifying a type that's a map, you can also specify the types of the values under the specific keys.
- The type operator
::
can also be used to prepend a variable name to a type. - Custom types can be used to define other custom types.
6. Document formatting the address
- The module attribute
@doc
can be used to write documentation for a function. - The module attribute
@spec
can be used to write a typespec for a function. - Place the
@doc
and@spec
attributes right before the first function clause of the function that those attributes describe. - Refer to the typespecs documentation for a list of all available types.
- The correct type for strings is defined in the
String
module. - Custom types can be used in a typespec.