New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section about function arguments to 'Writing Documentation' #4109

Merged
merged 1 commit into from Dec 23, 2015
Jump to file or symbol
Failed to load files and symbols.
+14 −0
Diff settings

Always

Just for now

@@ -77,6 +77,20 @@ The function above can still be invoked as `MyApp.Sample.add(1, 2)`. Not only th
* Start the function name with underscores, for example, `__add__/2`, and add `@doc false`. The compiler does not import functions with underscore and the underscore will tell users to be wary of using it.
## Function Arguments
When documenting a function, argument names are inferred by the compiler. This can be changed by specifying your preferred argument name. For example:
def size(%HashDict{size: size}) do
size
end
The compiler will infer this argument as `hash_dict`, whereas if you'd prefer it to be, for instance, `dict`, you can write it as so:
def size(%HashDict{size: size} = _dict) do

This comment has been minimized.

@lexmag

lexmag Dec 23, 2015

Member

I think it'd be better to show body-less function clause.

@lexmag

lexmag Dec 23, 2015

Member

I think it'd be better to show body-less function clause.

size
end
## Documentation != Comments
Elixir makes the difference between documentation and code comments. Documentation are for users of your API, be it your co-worker or your future self. Modules and functions must always be documented if they are part of your application public interface (API).
ProTip! Use n and p to navigate between commits in a pull request.