File 3752-EDoc-Add-docs-and-test-of-user-defined-macros.patch of Package erlang

From 595396355f09ead5d70ce66c6bad6ac509b00b45 Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Thu, 28 Jan 2021 13:03:20 +0100
Subject: [PATCH 2/2] EDoc: Add docs and test of user defined macros

---
 lib/edoc/src/edoc.erl        | 14 +++++++++++---
 lib/edoc/test/edoc_SUITE.erl |  5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl
index 0fdc818fae..3a40b5f815 100644
--- a/lib/edoc/src/edoc.erl
+++ b/lib/edoc/src/edoc.erl
@@ -745,10 +745,18 @@ get_doc(File) ->
 %%  </dt>
 %%  <dd><ul>
 %%       <li>`Macros' = {@type Macro | [Macro]}</li>
-%%       <li>`Macro' = {@type {Name::atom(), Text::string()@}}</li>
+%%       <li>`Macro' = {@type {Name::atom(), Text::string() | MacroFun@}}</li>
+%%       <li>`MacroFun' = {@type fun((MacroArgument::string(),
+%%                                    Line :: integer(),
+%%                                    edoc_lib:edoc_env()) -> (Text::string()))}</li>
 %%      </ul>
-%%    Specifies a set of EDoc macro definitions. See
-%%    <a href="overview-summary.html#Macro_expansion">Inline macro expansion</a>
+%%    Specifies a set of user-defined EDoc macros. The text
+%%    substituted for macro calls is specified as either a {@type
+%%    string()} or a {@type fun()}. The function is called with the
+%%    macro argument text, the current line number, and the current
+%%    environment. The fun is to return a {@type string()}.
+%%    See
+%%    <a href="overview-summary.html#Macro_expansion">Macro expansion</a>
 %%    for details.
 %%  </dd>
 %%  <dt>{@type {hidden, boolean()@}}
diff --git a/lib/edoc/test/edoc_SUITE.erl b/lib/edoc/test/edoc_SUITE.erl
index 29ca9d1203..12d06357df 100644
--- a/lib/edoc/test/edoc_SUITE.erl
+++ b/lib/edoc/test/edoc_SUITE.erl
@@ -70,6 +70,11 @@ build_std(Config) when is_list(Config) ->
 	    {def, {vsn,"TEST"}},
 	    {dir, PrivDir}]),
 
+    MF = fun(_MacroArg="", _Line, _Env) -> "TEST" end,
+    ok = edoc:application(syntax_tools, [{overview, Overview2},
+	    {def, {vsn,MF}},
+	    {dir, PrivDir}]),
+
     ok = edoc:application(xmerl, [{preprocess,true},{dir, PrivDir}]),
     ok.
 
-- 
2.26.2

openSUSE Build Service is sponsored by