Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/edoc/src/edoc.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
-define(DEFAULT_FILE_SUFFIX, ".html").
-define(DEFAULT_DOCLET, edoc_doclet).
-define(DEFAULT_LAYOUT, edoc_layout).
-define(APP_DEFAULT, "http://www.erlang.org/edoc/doc").
-define(APP_DEFAULT, "http://www.erlang.org/doc/apps").
-define(CURRENT_DIR, ".").
-define(SOURCE_DIR, "src").
-define(EBIN_DIR, "ebin").
Expand Down
2 changes: 2 additions & 0 deletions lib/edoc/src/edoc_refs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ module_absref(M, Env) ->

app_ref(A, Env) ->
case (Env#env.apps)(A) of
"" when Env#env.app_default == ?APP_DEFAULT ->
join_uri(Env#env.app_default, escape_uri(atom_to_list(A)));
"" ->
join_uri(Env#env.app_default,
join_uri(escape_uri(atom_to_list(A)), ?EDOC_DIR));
Expand Down
40 changes: 36 additions & 4 deletions lib/edoc/test/edoc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@
-module(edoc_SUITE).

-include_lib("common_test/include/ct.hrl").
-include_lib("xmerl/include/xmerl.hrl").

%% Test server specific exports
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
init_per_group/2,end_per_group/2]).

%% Test cases
-export([app/1,appup/1,build_std/1,build_map_module/1,otp_12008/1,
build_app/1, otp_14285/1, infer_module_app_test/1,
module_with_feature/1, module_with_maybe/1, module_with_nominal/1]).
module_with_feature/1, module_with_maybe/1, module_with_nominal/1,
otp_reference/1]).

suite() -> [{ct_hooks,[ts_install_cth]}].

all() ->
[app,appup,build_std,build_map_module,otp_12008, build_app, otp_14285,
infer_module_app_test, module_with_feature, module_with_nominal].
infer_module_app_test, module_with_feature, module_with_nominal,
otp_reference].

groups() ->
[].
Expand Down Expand Up @@ -195,4 +198,33 @@ module_with_nominal(Config) ->
ok = edoc:files([Source], DodgerOpts),
PreprocessOpts = [{preprocess, true}, {dir, PrivDir}],
ok = edoc:files([Source], PreprocessOpts),
ok.
ok.

otp_reference(Config) ->
DataDir = ?config(data_dir, Config),
Source = filename:join(DataDir, "module_with_links.erl"),
{module_with_links, Module} = edoc:get_doc(Source),
Functions = lists:keyfind(functions,
#xmlElement.name, Module#xmlElement.content),
[Start] = Functions#xmlElement.content,
Description = lists:keyfind(description,
#xmlElement.name, Start#xmlElement.content),
FullDescription = lists:keyfind(fullDescription,
#xmlElement.name, Description#xmlElement.content),
A = lists:keyfind(a,
#xmlElement.name, FullDescription#xmlElement.content),
Href1 = lists:keyfind(href,
#xmlAttribute.name, A#xmlElement.attributes),
URI1 = uri_string:parse(Href1#xmlAttribute.value),
"www.erlang.org" = maps:get(host, URI1),
"/doc/apps/kernel/application.html" = maps:get(path, URI1),
% "start/1" = maps:get(fragment, URI1),
See = lists:keyfind(see,
#xmlElement.name, Start#xmlElement.content),
Href2 = lists:keyfind(href,
#xmlAttribute.name, See#xmlElement.attributes),
URI2 = uri_string:parse(Href2#xmlAttribute.value),
"www.erlang.org" = maps:get(host, URI2),
"/doc/apps/kernel/application.html" = maps:get(path, URI2).
% "start/1" = maps:get(fragment, URI2).

33 changes: 33 additions & 0 deletions lib/edoc/test/edoc_SUITE_data/module_with_links.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2026. All Rights Reserved.
Comment thread
vances marked this conversation as resolved.
Outdated
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%
-module(module_with_links).
-export([start/0]).

-spec start() -> ok.
%% @doc Start application.
%%
%% Start application with {@link //kernel/application:start/1. application:start/1}.
%%
%% @see //kernel/application:start/1
%%
start() ->
application:start(my_app).

Loading