diff --git a/applications/yapp/src/yapp.erl b/applications/yapp/src/yapp.erl
index c2c2385a2..910b549bb 100644
--- a/applications/yapp/src/yapp.erl
+++ b/applications/yapp/src/yapp.erl
@@ -48,26 +48,23 @@
%%%
Note2: The current available registry implementation uses Mnesia so you need
%%% to create a mnesia schema (if not already done) for the node(s) you are running Yaws on.
%%% mnesia:create_schema([node()]).
-%%%
-%%% @type yawsArg() = term(). This is the #arg record as defined
-%%% by yaws_api.hrl.
-%%%
-%%% @type yawsSconf() = term(). This is the #sconf record as defined
-%%% by yaws.hrl.
-%%%
-%%% @type yawsGconf() = term(). This is the #gconf record as defined
-%%% by yaws.hrl.
-module(yapp).
-author('mikael@creado.se').
--include("yaws_api.hrl").
-export([arg_rewrite/1, start/0, prepath/1, insert/1, insert/2, remove/2,
log/3,
reset_yaws_conf/0, srv_id/1,
get_bootstrap_yapps/0, get_yapps/0, get_server_ids/0]).
%% reload_yaws/0,
+-include("yaws_api.hrl").
+-include("yaws.hrl").
+
+-type yawsArg() :: #arg{}. %% The #arg record as defined by yaws_api.hrl.
+-type yawsSconf() :: #sconf{}. %% The #sconf record as defined by yaws.hrl.
+-type yawsGconf() :: #gconf{}. %% The #gconf record as defined by yaws.hrl.
+
-define(prepath, yapp_prepath).
-define(srv_id, "yapp_server_id").
-define(bootstrap_yapps, "bootstrap_yapps"). %% Opaque key for "bootstrap yapps"
@@ -90,7 +87,7 @@
%% yapps is a list of {UrlPath, AppName} tuples
%% UrlPath = string()
%% Interface arg_rewrite_mod
-%% @spec arg_rewrite(Arg::yawsArg()) -> yawsArg()
+-spec arg_rewrite(Arg :: yawsArg()) -> yawsArg().
%% @doc Interface function for a Yaws arg_rewrite_mod. If
%% it finds a registered Yapp it will strip of the
%% path up to the Yapp and redirect the docroot.
@@ -138,7 +135,7 @@ arg_rewrite(Arg) ->
%% Interface run_mod
-%% @spec start() -> void()
+-spec start() -> ok | {error, Reason :: term()}.
%% @doc Interface function for Yaws run_mod.
%% This fun is spawned from Yaws so no return val is expected.
%% All Yapps can expect mnesia to be started, so mnesia is ensured
@@ -172,7 +169,7 @@ wait_for_yaws(N) ->
end.
-%% @spec prepath(Arg::yawsArg()) -> Path::string()
+-spec prepath(Arg :: yawsArg()) -> Path :: string().
%% @doc Get the Yapp root-path. Can be called from a Yapp erl/1
%% fun or an erl section in a .yaws file to get the Yapp root
%% path.
@@ -180,9 +177,9 @@ prepath(Arg) ->
Arg#arg.docroot_mount.
-%% @spec log(Level, FormatStr::string(), Args) -> void()
-%% Level = error | warning | info | debug
-%% Args = [term()]
+-spec log(Level, FormatStr :: string(), Args :: [term()]) -> ok
+ when
+ Level :: error | warning | info | debug.
%% @doc Yapp interface to the error_logger.
log(debug, FormatStr, Args) ->
gen_event:notify(error_logger, {debug_msg, group_leader(), {self(), FormatStr, Args}});
@@ -364,23 +361,22 @@ reset_yaws_conf() ->
Err
end.
-%% @spec get_conf() -> {ok,yawsGconf(), Sconfs}
-%% Sconfs = [ yawsSconf() ]
+-spec get_conf() -> {ok, yawsGconf(), Sconfs :: [yawsSconf()]}.
get_conf() ->
yaws_api:getconf().
% yaws_config:load(yaws_sup:get_app_args()).
-%% @spec srv_id(Sconf) -> string() | undefined
-%% Sconf = yawsSconf()
+-spec srv_id(Sconf :: yawsSconf()) -> string() | undefined.
%% @doc Get the server id from an Sconf if available
srv_id(SC) ->
OP = yaws:sconf_opaque(SC),
proplists:get_value(?srv_id, OP).
-%% @spec get_bootstrap_yapps() -> [{ ServerId, [ {Path, ApplicationName}]}]
-%% ServerId = string()
-%% Path = string()
-%% Applicationame = atom()
+-spec get_bootstrap_yapps() -> [{ServerId, [{Path, ApplicationName}]}]
+ when
+ ServerId :: string(),
+ Path :: string(),
+ ApplicationName :: atom().
%% @doc Gets the Yapps defined in each opaque
%% "bootstrap_yapps = appname1, appname2" for every server id. (If available).
%% Bootstrap yapps will get the same pathname as their application name
@@ -410,11 +406,13 @@ make_yapp_tuple(A) ->
B = string:strip(A),
{"/" ++ B, list_to_atom(B)}.
-%% @spec get_yapps() -> [{ServId,[{yapp, Urlpath, Docroot, Appname , Appmods}]}]
-%% Urlpath = string()
-%% Docroot = string()
-%% Appname = atom()
-%% Appmods = [atom()]
+-spec get_yapps() -> [{ServerId,[{yapp, Urlpath, Docroot, Appname , Appmods}]}]
+ when
+ ServerId :: string(),
+ Urlpath :: string(),
+ Docroot :: string(),
+ Appname :: atom(),
+ Appmods :: [atom()].
%% @doc Gets all Yapps that are configured for the Yaws server.
get_yapps() ->
{ok, _Gconf, Sconfs} = yaws_api:getconf(),
@@ -425,7 +423,7 @@ get_yapps() ->
end || SC <- lists:flatten(Sconfs)],
[{S,Y} || {S,Y} <- Yapps1, Y =/= undefined, S =/= undefined].
-%% @spec get_server_ids() -> [string()]
+-spec get_server_ids() -> [ServerId :: string()].
%% @doc Lists all server ids.
get_server_ids() ->
{ok, _Gconf, Sconfs} = get_conf(),
diff --git a/applications/yapp/src/yapp_handler.erl b/applications/yapp/src/yapp_handler.erl
index 3007a2721..47cfec78a 100644
--- a/applications/yapp/src/yapp_handler.erl
+++ b/applications/yapp/src/yapp_handler.erl
@@ -34,23 +34,21 @@
%% API
-export([list/2, add/3, add/4, remove/3, init_yapps/1]).
-%% @spec list(YappServer::pid(), SrvId) -> Yapps | exit()
-%% SrvID = string() | all
-%% Yapps = {URL, AppName} | undefined
-%% URL= string()
-%% AppName = atom()
+-spec list(YappServer :: pid(), YawsServerId :: string() | all) ->
+ Yapps :: {URL :: string(), AppName :: atom()} | undefined.
%% @doc Lists all registered Yapps.
list(YappServer, YawsServerId) ->
gen_server:call(YappServer,{?MODULE, list, YawsServerId}).
-%% @spec add(YappServer::pid(), SrvId::string(), YappUrl::string(), AppName::atom()) -> ok | exit()
+-spec add(YappServer :: pid(), SrvId :: string(),
+ YappUrl :: string(), AppName :: atom()) -> ok.
%% @doc Add a Yapp. Adds in the virtual server with the opaque property
%% yapp_server_id = SrvID. The YappUrl is the root path to the Yapp and the AppName is
%% the Name of the application.
add(YappServer, SrvId, YappUrl, AppName) ->
gen_server:call(YappServer,{?MODULE, add, {SrvId, YappUrl, AppName}}).
-%% @spec add(YappServer::pid(), SrvId::string(), AppName::atom()) -> ok | exit()
+-spec add(YappServer :: pid(), SrvId :: string(), AppName :: atom()) -> ok.
%% @doc Add a Yapp. Adds in the virtual server with the opaque property
%% yapp_server_id = SrvID. The root URL will become "/" ++ atom_to_list(AppName)
%% the Name of the application.
@@ -58,8 +56,8 @@ add(YappServer, SrvId, AppName) ->
add(YappServer, SrvId, "/" ++ atom_to_list(AppName), AppName).
-%% @spec remove(YappServer::pid(), SrvId::string(), YappUrlOrName::string()) -> ok | exit()
-%% YappUrlOrName = string() | atom()
+-spec remove(YappServer :: pid(), SrvId :: string(),
+ YappUrlOrName :: string() | atom()) -> ok.
%% @doc Remove a Yapp from Yaws. Removes in the virtual server with yapp_server_id = SrvID.
%% The YappUrlOrName is either the root path to the Yapp or the name of it.
remove(YappServer, SrvId, YappUrlOrName) when is_list(YappUrlOrName)->
@@ -67,7 +65,7 @@ remove(YappServer, SrvId, YappUrlOrName) when is_list(YappUrlOrName)->
remove(YappServer, SrvId, YappUrlOrName) when is_atom(YappUrlOrName)->
remove(YappServer, SrvId, "/" ++ atom_to_list(YappUrlOrName)).
-%% @spec init_yapps(YappServer::pid()) -> ok | exit()
+-spec init_yapps(YappServer :: pid()) -> ok.
%% @doc Iinitalizes the Yaws Sconfs list with bootstrap_yapps and Yapps in the
%% the registry. The default name for YappServer is the atom yapp_handler.
init_yapps(YappServer) ->
diff --git a/applications/yapp/src/yapp_mnesia_server.erl b/applications/yapp/src/yapp_mnesia_server.erl
index a046d61b6..1301a287b 100644
--- a/applications/yapp/src/yapp_mnesia_server.erl
+++ b/applications/yapp/src/yapp_mnesia_server.erl
@@ -158,7 +158,9 @@ list_yapps() ->
{atomic, Value} = mnesia:transaction(fun() -> get_yapp_reg() end),
Value.
-%% @spec register_yapp(SrvId::string(), {YappUrl::string(), AppName::atom()}) -> ok | exit()
+-spec register_yapp(SrvId :: string(), KeyValue) -> ok
+ when
+ KeyValue :: {YappUrl :: string(), AppName :: atom()}.
%% @doc Register a Yapp. Registers in the virtual server with the opaque property
%% yapp_server_id = SrvID. The YappUrl is the root path to the Yapp and the AppName is
%% the Name of the application.
@@ -181,7 +183,7 @@ register2(SrvId, {YappUrl, AppName}) ->
put_yapp_reg(YR2).
-%% @spec unregister_yapp(SrvId::string(), YappUrl::string()) -> ok | exit()
+-spec unregister_yapp(SrvId :: string(), YappUrl :: string()) -> ok.
%% @doc Unregister a Yapp. Unregisters in the virtual server with yapp_server_id = SrvID.
%% The YappUrl is the root path to the Yapp.
unregister_yapp(SrvId, YappUrl) ->
diff --git a/applications/yapp/src/yapp_registry.erl b/applications/yapp/src/yapp_registry.erl
index 9bfd24d2a..5a6484c84 100644
--- a/applications/yapp/src/yapp_registry.erl
+++ b/applications/yapp/src/yapp_registry.erl
@@ -12,17 +12,20 @@
%% API
-export([list/1, register/3, unregister/3]).
-%% @spec list(YappRegistry::pid()) -> RegistryContent | exit()
-%% RegsitryContent = [YawsSrvContent]
-%% YawsSrvContent = {YawsServerId, Yapps}
-%% Yapps = [{URL, AppName}] | undefined
-%% URL= string()
-%% AppName = atom()
+-spec list(YappRegistry :: pid()) -> RegistryContent
+ when
+ RegistryContent :: [YawsSrvContent],
+ YawsSrvContent :: {YawsServerId, Yapps},
+ YawsServerId :: string(),
+ Yapps :: [{URL, AppName}] | undefined,
+ URL :: string(),
+ AppName :: atom().
%% @doc Lists all registered Yapps.
list(YappRegistry) ->
gen_server:call(YappRegistry,{?MODULE, list}).
-%% @spec register(YappRegistry::pid(), SrvId::string(), {YappUrl::string(), AppName::atom()}) -> ok | exit()
+-spec register(YappRegistry :: pid(), SrvId :: string(),
+ {YappUrl ::string (), AppName :: atom()}) -> ok.
%% @doc Register a Yapp. Registers in the virtual server with the opaque property
%% yapp_server_id = SrvID. The YappUrl is the root path to the Yapp and the AppName is
%% the Name of the application.
@@ -30,7 +33,8 @@ register(YappRegistry, SrvId, {_YappUrl, _AppName} = A) ->
gen_server:call(YappRegistry,{?MODULE, register, {SrvId, A}}).
-%% @spec unregister(YappRegistry::pid(), SrvId::string(), YappUrl::string()) -> ok | exit()
+-spec unregister(YappRegistry :: pid(), SrvId :: string(),
+ YappUrl :: string()) -> ok.
%% @doc Unregister a Yapp from Yaws. Unregisters in the virtual server with yapp_server_id = SrvID.
%% The YappUrlOrName is either the root path to the Yapp or the name of it.
unregister(YappRegistry, SrvId, YappUrl) ->