Added edoc comments.

This commit is contained in:
Juan Jose Comellas 2009-10-05 17:09:04 -03:00
parent 35395b82e8
commit cc6bf5810a

View File

@ -2,24 +2,31 @@
%%% @author Juan Jose Comellas <jcomellas@novamens.com> %%% @author Juan Jose Comellas <jcomellas@novamens.com>
%%% @copyright (C) 2009, Novamens SA (http://www.novamens.com) %%% @copyright (C) 2009, Novamens SA (http://www.novamens.com)
%%% @doc Parses command line options with a format similar to that of GNU getopt. %%% @doc Parses command line options with a format similar to that of GNU getopt.
%%% @end
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(getopt). -module(getopt).
%% @headerfile getopt.hrl
-include("getopt.hrl"). -include("getopt.hrl").
-define(TAB_LENGTH, 8). -define(TAB_LENGTH, 8).
-define(HELP_INDENTATION, 4 * ?TAB_LENGTH). -define(HELP_INDENTATION, 4 * ?TAB_LENGTH).
-type option() :: atom() | {atom(), any()}. %% @type option() = atom() | {atom(), getopt_arg()}. Option type and optional default argument.
-type option() :: atom() | {atom(), getopt_arg()}.
%% @type option_spec() = [#option{}]. Command line options specification.
-type option_spec() :: [#option{}]. -type option_spec() :: [#option{}].
%% @type option_list() = [option()]. List of option types.
-type option_list() :: [option()]. -type option_list() :: [option()].
-type arg_list() :: [atom() | binary() | boolean() | float() | integer() | string()]. %% @type arg_list() = [getopt_arg()]. List of arguments returned to the calling function.
-type arg_list() :: [getopt_arg()].
-export([parse/2, usage/2]). -export([parse/2, usage/2]).
-spec parse(option_spec(), [string()]) -> option_list(). -spec parse(option_spec(), [string()]) -> option_list().
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @spec parse(OptSpec::option_spec(), Args::[string()]) -> option_list().
%% @doc Parse the command line options and arguments returning a list of tuples %% @doc Parse the command line options and arguments returning a list of tuples
%% and/or atoms using the Erlang convention for sending options to a %% and/or atoms using the Erlang convention for sending options to a
%% function. %% function.
@ -157,6 +164,7 @@ to_type(_Type, Arg) ->
-spec usage(option_spec(), string()) -> ok. -spec usage(option_spec(), string()) -> ok.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @spec usage(OptSpec :: option_spec(), ProgramName :: string()) -> ok.
%% @doc Show a message on stdout indicating the command line options and %% @doc Show a message on stdout indicating the command line options and
%% arguments that are supported by the program. %% arguments that are supported by the program.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------