summaryrefslogtreecommitdiff
path: root/lib/edoc/src/edoc_types.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/edoc/src/edoc_types.erl')
-rw-r--r--lib/edoc/src/edoc_types.erl107
1 files changed, 106 insertions, 1 deletions
diff --git a/lib/edoc/src/edoc_types.erl b/lib/edoc/src/edoc_types.erl
index 510f9513b2..51219b5143 100644
--- a/lib/edoc/src/edoc_types.erl
+++ b/lib/edoc/src/edoc_types.erl
@@ -39,6 +39,100 @@
-include("edoc_types.hrl").
-include_lib("xmerl/include/xmerl.hrl").
+%-type t_spec() :: #t_spec{name :: t_name(),
+% type :: t_type(),
+% defs :: [t_def()]}.
+%% Function specification.
+
+-type type() :: t_atom() | t_binary() | t_float() | t_fun() | t_integer()
+ | t_integer_range() | t_list() | t_nil()| t_nonempty_list()
+ | t_record() | t_tuple() | t_type() | t_union() | t_var()
+ | t_paren().
+
+%-type t_typedef() :: #t_typedef{name :: t_name(),
+% args :: [type()],
+% type :: type() | undefined,
+% defs :: [t_def()]}.
+%% Type declaration/definition.
+
+%-type t_throws() :: #t_throws{type :: type(),
+% defs :: [t_def()]}.
+%% Exception declaration.
+
+%-type t_def() :: #t_def{name :: t_type() | t_var(),
+% type :: type()}.
+%% Local definition `name = type'.
+
+-type t_name() :: #t_name{app :: [] | atom(),
+ module :: [] | atom(),
+ name :: [] | atom()}.
+
+-type t_var() :: #t_var{a :: list(),
+ name :: [] | atom()}.
+%% Type variable.
+
+-type t_type() :: #t_type{a :: list(),
+ name :: t_name(),
+ args :: [type()]}.
+%% Abstract type `name(...)'.
+
+-type t_union() :: #t_union{a :: list(),
+ types :: [type()]}.
+%% Union type `t1 | ... | tN'.
+
+-type t_fun() :: #t_fun{a :: list(),
+ args :: [type()],
+ range :: type()}.
+%% Function `(t1, ..., tN) -> range'.
+
+-type t_tuple() :: #t_tuple{a :: list(),
+ types :: [type()]}.
+%% Tuple type `{t1,...,tN}'.
+
+-type t_list() :: #t_list{a :: list(),
+ type :: type()}.
+%% List type `[type]'.
+
+-type t_nil() :: #t_nil{a :: list()}.
+%% Empty-list constant `[]'.
+
+-type t_nonempty_list() :: #t_nonempty_list{a :: list(),
+ type :: type()}.
+%% List type `[type, ...]'.
+
+-type t_atom() :: #t_atom{a :: list(),
+ val :: atom()}.
+%% Atom constant.
+
+-type t_integer() :: #t_integer{a :: list(),
+ val :: integer()}.
+%% Integer constant.
+
+-type t_integer_range() :: #t_integer_range{a :: list(),
+ from :: integer(),
+ to :: integer()}.
+
+-type t_binary() :: #t_binary{a :: list(),
+ base_size :: integer(),
+ unit_size :: integer()}.
+
+-type t_float() :: #t_float{a :: list(),
+ val :: float()}.
+%% Floating-point constant.
+
+-type t_record() :: #t_record{a :: list(),
+ name :: t_atom(),
+ fields :: [t_field()]}.
+%% Record "type" `#r{f1, ..., fN}'.
+
+-type t_field() :: #t_field{a :: list(),
+ name :: type(),
+ type :: type()}.
+%% Named field `n1 = t1'.
+
+-type t_paren() :: #t_paren{a :: list(), type :: type()}.
+%% Parentheses.
+
is_predefined(cons, 2) -> true;
is_predefined(deep_string, 0) -> true;
is_predefined(F, A) -> erl_internal:is_type(F, A).
@@ -63,7 +157,18 @@ to_label(N) ->
edoc_refs:to_label(to_ref(N)).
get_uri(Name, Env) ->
- edoc_refs:get_uri(to_ref(Name), Env).
+ NewName = infer_module_app(Name),
+ edoc_refs:get_uri(to_ref(NewName), Env).
+
+infer_module_app(#t_name{app = [], module = M} = TName) when is_atom(M) ->
+ case edoc_lib:infer_module_app(M) of
+ no_app ->
+ TName;
+ {app, App} when is_atom(App) ->
+ TName#t_name{app = App}
+ end;
+infer_module_app(Other) ->
+ Other.
to_xml(#t_var{name = N}, _Env) ->
{typevar, [{name, atom_to_list(N)}], []};