Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
4431-edoc-Propagate-type-links-from-type-macro....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4431-edoc-Propagate-type-links-from-type-macro.patch of Package erlang
From 8f7aa9cf9989669ff77ff2ac549c0e3bae3530c5 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Fri, 10 Nov 2023 15:03:19 +0100 Subject: [PATCH 1/4] edoc: Propagate type links from {@type macro} --- lib/edoc/src/edoc_layout.erl | 11 +++++++---- lib/edoc/src/edoc_refs.erl | 6 +++--- lib/edoc/src/edoc_types.erl | 14 ++++++++++++-- lib/edoc/test/eep48_SUITE.erl | 2 ++ lib/edoc/test/eep48_SUITE_data/eep48_links.erl | 5 +++++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/edoc/src/edoc_layout.erl b/lib/edoc/src/edoc_layout.erl index f6f11ae5d8..6580ce47d9 100644 --- a/lib/edoc/src/edoc_layout.erl +++ b/lib/edoc/src/edoc_layout.erl @@ -660,10 +660,13 @@ href(E) -> case get_attrval(href, E) of "" -> []; URI -> - T = case get_attrval(target, E) of - "" -> []; - S -> [{target, S}] - end, + T = lists:flatmap( + fun(K) -> + case get_attrval(K, E) of + "" -> []; + S -> [{K, S}] + end + end, [target, 'docgen-rel', 'docgen-href']), [{href, URI} | T] end. diff --git a/lib/edoc/src/edoc_refs.erl b/lib/edoc/src/edoc_refs.erl index f5bf2468a2..f1e26ea660 100644 --- a/lib/edoc/src/edoc_refs.erl +++ b/lib/edoc/src/edoc_refs.erl @@ -140,12 +140,12 @@ docgen_uri({module, M}) -> docgen_uri({module, M, Ref}) -> [atom_to_list(M), docgen_uri(Ref)]; docgen_uri({function, F, A}) -> - ["#", atom_to_list(F), "/", integer_to_list(A)]; + ["#", escape_uri(atom_to_list(F)), "/", integer_to_list(A)]; docgen_uri({type, T}) -> - ["#", atom_to_list(T), "/0"]; + ["#", escape_uri(atom_to_list(T)), "/0"]; docgen_uri({type, T, A}) -> %% This case is not used yet, but since types also have arity it should be in the future. - ["#", atom_to_list(T), "/", integer_to_list(A)]. + ["#", escape_uri(atom_to_list(T)), "/", integer_to_list(A)]. get_uri({app, App}, Env) -> join_uri(app_ref(App, Env), ?INDEX_FILE); diff --git a/lib/edoc/src/edoc_types.erl b/lib/edoc/src/edoc_types.erl index 94e8db5749..9bc7b33386 100644 --- a/lib/edoc/src/edoc_types.erl +++ b/lib/edoc/src/edoc_types.erl @@ -160,6 +160,10 @@ get_uri(Name, Env) -> NewName = infer_module_app(Name), edoc_refs:get_uri(to_ref(NewName), Env). +get_docgen_uri(Name, _Env) -> + NewName = infer_module_app(Name), + edoc_refs:get_docgen_link(to_ref(NewName)). + infer_module_app(#t_name{app = [], module = M} = TName) when is_atom(M) -> case edoc_lib:infer_module_app(M) of no_app -> @@ -194,9 +198,15 @@ to_xml(#t_type{name = N, args = As}, Env, Opts) -> HRef = case {Predef, proplists:get_value(link_predefined_types, Opts, false)} of {true, false} -> []; {true, true} -> - [{href, get_uri(N#t_name{ module = erlang }, Env)}]; + {DocgenRel, DocgenURI} = get_docgen_uri(N#t_name{ module = erlang }, Env), + [{'docgen-rel',DocgenRel}, + {'docgen-href',DocgenURI}, + {href, get_uri(N#t_name{ module = erlang }, Env)}]; {false, _} -> - [{href, get_uri(N, Env)}] + {DocgenRel, DocgenURI} = get_docgen_uri(N, Env), + [{'docgen-rel',DocgenRel}, + {'docgen-href',DocgenURI}, + {href, get_uri(N, Env)}] end, {abstype, HRef, [to_xml(N, Env, Opts) | map(fun wrap_utype/3, As, Env, Opts)]}; to_xml(#t_fun{args = As, range = T}, Env, Opts) -> diff --git a/lib/edoc/test/eep48_SUITE.erl b/lib/edoc/test/eep48_SUITE.erl index 7932634b34..e56e88e93e 100644 --- a/lib/edoc/test/eep48_SUITE.erl +++ b/lib/edoc/test/eep48_SUITE.erl @@ -233,6 +233,8 @@ links(Config) -> get_doc_link({function, local_function_link, 0}, Docs)), ?assertEqual({<<"seetype">>, <<"#t/0">>}, get_doc_link({function, local_type_link, 0}, Docs)), + ?assertEqual({<<"seetype">>, <<"#t/0">>}, + get_doc_link({function, local_type_link_macro, 0}, Docs)), ?assertEqual({<<"seetype">>, <<"eep48_links#t/0">>}, get_doc_link({function, external_type_link, 0}, Docs)). diff --git a/lib/edoc/test/eep48_SUITE_data/eep48_links.erl b/lib/edoc/test/eep48_SUITE_data/eep48_links.erl index 0e5c8033db..2345495aed 100644 --- a/lib/edoc/test/eep48_SUITE_data/eep48_links.erl +++ b/lib/edoc/test/eep48_SUITE_data/eep48_links.erl @@ -11,6 +11,7 @@ external_function_link/0, local_function_link/0, local_type_link/0, + local_type_link_macro/0, external_type_link/0]). -export([see_module/0, @@ -57,6 +58,10 @@ local_function_link() -> ok. %% Should map to `seetype'. local_type_link() -> ok. +%% @doc Local type link {@type {type, t()@}}. +%% Should map to `seetype'. +local_type_link_macro() -> ok. + %% @doc External type link {@link eep48_links:t()}. %% Should map to `seetype'. external_type_link() -> ok. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor