Skip to content

Commit

Permalink
Merge pull request erlang#7643 from paulo-ferraz-oliveira/feature/edo…
Browse files Browse the repository at this point in the history
…c-code-for-tt/OTP-18782

Replace EDoc-issued `<tt>` elements with `<code>` (in generated HTML)
  • Loading branch information
garazdawi authored Oct 3, 2023
2 parents e6a02fc + 901a320 commit 9f7efe7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions lib/edoc/doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ documentation.
=== Empty lines separate paragraphs ===

Leaving an empty line in XHTML text (i.e., a line which except for
any leading start-of-comment '<tt>%</tt>' characters contains only
any leading start-of-comment '<code>%</code>' characters contains only
whitespace), will make EDoc split the text before and
after the empty line into separate paragraphs. For example:
```%% @doc This will all be part of the first paragraph.
Expand Down Expand Up @@ -598,7 +598,7 @@ The above expansions take place before XML parsing.
Writing a URL within brackets, as in "`[http://www.w3c.org/]'", will
generate a hyperlink such as [http://www.w3c.org/], using the URL both
for the destination and the label of the reference, equivalent to writing
"`<a href="http://www.w3c.org/"><tt>http://www.w3c.org/</tt></a>'". This
"`<a href="http://www.w3c.org/"><code>http://www.w3c.org/</code></a>'". This
short-hand keeps external URL references short and readable. The
recognized protocols are `http', `ftp', and `file'. This expansion takes
place before XML parsing.
Expand Down Expand Up @@ -703,7 +703,7 @@ information. User-defined macros override predefined macros.

<dl>
<dt><a name="predefmacro-date"><code>@{@date}</code></a></dt>
<dd>Expands to the current date, as "<tt>Month Day Year</tt>",
<dd>Expands to the current date, as "<code>Month Day Year</code>",
e.g. "{@date}".</dd>

<dt><a name="predefmacro-link"><code>@{@link <em>reference</em>.
Expand All @@ -726,7 +726,7 @@ information. User-defined macros override predefined macros.
see {@section Headings} for more information.</dd>

<dt><a name="predefmacro-time"><code>@{@time}</code></a></dt>
<dd>Expands to the current time, as "<tt>Hr:Min:Sec</tt>",
<dd>Expands to the current time, as "<code>Hr:Min:Sec</code>",
e.g. "{@time}".</dd>

<dt><a name="predefmacro-type"><code>@{@type
Expand Down
26 changes: 13 additions & 13 deletions lib/edoc/src/edoc_layout.erl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ label_anchor(Content, E) ->
%% This is currently only done for functions without type spec.

signature(Es, Name) ->
[{tt, [Name, "("] ++ seq(fun arg/1, Es) ++ [") -> any()"]}].
[{code, [Name, "("] ++ seq(fun arg/1, Es) ++ [") -> any()"]}].

arg(#xmlElement{content = Es}) ->
[get_text(argName, Es)].
Expand All @@ -441,7 +441,7 @@ params(Es) ->
if As1 == [] ->
[];
true ->
[ { [{tt, [A]}, ": "] ++ D ++ [br, ?NL] }
[ { [{code, [A]}, ": "] ++ D ++ [br, ?NL] }
|| {A, D} <- As1]
end.

Expand All @@ -460,7 +460,7 @@ throws(Es, Opts) ->
[] -> [];
Es1 ->
%% Doesn't use format_type; keep it short!
[{p, (["throws ", {tt, t_utype(get_elem(type, Es1), Opts)}]
[{p, (["throws ", {code, t_utype(get_elem(type, Es1), Opts)}]
++ local_defs(get_elem(localdef, Es1), Opts))},
?NL]
end.
Expand Down Expand Up @@ -497,7 +497,7 @@ typedef(Es, Opts) ->
Name = ([t_name(get_elem(erlangName, Es), Opts), "("]
++ seq(t_utype_elem_fun(Opts), get_content(argtypes, Es), [")"])),
(case get_elem(type, Es) of
[] -> [{b, ["abstract datatype"]}, ": ", {tt, Name}];
[] -> [{b, ["abstract datatype"]}, ": ", {code, Name}];
Type -> format_type(Name, Name, Type, [], Opts)
end
++ local_defs(get_elem(localdef, Es), Opts)).
Expand Down Expand Up @@ -540,7 +540,7 @@ format_spec(Name, Type, Defs, #opts{pretty_printer = erl_pp}=Opts) ->
format_spec(Sep, Type, Defs, Opts) ->
%% Very limited formatting.
Br = if Defs =:= [] -> br; true -> [] end,
[{tt, t_clause(Sep, Type, Opts)}, Br].
[{code, t_clause(Sep, Type, Opts)}, Br].

t_clause(Name, Type, Opts) ->
#xmlElement{content = [#xmlElement{name = 'fun', content = C}]} = Type,
Expand All @@ -567,7 +567,7 @@ format_type(Prefix, Name, Type, Last, #opts{pretty_printer = erl_pp}=Opts) ->
format_type(Prefix, Name, Type, Last, Opts#opts{pretty_printer =''})
end;
format_type(Prefix, _Name, Type, Last, Opts) ->
[{tt, Prefix ++ [" = "] ++ t_utype(Type, Opts) ++ Last}].
[{code, Prefix ++ [" = "] ++ t_utype(Type, Opts) ++ Last}].

pp_type(Prefix, Type, Opts) ->
Atom = list_to_atom(lists:duplicate(string:length(Prefix), $a)),
Expand Down Expand Up @@ -672,7 +672,7 @@ equiv(Es, P) ->
case get_content(expr, Es1) of
[] -> [];
[Expr] ->
Expr1 = [{tt, [Expr]}],
Expr1 = [{code, [Expr]}],
Expr2 = case get_elem(see, Es1) of
[] ->
Expr1;
Expand Down Expand Up @@ -745,19 +745,19 @@ behaviours(Es, Name, Opts) ->
[br, " Optional callback functions: "]
++ seq(CBFun, OCBs, ["."])
end,
[{p, ([{b, ["This module defines the ", {tt, [Name]},
[{p, ([{b, ["This module defines the ", {code, [Name]},
" behaviour."]}]
++ Req ++ Opt)},
?NL]
end).

behaviour(E=#xmlElement{content = Es}) ->
see(E, [{tt, Es}]).
see(E, [{code, Es}]).

callback(E=#xmlElement{}, Opts) ->
Name = get_attrval(name, E),
Arity = get_attrval(arity, E),
[{tt, [atom(Name, Opts), "/", Arity]}].
[{code, [atom(Name, Opts), "/", Arity]}].

authors(Es) ->
case get_elem(author, Es) of
Expand All @@ -782,18 +782,18 @@ author(E=#xmlElement{}) ->
Mail = get_attrval(email, E),
URI = get_attrval(website, E),
(if Name == Mail ->
[{a, [{href, "mailto:" ++ Mail}],[{tt, [Mail]}]}];
[{a, [{href, "mailto:" ++ Mail}],[{code, [Mail]}]}];
true ->
if Mail == "" -> [Name];
true -> [Name, " (", {a, [{href, "mailto:" ++ Mail}],
[{tt, [Mail]}]}, ")"]
[{code, [Mail]}]}, ")"]
end
end
++ if URI == "" ->
[];
true ->
[" [", {em, ["web site:"]}, " ",
{tt, [{a, [{href, URI}, {target, "_top"}], [URI]}]},
{code, [{a, [{href, URI}, {target, "_top"}], [URI]}]},
"]"]
end).

Expand Down
2 changes: 1 addition & 1 deletion lib/edoc/src/edoc_wiki.erl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ expand_uri(Cs, L, As) ->
expand(Cs, L, [$[ | As]).

expand_uri([$] | Cs], L, Us, As) ->
expand(Cs, L, push_uri(Us, ">tt/<" ++ Us ++ ">tt<", As));
expand(Cs, L, push_uri(Us, ">edoc/<" ++ Us ++ ">edoc<", As));
expand_uri([$\s = C | Cs], L, Us, As) ->
expand_uri(Cs, 0, L, [C], Us, As);
expand_uri([$\t = C | Cs], L, Us, As) ->
Expand Down
8 changes: 4 additions & 4 deletions lib/edoc/test/edoc_SUITE_data/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ documentation.
=== Empty lines separate paragraphs ===

Leaving an empty line in XHTML text (i.e., a line which except for
any leading start-of-comment '<tt>%</tt>' characters contains only
any leading start-of-comment '<code>%</code>' characters contains only
whitespace), will make EDoc split the text before and
after the empty line into separate paragraphs. For example:
```%% @doc This will all be part of the first paragraph.
Expand Down Expand Up @@ -484,7 +484,7 @@ The above expansions take place before XML parsing.
Writing a URL within brackets, as in "`[http://www.w3c.org/]'", will
generate a hyperlink such as [http://www.w3c.org/], using the URL both
for the destination and the label of the reference, equivalent to writing
"`<a href="http://www.w3c.org/"><tt>http://www.w3c.org/</tt></a>'". This
"`<a href="http://www.w3c.org/"><code>http://www.w3c.org/</code></a>'". This
short-hand keeps external URL references short and readable. The
recognized protocols are `http', `ftp', and `file'. This expansion takes
place before XML parsing.
Expand Down Expand Up @@ -583,7 +583,7 @@ information.

<dl>
<dt><a name="predefmacro-date"><code>@{@date}</code></a></dt>
<dd>Expands to the current date, as "<tt>Month Day Year</tt>",
<dd>Expands to the current date, as "<code>Month Day Year</code>",
e.g. "{@date}".</dd>

<dt><a name="predefmacro-docRoot"><code>@{@docRoot}</code></a></dt>
Expand Down Expand Up @@ -628,7 +628,7 @@ information.
{@section Escape sequences} below.)</dd>

<dt><a name="predefmacro-time"><code>@{@time}</code></a></dt>
<dd>Expands to the current time, as "<tt>Hr:Min:Sec</tt>",
<dd>Expands to the current time, as "<code>Hr:Min:Sec</code>",
e.g. "{@time}".</dd>
</dl>

Expand Down

0 comments on commit 9f7efe7

Please sign in to comment.