Skip to content

Commit 3188865

Browse files
docs: document the use of slicing as an alternative to std.substr
Fixes #782
1 parent 0b2daa7 commit 3188865

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

doc/_stdlib_gen/stdlib-content.jsonnet

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,18 @@ local exampleDocMultiline(mid, ex) =
217217
name: 'substr',
218218
params: ['str', 'from', 'len'],
219219
availableSince: '0.10.0',
220-
description: |||
221-
Returns a string that is the part of <code>s</code> that starts at offset <code>from</code>
222-
and is <code>len</code> codepoints long. If the string <code>s</code> is shorter than
223-
<code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
224-
|||,
220+
description: html.paragraphs([
221+
|||
222+
Returns a string that is the part of <code>s</code> that starts at offset <code>from</code>
223+
and is <code>len</code> codepoints long. If the string <code>s</code> is shorter than
224+
<code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
225+
|||,
226+
|||
227+
The slice operator (e.g., <code>s[from:to]</code>) can also be used on strings, as an alternative
228+
to this function. However, note that the slice operator takes a start and an end index, but
229+
<code>std.substr</code> takes a start index and a length.
230+
|||,
231+
]),
225232
},
226233
{
227234
name: 'findSubstr',

doc/ref/stdlib.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ <h4 id="substr">
467467
and is <code>len</code> codepoints long. If the string <code>s</code> is shorter than
468468
<code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
469469
</p>
470+
<p>
471+
The slice operator (e.g., <code>s[from:to]</code>) can also be used on strings, as an alternative
472+
to this function. However, note that the slice operator takes a start and an end index, but
473+
<code>std.substr</code> takes a start index and a length.
474+
</p>
470475

471476
</div>
472477
<div style="clear: both"></div>

0 commit comments

Comments
 (0)