File 0135-docs-Fix-example-section-in-docs-howto.patch of Package erlang
From e62e8df44fb43bb267788e48c14f322774852cbb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= <lukas@erlang.org>
Date: Tue, 4 Mar 2025 12:10:33 +0100
Subject: [PATCH] docs: Fix example section in docs howto
---
HOWTO/DOCUMENTATION.md | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/HOWTO/DOCUMENTATION.md b/HOWTO/DOCUMENTATION.md
index d73f7ab5cb..b57c19744d 100644
--- a/HOWTO/DOCUMENTATION.md
+++ b/HOWTO/DOCUMENTATION.md
@@ -262,18 +262,19 @@ code fragment:”
For code examples with several steps and for long examples:
- Ensure that it is obvious for the reader what belongs to the example.
-- Use either a subheading `#### Example` or use a separate paragraph
- with the text `*Example*:`.
+- Use a subheading `## Examples`.
-*Example*:
+All examples should be tested if possible using [`shell_docs:test/2`](../lib/stdlib/src/shell_docs.erl).
+See [lists_SUITE:doctests/1](../lib/stdlib/test/lists_SUITE.erl) for an example
+on how to do that.
-````markdown
-The compiler gives a warning for some code fragments.
+##### Examples
-*Example*:
+````markdown
+The compiler gives a warning for some code fragments:
```erlang
-> erlc test.erl
+1> erlc test.erl
test.erl:3:6: Warning: variable 'Data' is unused
% 3| main(Data) ->
% | ^
@@ -281,6 +282,23 @@ test.erl:3:6: Warning: variable 'Data' is unused
````
+````markdown
+Searches the list of tuples `TupleList` for a tuple whose `N`th element compares
+equal to `Key`.
+
+Returns `Tuple` if such a tuple is found; otherwise, returns `false`.
+
+## Examples
+
+```erlang
+1> lists:keyfind(b, 1, [{a,10}, {b,20}, {c,30}]).
+{b,20}
+2> lists:keyfind(unknown, 1, [{a,10}, {b,20}, {c,30}]).
+false
+```
+""".
+````
+
#### Headings
Use capital letters at the beginning of each word, except for small
--
2.43.0