Skip to content

Instantly share code, notes, and snippets.

@cooldaemon
Created July 25, 2008 09:23
Show Gist options
  • Save cooldaemon/2417 to your computer and use it in GitHub Desktop.
Save cooldaemon/2417 to your computer and use it in GitHub Desktop.
I'm practicing writing the EDoc.
%% @author Masahito Ikuta <cooldaemon@gmail.com> [http://d.hatena.ne.jp/cooldaemon/]
%% @copyright Masahito Ikuta 2008
%%
%% @doc The sample module for the EDoc.
%%
%% I'm practicing writing the EDoc.
%% This file was made because of the practice.
%%
%% Here's a quick example illustrating how to use edoc_test:
%% ```
%% Person = edoc_test:new("cooldaemon", 31, male),
%% edoc_test:say(Person).
%% '''
%%
%% The following is an example of making HTMLs.
%% ```
%% erl -noshell -run edoc_run application edoc_test '"."' '[{def,{vsn, "1.0"}}]'
%% '''
%%
%% The following is an example of using the dialyzer command.
%% ```
%% dialyzer --succ_typings -c edoc_test.erl
%% '''
%% Copyright (c) Masahito Ikuta 2008
%%
%% Permission is hereby granted, free of charge, to any person
%% obtaining a copy of this software and associated documentation
%% files (the "Software"), to deal in the Software without restriction,
%% including without limitation the rights to use, copy, modify, merge,
%% publish, distribute, sublicense, and/or sell copies of the Software,
%% and to permit persons to whom the Software is furnished to do
%% so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included
%% in all copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
%% IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
%% CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
%% TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
%% SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-module(edoc_test).
-author('cooldaemon@gmail.com').
-export([new/0, new/3, say/1, bug/0]).
%% @type person() = {name(), age(), gender()}.
%% A data structure holding the person infomation.
%% @type name() = string() | secret.
%% @type age() = integer() | secret.
%% @type gender() = male | female | secret.
-record(person, {name, age, gender}).
%% @equiv new(secret, secret, secret)
new() -> new(secret, secret, secret).
%% @doc Create a new person.
%% @spec new(Name::name(), Age::age(), Gender::gender()) -> person()
new(Name, Age, Gender) -> #person{name=Name, age=Age, gender=Gender}.
%% @doc The person speaks the wish.
%% The person was made by {@link edoc_test:new/3}.
%% @spec say(Person::person()) -> ok
say(Person) ->
io:fwrite("\"EDoc is easy.\" said ~s.~n", [get_name(Person)]),
ok.
% The following is not included in EDoc.
%% @doc Get the name of person.
%% @spec get_name(Person::person()) -> name()
get_name(Person) -> Person#person.name.
%% @doc Cause offense to the dialyzer command.
%% @spec bug() -> name()
bug() -> get_name(error_data).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment