File 4242-Add-documentation-about-indirect-inherits-option.patch of Package erlang

From c0280a62713ca5009350eaed16bcda6d7fe57876 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20W=C4=85sowski?= <michal@erlang.org>
Date: Thu, 25 Sep 2025 11:29:41 +0200
Subject: [PATCH 2/3] Add documentation about indirect-inherits option

---
 lib/diameter/doc/references/diameter_dict.md | 101 +++++++++++++++++++
 lib/diameter/doc/references/diameterc_cmd.md |  11 +-
 lib/diameter/src/compiler/diameter_make.erl  |  20 ++++
 3 files changed, 128 insertions(+), 4 deletions(-)

diff --git a/lib/diameter/doc/src/diameter_dict.xml b/lib/diameter/doc/src/diameter_dict.xml
index 2f589acd02..75ab3aeb20 100644
--- a/lib/diameter/doc/src/diameter_dict.xml
+++ b/lib/diameter/doc/src/diameter_dict.xml
@@ -267,6 +267,62 @@ Example:</p>
 <pre>
 @inherits diameter_gen_base_rfc6733
 </pre>
+
+<p>
+When using the <c>indirect_inherits</c> option from
+<seemfa marker="diameter_make#codec/2">diameter_make:codec/2</seemfa>,
+only <c>@vendor</c> from the dictionary that defined the AVPs and <c>@avp_vendor_id</c>
+in the currently compiled dictionary is used. All other dictionaries along the
+chain are ignored, so for example:</p>
+
+<p><c>a.dia</c>:</p>
+<pre>
+  @vendor 1 A
+  @avp_types
+      AAA 111 Unsigned32 V
+      BBB 222 Unsigned32 V
+</pre>
+<p><c>a.dia</c> will see:</p>
+<pre>
+    - AAA vendor_id = 1
+    - BBB vendor_id = 1
+</pre>
+<p><c>b.dia</c>:</p>
+<pre>
+  @vendor 2 B
+  @avp_types
+      CCC 333 Unsigned32 V
+  @inherits diameter_a
+  @avp_vendor_id 4
+      AAA
+</pre>
+<p><c>b.dia</c> will see:</p>
+<pre>
+    - AAA vendor_id = 4
+    - BBB vendor_id = 1
+    - CCC vendor_id = 2
+</pre>
+<p><c>c.dia</c>:</p>
+<pre>
+  @vendor 3 C
+  @avp_types
+      DDD 444 Unsigned32 V
+  @inherits diameter_b
+  @avp_vendor_id 5
+      BBB
+      CCC
+</pre>
+<p><c>c.dia</c> will see:</p>
+<pre>
+    - AAA vendor_id = 1
+    - BBB vendor_id = 5
+    - CCC vendor_id = 5
+    - DDD vendor_id = 3
+</pre>
+
+<p>
+In particular <c>b.dia</c>'s override of <c>AAA</c> to vendor_id = 4
+is ignored by <c>c.dia</c> and <c>AAA</c> is back to having vendor_id = 1.</p>
 </item>
 
 <tag>
@@ -441,6 +497,60 @@ REMOVE_SIP_SERVER        3
 </pre>
 </item>
 
+</item>
+<p>
+If <c>indirect_inherits</c> option from
+<seemfa marker="diameter_make#codec/2">diameter_make:codec/2</seemfa> is used,
+new enum values can also be added in each <c>.dia</c> file along the inheritance chain,
+example:</p>
+<p><c>a.dia</c>:</p>
+<pre>
+  @avp_types
+      AAA 111 Enumerated V
+  @enum AAA
+      A 0
+      B 1
+</pre>
+<p><c>a.dia</c> will see following enum values:</p>
+<pre>
+    - A 0
+    - B 1
+</pre>
+<p><c>b.dia</c>:</p>
+<pre>
+  @inherits diameter_a
+  @enum AAA
+      C 2
+      D 3
+</pre>
+<p><c>b.dia</c> will see following enum values:</p>
+<pre>
+    - A 0
+    - B 1
+    - C 2
+    - D 3
+</pre>
+<p><c>c.dia</c>:</p>
+<pre>
+  @inherits diameter_b
+  @enum AAA
+      E 4
+      F 5
+</pre>
+<p><c>c.dia</c> will see:</p>
+<pre>
+    - A 0
+    - B 1
+    - C 2
+    - D 3
+    - E 4
+    - F 5
+</pre>
+<p>
+Warning: messages are not shown in this example, but it is required to add
+enum AVPs to messages in order for the code to encode/decode them to be generated!</p>
+</item>
+
 <tag>
 <marker id="end"/><c>@end</c></tag>
 <item>
diff --git a/lib/diameter/doc/src/diameterc_cmd.xml b/lib/diameter/doc/src/diameterc_cmd.xml
index d76aac3d7e..b85edf6c8e 100644
--- a/lib/diameter/doc/src/diameterc_cmd.xml
+++ b/lib/diameter/doc/src/diameterc_cmd.xml
@@ -119,6 +119,13 @@ modifying the file itself.</p>
 Multiple <c>--inherits</c> options can be specified.</p>
 </item>
 
+<tag><![CDATA[--indirect-inherits]]></tag>
+<item>
+<p>
+Enables indirect inherits feature,
+<seemfa marker="diameter_make#codec/2">diameter_make:codec/2</seemfa>.</p>
+</item>
+
 </taglist>
 
 </item>
diff --git a/lib/diameter/doc/src/diameter_make.xml b/lib/diameter/doc/src/diameter_make.xml
index c0d7b9198a..213afd3dfc 100644
--- a/lib/diameter/doc/src/diameter_make.xml
+++ b/lib/diameter/doc/src/diameter_make.xml
@@ -167,6 +167,27 @@ modifying the file itself.</p>
 Multiple <c>inherits</c> options can be specified.</p>
 </item>
 
+<tag><c>indirect_inherits</c></tag>
+<item>
+<p>
+This option makes compiler support automatic recursive inheritance.
+When a dictionary file inherits another <c>.dia</c>, all ancestors
+of that <c>.dia</c> will also be considered in code generation.
+This enhancement removes the requirement to explicitly list
+all parent dictionaries via <c>@inherits</c>,
+preventing missing AVP/message encodings and runtime errors.</p>
+
+<p>Example <c>C.dia</c> inherits <c>B.dia</c> and <c>B.dia</c> inherits <c>A.dia</c>.</p>
+<p>Before (without indirect_inherits):</p>
+<p>If <c>C.dia</c> references AVPs from <c>A.dia</c> without directly inheriting it,
+the generated code will lack necessary definitions, causing encoding failures.</p>
+<p>After (with indirect_inherits):</p>
+<p><c>C.dia</c> can reference AVPs from <c>A.dia</c> without directly inheriting it,
+compiler will resolve the entire inheritance chain automatically, ensuring
+all relevant descendant definitions from <c>A.dia</c> are available without
+additional user declarations.</p>
+</item>
+
 </taglist>
 
 <p>
-- 
2.51.0

openSUSE Build Service is sponsored by