From 51d262af12ddeb4db255f14a1592fdc7840e196d Mon Sep 17 00:00:00 2001 From: Naveen Albert <asterisk@phreaknet.org> Date: Wed, 1 Jun 2022 01:43:52 +0000 Subject: [PATCH] xmldocs: Improve examples. Use example tags instead of regular para tags where possible. ASTERISK-30090 Change-Id: Iada8bbfda08f30b118cedf2d040bbb21e4966ec5 --- apps/app_confbridge.c | 26 +++++---- funcs/func_cdr.c | 4 +- funcs/func_dialgroup.c | 9 +-- funcs/func_env.c | 89 ++++++++++++++++------------- funcs/func_frame_drop.c | 12 +++- funcs/func_frame_trace.c | 12 +++- funcs/func_math.c | 25 ++++++--- funcs/func_odbc.c | 8 ++- funcs/func_periodic_hook.c | 18 +++--- funcs/func_pitchshift.c | 33 ++++++++--- funcs/func_rand.c | 5 +- funcs/func_sha1.c | 8 ++- funcs/func_shell.c | 4 +- funcs/func_speex.c | 14 +++-- funcs/func_strings.c | 72 ++++++++++++++++-------- funcs/func_talkdetect.c | 24 +++++--- funcs/func_version.c | 9 +-- funcs/func_vmcount.c | 4 +- funcs/func_volume.c | 23 ++++++-- res/res_calendar.c | 4 +- res/res_mutestream.c | 17 +++--- res/res_pjsip_config_wizard.c | 74 ++++++++++++------------ res/res_pjsip_header_funcs.c | 102 ++++++++++++++++------------------ 23 files changed, 353 insertions(+), 243 deletions(-) diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index ae17bcab6f..9b3ddba836 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -198,23 +198,29 @@ <para>---- Example 1 ----</para> <para>In this example the custom user profile set on the channel will automatically be used by the ConfBridge application.</para> - <para>exten => 1,1,Answer()</para> + <example title="Example 1"> + exten => 1,1,Answer() + </example> <para>; In this example the effect of the following line is</para> <para>; implied:</para> - <para>; same => n,Set(CONFBRIDGE(user,template)=default_user)</para> - <para>same => n,Set(CONFBRIDGE(user,announce_join_leave)=yes)</para> - <para>same => n,Set(CONFBRIDGE(user,startmuted)=yes)</para> - <para>same => n,ConfBridge(1) </para> + <example title="Example 1b"> + same => n,Set(CONFBRIDGE(user,template)=default_user) + same => n,Set(CONFBRIDGE(user,announce_join_leave)=yes) + same => n,Set(CONFBRIDGE(user,startmuted)=yes) + same => n,ConfBridge(1) + </example> <para>---- Example 2 ----</para> <para>This example shows how to use a predefined user profile in <filename>confbridge.conf</filename> as a template for a dynamic profile. Here we make an admin/marked user out of the <literal>my_user</literal> profile that you define in <filename>confbridge.conf</filename>.</para> - <para>exten => 1,1,Answer()</para> - <para>same => n,Set(CONFBRIDGE(user,template)=my_user)</para> - <para>same => n,Set(CONFBRIDGE(user,admin)=yes)</para> - <para>same => n,Set(CONFBRIDGE(user,marked)=yes)</para> - <para>same => n,ConfBridge(1)</para> + <example title="Example 2"> + exten => 1,1,Answer() + same => n,Set(CONFBRIDGE(user,template)=my_user) + same => n,Set(CONFBRIDGE(user,admin)=yes) + same => n,Set(CONFBRIDGE(user,marked)=yes) + same => n,ConfBridge(1) + </example> </description> </function> <function name="CONFBRIDGE_INFO" language="en_US"> diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index d7bc211452..2c6e2e1018 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -161,7 +161,9 @@ <note><para>CDRs can only be modified before the bridge between two channels is torn down. For example, CDRs may not be modified after the <literal>Dial</literal> application has returned.</para></note> - <para>Example: exten => 1,1,Set(CDR(userfield)=test)</para> + <example title="Set the userfield"> + exten => 1,1,Set(CDR(userfield)=test) + </example> </description> </function> <function name="CDR_PROP" language="en_US"> diff --git a/funcs/func_dialgroup.c b/funcs/func_dialgroup.c index 9a98b3ca24..64aa65882e 100644 --- a/funcs/func_dialgroup.c +++ b/funcs/func_dialgroup.c @@ -67,10 +67,11 @@ fallback to a queue when the front line people are busy or unavailable, but you still want front line people to log in and out of that group, just like a queue.</para> - <para>Example:</para> - <para>exten => 1,1,Set(DIALGROUP(mygroup,add)=SIP/10)</para> - <para>exten => 1,n,Set(DIALGROUP(mygroup,add)=SIP/20)</para> - <para>exten => 1,n,Dial(${DIALGROUP(mygroup)})</para> + <example title="Add 2 endpoints to a dial group"> + exten => 1,1,Set(DIALGROUP(mygroup,add)=SIP/10) + same => n,Set(DIALGROUP(mygroup,add)=SIP/20) + same => n,Dial(${DIALGROUP(mygroup)}) + </example> </description> </function> ***/ diff --git a/funcs/func_env.c b/funcs/func_env.c index 26025002ec..aba753352e 100644 --- a/funcs/func_env.c +++ b/funcs/func_env.c @@ -178,48 +178,61 @@ <description> <para>Read and write text file in character and line mode.</para> <para>Examples:</para> - <para/> <para>Read mode (byte):</para> - <para> ;reads the entire content of the file.</para> - <para> Set(foo=${FILE(/tmp/test.txt)})</para> - <para> ;reads from the 11th byte to the end of the file (i.e. skips the first 10).</para> - <para> Set(foo=${FILE(/tmp/test.txt,10)})</para> - <para> ;reads from the 11th to 20th byte in the file (i.e. skip the first 10, then read 10 bytes).</para> - <para> Set(foo=${FILE(/tmp/test.txt,10,10)})</para> - <para/> + <example title="Reads the entire content of the file"> + same => n,Set(foo=${FILE(/tmp/test.txt)}) + </example> + <example title="Reads from the 11th byte to the end of the file (i.e. skips the first 10)"> + same => n,Set(foo=${FILE(/tmp/test.txt,10)}) + </example> + <example title="Reads from the 11th to 20th byte in the file (i.e. skip the first 10, then read 10 bytes)"> + same => n,Set(foo=${FILE(/tmp/test.txt,10,10)}) + </example> <para>Read mode (line):</para> - <para> ; reads the 3rd line of the file.</para> - <para> Set(foo=${FILE(/tmp/test.txt,3,1,l)})</para> - <para> ; reads the 3rd and 4th lines of the file.</para> - <para> Set(foo=${FILE(/tmp/test.txt,3,2,l)})</para> - <para> ; reads from the third line to the end of the file.</para> - <para> Set(foo=${FILE(/tmp/test.txt,3,,l)})</para> - <para> ; reads the last three lines of the file.</para> - <para> Set(foo=${FILE(/tmp/test.txt,-3,,l)})</para> - <para> ; reads the 3rd line of a DOS-formatted file.</para> - <para> Set(foo=${FILE(/tmp/test.txt,3,1,l,d)})</para> - <para/> + <example title="Reads the 3rd line of the file"> + same => n,Set(foo=${FILE(/tmp/test.txt,3,1,l)}) + </example> + <example title="Reads the 3rd and 4th lines of the file"> + same => n,Set(foo=${FILE(/tmp/test.txt,3,2,l)}) + </example> + <example title="Reads from the third line to the end of the file"> + same => n,Set(foo=${FILE(/tmp/test.txt,3,,l)}) + </example> + <example title="Reads the last three lines of the file"> + same => n,Set(foo=${FILE(/tmp/test.txt,-3,,l)}) + </example> + <example title="Reads the 3rd line of a DOS-formatted file"> + same => n,Set(foo=${FILE(/tmp/test.txt,3,1,l,d)}) + </example> <para>Write mode (byte):</para> - <para> ; truncate the file and write "bar"</para> - <para> Set(FILE(/tmp/test.txt)=bar)</para> - <para> ; Append "bar"</para> - <para> Set(FILE(/tmp/test.txt,,,a)=bar)</para> - <para> ; Replace the first byte with "bar" (replaces 1 character with 3)</para> - <para> Set(FILE(/tmp/test.txt,0,1)=bar)</para> - <para> ; Replace 10 bytes beginning at the 21st byte of the file with "bar"</para> - <para> Set(FILE(/tmp/test.txt,20,10)=bar)</para> - <para> ; Replace all bytes from the 21st with "bar"</para> - <para> Set(FILE(/tmp/test.txt,20)=bar)</para> - <para> ; Insert "bar" after the 4th character</para> - <para> Set(FILE(/tmp/test.txt,4,0)=bar)</para> - <para/> + <example title="Truncate the file and write bar"> + same => n,Set(FILE(/tmp/test.txt)=bar) + </example> + <example title="Append bar"> + same => n,Set(FILE(/tmp/test.txt,,,a)=bar) + </example> + <example title="Replace the first byte with bar (replaces 1 character with 3)"> + same => n,Set(FILE(/tmp/test.txt,0,1)=bar) + </example> + <example title="Replace 10 bytes beginning at the 21st byte of the file with bar"> + same => n,Set(FILE(/tmp/test.txt,20,10)=bar) + </example> + <example title="Replace all bytes from the 21st with bar"> + same => n,Set(FILE(/tmp/test.txt,20)=bar) + </example> + <example title="Insert bar after the 4th character"> + same => n,Set(FILE(/tmp/test.txt,4,0)=bar) + </example> <para>Write mode (line):</para> - <para> ; Replace the first line of the file with "bar"</para> - <para> Set(FILE(/tmp/foo.txt,0,1,l)=bar)</para> - <para> ; Replace the last line of the file with "bar"</para> - <para> Set(FILE(/tmp/foo.txt,-1,,l)=bar)</para> - <para> ; Append "bar" to the file with a newline</para> - <para> Set(FILE(/tmp/foo.txt,,,al)=bar)</para> + <example title="Replace the first line of the file with bar"> + same => n,Set(FILE(/tmp/foo.txt,0,1,l)=bar) + </example> + <example title="Replace the last line of the file with bar"> + same => n,Set(FILE(/tmp/foo.txt,-1,,l)=bar) + </example> + <example title="Append bar to the file with a newline"> + same => n,Set(FILE(/tmp/foo.txt,,,al)=bar) + </example> <note> <para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal> is set to <literal>no</literal>, this function can only be executed from the diff --git a/funcs/func_frame_drop.c b/funcs/func_frame_drop.c index f5d70f322a..522685cbd0 100644 --- a/funcs/func_frame_drop.c +++ b/funcs/func_frame_drop.c @@ -91,9 +91,15 @@ </syntax> <description> <para>Examples:</para> - <para>exten => 1,1,Set(FRAME_DROP(TX)=DTMF_BEGIN,DTMF_END); drop only DTMF frames towards this channel.</para> - <para>exten => 1,1,Set(FRAME_DROP(TX)=ANSWER); drop only ANSWER CONTROL frames towards this channel.</para> - <para>exten => 1,1,Set(FRAME_DROP(RX)=DTMF_BEGIN,DTMF_END); drop only DTMF frames received on this channel.</para> + <example title="Drop only DTMF frames towards this channel"> + exten => 1,1,Set(FRAME_DROP(TX)=DTMF_BEGIN,DTMF_END) + </example> + <example title="Drop only Answer control frames towards this channel"> + exten => 1,1,Set(FRAME_DROP(TX)=ANSWER) + </example> + <example title="Drop only DTMF frames received on this channel"> + exten => 1,1,Set(FRAME_DROP(RX)=DTMF_BEGIN,DTMF_END) + </example> </description> </function> ***/ diff --git a/funcs/func_frame_trace.c b/funcs/func_frame_trace.c index b62bae9dee..b023c9f41d 100644 --- a/funcs/func_frame_trace.c +++ b/funcs/func_frame_trace.c @@ -69,9 +69,15 @@ </syntax> <description> <para>Examples:</para> - <para>exten => 1,1,Set(FRAME_TRACE(white)=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para> - <para>exten => 1,1,Set(FRAME_TRACE()=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para> - <para>exten => 1,1,Set(FRAME_TRACE(black)=DTMF_BEGIN,DTMF_END); view everything except DTMF frames. </para> + <example title="View only DTMF frames"> + exten => 1,1,Set(FRAME_TRACE(white)=DTMF_BEGIN,DTMF_END) + </example> + <example title="View only DTMF frames"> + exten => 1,1,Set(FRAME_TRACE()=DTMF_BEGIN,DTMF_END) + </example> + <example title="View everything except DTMF frames"> + exten => 1,1,Set(FRAME_TRACE(black)=DTMF_BEGIN,DTMF_END) + </example> </description> </function> ***/ diff --git a/funcs/func_math.c b/funcs/func_math.c index c5c30e4b6e..c3bc71fbf4 100644 --- a/funcs/func_math.c +++ b/funcs/func_math.c @@ -71,7 +71,9 @@ <description> <para>Performs mathematical functions based on two parameters and an operator. The returned value type is <replaceable>type</replaceable></para> - <para>Example: Set(i=${MATH(123%16,int)}) - sets var i=11</para> + <example title="Sets var i to 11"> + same => n,Set(i=${MATH(123%16,int)}) + </example> </description> </function> <function name="INC" language="en_US"> @@ -104,8 +106,10 @@ </syntax> <description> <para>Decrements the value of a variable, while returning the updated value to the dialplan</para> - <para>Example: DEC(MyVAR) - Decrements MyVar</para> - <para>Note: DEC(${MyVAR}) - Is wrong, as DEC expects the variable name, not its value</para> + <example title="Decrements MyVAR"> + same => n,NoOp(${DEC(MyVAR)}) + </example> + <note><para>DEC(${MyVAR}) is wrong, as DEC expects the variable name, not its value</para></note> </description> </function> <function name="MIN" language="en_US"> @@ -123,8 +127,9 @@ </syntax> <description> <para>Returns the minimum of two numbers <replaceable>num1</replaceable> and <replaceable>num2</replaceable>.</para> - <para>Example: Set(min=${MIN(7,4)}); - Sets the min variable equal to 4.</para> + <example title="Sets the min variable equal to 4"> + same => n,Set(min=${MIN(7,4)}) + </example> </description> </function> <function name="MAX" language="en_US"> @@ -142,8 +147,9 @@ </syntax> <description> <para>Returns the maximum of two numbers <replaceable>num1</replaceable> and <replaceable>num2</replaceable>.</para> - <para>Example: Set(max=${MAX(4,7)}); - Sets the max variable equal to 7.</para> + <example title="Sets the max variable equal to 13"> + same => n,Set(max=${MAX(4,7)}) + </example> </description> </function> <function name="ABS" language="en_US"> @@ -160,8 +166,9 @@ </syntax> <description> <para>Returns the absolute value of a number <replaceable>num</replaceable>.</para> - <para>Example: Set(absval=${ABS(-13)}); - Sets the absval variable equal to 13.</para> + <example title="Sets the absval variable equal to 13"> + same => n,Set(absval=${ABS(-13)}) + </example> </description> </function> ***/ diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index 7e4e6a3bb7..43c4a0c6a5 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -93,7 +93,9 @@ <description> <para>Used in SQL templates to escape data which may contain single ticks <literal>'</literal> which are otherwise used to delimit data.</para> - <para>Example: SELECT foo FROM bar WHERE baz='${SQL_ESC(${ARG1})}'</para> + <example title="Escape example"> + SELECT foo FROM bar WHERE baz='${SQL_ESC(${ARG1})}' + </example> </description> </function> <function name="SQL_ESC_BACKSLASHES" language="en_US"> @@ -106,7 +108,9 @@ <description> <para>Used in SQL templates to escape data which may contain backslashes <literal>\</literal> which are otherwise used to escape data.</para> - <para>Example: SELECT foo FROM bar WHERE baz='${SQL_ESC(${SQL_ESC_BACKSLASHES(${ARG1})})}'</para> + <example title="Escape with backslashes example"> + SELECT foo FROM bar WHERE baz='${SQL_ESC(${SQL_ESC_BACKSLASHES(${ARG1})})}' + </example> </description> </function> ***/ diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c index 6b90ee3b83..3c7b93e6a7 100644 --- a/funcs/func_periodic_hook.c +++ b/funcs/func_periodic_hook.c @@ -67,15 +67,15 @@ <para>For example, you could use this function to enable playing a periodic <literal>beep</literal> sound in a call.</para> <para/> - <para>To turn on:</para> - <para> Set(BEEPID=${PERIODIC_HOOK(hooks,beep,180)})</para> - <para/> - <para>To turn off:</para> - <para> Set(PERIODIC_HOOK(${BEEPID})=off)</para> - <para/> - <para>To turn back on again later:</para> - <para>Set(PERIODIC_HOOK(${BEEPID})=on)</para> - <para/> + <example title="To turn on"> + same => n,Set(BEEPID=${PERIODIC_HOOK(hooks,beep,180)}) + </example> + <example title="To turn off"> + same => n,Set(PERIODIC_HOOK(${BEEPID})=off) + </example> + <example title="To turn back on again later"> + same => n,Set(PERIODIC_HOOK(${BEEPID})=on) + </example> <para>It is important to note that the hook does not actually run on the channel itself. It runs asynchronously on a new channel. Any audio generated by the hook gets injected into the call for diff --git a/funcs/func_pitchshift.c b/funcs/func_pitchshift.c index 779f064e72..4057ed9c87 100644 --- a/funcs/func_pitchshift.c +++ b/funcs/func_pitchshift.c @@ -97,15 +97,30 @@ </syntax> <description> <para>Examples:</para> - <para>exten => 1,1,Set(PITCH_SHIFT(tx)=highest); raises pitch an octave </para> - <para>exten => 1,1,Set(PITCH_SHIFT(rx)=higher) ; raises pitch more </para> - <para>exten => 1,1,Set(PITCH_SHIFT(both)=high) ; raises pitch </para> - <para>exten => 1,1,Set(PITCH_SHIFT(rx)=low) ; lowers pitch </para> - <para>exten => 1,1,Set(PITCH_SHIFT(tx)=lower) ; lowers pitch more </para> - <para>exten => 1,1,Set(PITCH_SHIFT(both)=lowest) ; lowers pitch an octave </para> - - <para>exten => 1,1,Set(PITCH_SHIFT(rx)=0.8) ; lowers pitch </para> - <para>exten => 1,1,Set(PITCH_SHIFT(tx)=1.5) ; raises pitch </para> + <example title="Raises pitch an octave"> + exten => 1,1,Set(PITCH_SHIFT(tx)=highest) + </example> + <example title="Raises pitch more"> + exten => 1,1,Set(PITCH_SHIFT(rx)=higher) + </example> + <example title="Raises pitch"> + exten => 1,1,Set(PITCH_SHIFT(both)=high) + </example> + <example title="Lowers pitch"> + exten => 1,1,Set(PITCH_SHIFT(rx)=low) + </example> + <example title="Lowers pitch more"> + exten => 1,1,Set(PITCH_SHIFT(tx)=lower) + </example> + <example title="Lowers pitch an octave"> + exten => 1,1,Set(PITCH_SHIFT(both)=lowest) + </example> + <example title="Lowers pitch"> + exten => 1,1,Set(PITCH_SHIFT(rx)=0.8) + </example> + <example title="Raises pitch"> + exten => 1,1,Set(PITCH_SHIFT(tx)=1.5) + </example> </description> </function> ***/ diff --git a/funcs/func_rand.c b/funcs/func_rand.c index bf208e9e23..2b70ba3443 100644 --- a/funcs/func_rand.c +++ b/funcs/func_rand.c @@ -49,8 +49,9 @@ <para>Choose a random number between <replaceable>min</replaceable> and <replaceable>max</replaceable>. <replaceable>min</replaceable> defaults to <literal>0</literal>, if not specified, while <replaceable>max</replaceable> defaults to <literal>RAND_MAX</literal> (2147483647 on many systems).</para> - <para>Example: Set(junky=${RAND(1,8)}); - Sets junky to a random number between 1 and 8, inclusive.</para> + <example title="Set random number between 1 and 8, inclusive"> + exten => s,1,Set(junky=${RAND(1,8)}) + </example> </description> </function> ***/ diff --git a/funcs/func_sha1.c b/funcs/func_sha1.c index 6c96ecd059..11685b2f24 100644 --- a/funcs/func_sha1.c +++ b/funcs/func_sha1.c @@ -45,9 +45,11 @@ </syntax> <description> <para>Generate a SHA1 digest via the SHA1 algorythm.</para> - <para>Example: Set(sha1hash=${SHA1(junky)})</para> - <para>Sets the asterisk variable sha1hash to the string <literal>60fa5675b9303eb62f99a9cd47f9f5837d18f9a0</literal> - which is known as his hash</para> + <example title="Set sha1hash variable to SHA1 hash of junky"> + exten => s,1,Set(sha1hash=${SHA1(junky)}) + </example> + <para>The example above sets the asterisk variable sha1hash to the string <literal>60fa5675b9303eb62f99a9cd47f9f5837d18f9a0</literal> + which is known as its hash</para> </description> </function> ***/ diff --git a/funcs/func_shell.c b/funcs/func_shell.c index fe1debe884..c8c2187180 100644 --- a/funcs/func_shell.c +++ b/funcs/func_shell.c @@ -91,7 +91,9 @@ static int shell_helper(struct ast_channel *chan, const char *cmd, char *data, </syntax> <description> <para>Collects the output generated by a command executed by the system shell</para> - <para>Example: <literal>Set(foo=${SHELL(echo bar)})</literal></para> + <example title="Shell example"> + exten => s,1,Set(foo=${SHELL(echo bar)}) + </example> <note> <para>The command supplied to this function will be executed by the system's shell, typically specified in the SHELL environment variable. There diff --git a/funcs/func_speex.c b/funcs/func_speex.c index 1a88fae7f3..7d05d6f43c 100644 --- a/funcs/func_speex.c +++ b/funcs/func_speex.c @@ -66,9 +66,10 @@ analog lines, but could be useful for other channels as well. The target volume is set with a number between <literal>1-32768</literal>. The larger the number the louder (more gain) the channel will receive.</para> - <para>Examples:</para> - <para>exten => 1,1,Set(AGC(rx)=8000)</para> - <para>exten => 1,2,Set(AGC(tx)=off)</para> + <example title="Apply automatic gain control"> + exten => 1,1,Set(AGC(rx)=8000) + exten => 1,2,Set(AGC(tx)=off) + </example> </description> </function> <function name="DENOISE" language="en_US"> @@ -87,9 +88,10 @@ that it is executed on. It is very useful for noisy analog lines, especially when adjusting gains or using AGC. Use <literal>rx</literal> for audio received from the channel and <literal>tx</literal> to apply the filter to the audio being sent to the channel.</para> - <para>Examples:</para> - <para>exten => 1,1,Set(DENOISE(rx)=on)</para> - <para>exten => 1,2,Set(DENOISE(tx)=off)</para> + <example title="Apply noise reduction"> + exten => 1,1,Set(DENOISE(rx)=on) + exten => 1,2,Set(DENOISE(tx)=off) + </example> </description> </function> ***/ diff --git a/funcs/func_strings.c b/funcs/func_strings.c index 3eed847d54..77cdc99f28 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -62,7 +62,10 @@ AST_THREADSTORAGE(tmp_buf); carriage return, and tab characters, respectively. Also, octal and hexadecimal specifications are recognized by the patterns <literal>\0nnn</literal> and <literal>\xHH</literal>, respectively. For example, if you wanted to encode a comma as the delimiter, you could use either <literal>\054</literal> or <literal>\x2C</literal>.</para> - <para>Example: If ${example} contains <literal>ex-amp-le</literal>, then ${FIELDQTY(example,-)} returns 3.</para> + <example title="Prints 3"> + exten => s,1,Set(example=ex-amp-le) + same => n,NoOp(${FIELDQTY(example,-)}) + </example> </description> </function> <function name="FIELDNUM" language="en_US"> @@ -83,7 +86,10 @@ AST_THREADSTORAGE(tmp_buf); carriage return, and tab characters, respectively. Also, octal and hexadecimal specifications are recognized by the patterns <literal>\0nnn</literal> and <literal>\xHH</literal>, respectively. For example, if you wanted to encode a comma as the delimiter, you could use either <literal>\054</literal> or <literal>\x2C</literal>.</para> - <para>Example: If ${example} contains <literal>ex-amp-le</literal>, then ${FIELDNUM(example,-,amp)} returns 2.</para> + <example title="Prints 2"> + exten => s,1,Set(example=ex-amp-le) + same => n,NoOp(${FIELDNUM(example,-,amp)}) + </example> </description> </function> <function name="LISTFILTER" language="en_US"> @@ -190,8 +196,10 @@ AST_THREADSTORAGE(tmp_buf); string, instead.</para> <note><para>The functions which take a variable name need to be passed var and not ${var}. Similarly, use PASSTHRU() and not ${PASSTHRU()}.</para></note> - <para>Example: ${CHANNEL} contains SIP/321-1</para> - <para> ${CUT(PASSTHRU(${CUT(CHANNEL,-,1)}),/,2)}) will return 321</para> + <example title="Prints 321"> + exten => s,1,NoOp(${CHANNEL}) ; contains SIP/321-1 + same => n,NoOp(${CUT(PASSTHRU(${CUT(CHANNEL,-,1)}),/,2)}) + </example> </description> </function> <function name="REGEX" language="en_US"> @@ -257,7 +265,9 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="string" required="true" /> </syntax> <description> - <para>Example: ${KEYPADHASH(Les)} returns "537"</para> + <example title="Returns 537"> + exten => s,1,Return(${KEYPADHASH(Les)}) + </example> </description> </function> <function name="ARRAY" language="en_US"> @@ -273,7 +283,9 @@ AST_THREADSTORAGE(tmp_buf); <para>The comma-delimited list passed as a value to which the function is set will be interpreted as a set of values to which the comma-delimited list of variable names in the argument should be set.</para> - <para>Example: Set(ARRAY(var1,var2)=1,2) will set var1 to 1 and var2 to 2</para> + <example title="Set var1 to 1 and var2 to 2"> + same => n,Set(ARRAY(var1,var2)=1,2) + </example> </description> </function> <function name="STRPTIME" language="en_US"> @@ -289,7 +301,9 @@ AST_THREADSTORAGE(tmp_buf); <para>This is useful for converting a date into <literal>EPOCH</literal> time, possibly to pass to an application like SayUnixTime or to calculate the difference between the two date strings</para> - <para>Example: ${STRPTIME(2006-03-01 07:30:35,America/Chicago,%Y-%m-%d %H:%M:%S)} returns 1141219835</para> + <example title="Prints 1141219835"> + same => n,NoOp(${STRPTIME(2006-03-01 07:30:35,America/Chicago,%Y-%m-%d %H:%M:%S)}) + </example> </description> </function> <function name="STRFTIME" language="en_US"> @@ -343,7 +357,9 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="string" required="true" /> </syntax> <description> - <para>Example: ${TOUPPER(Example)} returns "EXAMPLE"</para> + <example title="Prints EXAMPLE"> + exten => s,1,NoOp(${TOUPPER(Example)}) + </example> </description> </function> <function name="TOLOWER" language="en_US"> @@ -354,7 +370,9 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="string" required="true" /> </syntax> <description> - <para>Example: ${TOLOWER(Example)} returns "example"</para> + <example title="Prints example"> + exten => s,1,NoOp(${TOLOWER(Example)}) + </example> </description> </function> <function name="LEN" language="en_US"> @@ -365,7 +383,9 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="string" required="true" /> </syntax> <description> - <para>Example: ${LEN(example)} returns 7</para> + <example title="Prints 7"> + exten => s,1,NoOp(${LEN(example)}) + </example> </description> </function> <function name="QUOTE" language="en_US"> @@ -399,11 +419,12 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="delimiter" required="false" default="," /> </syntax> <description> - <para>Example:</para> - <para>exten => s,1,Set(array=one,two,three)</para> - <para>exten => s,n,While($["${SET(var=${SHIFT(array)})}" != ""])</para> - <para>exten => s,n,NoOp(var is ${var})</para> - <para>exten => s,n,EndWhile</para> + <example title="SHIFT example"> + exten => s,1,Set(array=one,two,three) + exten => s,n,While($["${SET(var=${SHIFT(array)})}" != ""]) + exten => s,n,NoOp(var is ${var}) + exten => s,n,EndWhile + </example> <para>This would iterate over each value in array, left to right, and would result in NoOp(var is one), NoOp(var is two), and NoOp(var is three) being executed. @@ -419,11 +440,12 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="delimiter" required="false" default="," /> </syntax> <description> - <para>Example:</para> - <para>exten => s,1,Set(array=one,two,three)</para> - <para>exten => s,n,While($["${SET(var=${POP(array)})}" != ""])</para> - <para>exten => s,n,NoOp(var is ${var})</para> - <para>exten => s,n,EndWhile</para> + <example title="POP example"> + exten => s,1,Set(array=one,two,three) + exten => s,n,While($["${SET(var=${POP(array)})}" != ""]) + exten => s,n,NoOp(var is ${var}) + exten => s,n,EndWhile + </example> <para>This would iterate over each value in array, right to left, and would result in NoOp(var is three), NoOp(var is two), and NoOp(var is one) being executed. @@ -439,7 +461,10 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="delimiter" required="false" default="," /> </syntax> <description> - <para>Example: Set(PUSH(array)=one,two,three) would append one, + <example title="PUSH example"> + exten => s,1,Set(PUSH(array)=one,two,three) + </example> + <para>This would append one, two, and three to the end of the values stored in the variable "array". </para> @@ -454,7 +479,10 @@ AST_THREADSTORAGE(tmp_buf); <parameter name="delimiter" required="false" default="," /> </syntax> <description> - <para>Example: Set(UNSHIFT(array)=one,two,three) would insert one, + <example title="UNSHIFT example"> + exten => s,1,Set(UNSHIFT(array)=one,two,three) + </example> + <para>This would insert one, two, and three before the values stored in the variable "array". </para> diff --git a/funcs/func_talkdetect.c b/funcs/func_talkdetect.c index 88c470e8e3..257ecda8f3 100644 --- a/funcs/func_talkdetect.c +++ b/funcs/func_talkdetect.c @@ -103,11 +103,18 @@ natural speech.</para> <para>By default this value is 2500ms. Valid values are 1 through 2^31.</para> - <para>Example:</para> - <para>same => n,Set(TALK_DETECT(set)=) ; Enable talk detection</para> - <para>same => n,Set(TALK_DETECT(set)=1200) ; Update existing talk detection's silence threshold to 1200 ms</para> - <para>same => n,Set(TALK_DETECT(remove)=) ; Remove talk detection</para> - <para>same => n,Set(TALK_DETECT(set)=,128) ; Enable and set talk threshold to 128</para> + <example title="Enable talk detection"> + same => n,Set(TALK_DETECT(set)=) + </example> + <example title="Update existing talk detection's silence threshold to 1200 ms"> + same => n,Set(TALK_DETECT(set)=1200) + </example> + <example title="Remove talk detection"> + same => n,Set(TALK_DETECT(remove)=) + </example> + <example title="Enable and set talk threshold to 128"> + same => n,Set(TALK_DETECT(set)=,128) + </example> <para>This function will set the following variables:</para> <note> <para>The TALK_DETECT function uses an audiohook to inspect the @@ -117,10 +124,11 @@ it typically makes sense to place functions that modify the voice media data prior to placing the TALK_DETECT function, as this will yield better results.</para> - <para>Example:</para> - <para>same => n,Set(DENOISE(rx)=on) ; Denoise received audio</para> - <para>same => n,Set(TALK_DETECT(set)=) ; Perform talk detection on the denoised received audio</para> </note> + <example title="Denoise and then perform talk detection"> + same => n,Set(DENOISE(rx)=on) ; Denoise received audio + same => n,Set(TALK_DETECT(set)=) ; Perform talk detection on the denoised received audio + </example> </description> </function> ***/ diff --git a/funcs/func_version.c b/funcs/func_version.c index 01cb748454..baef884ac4 100644 --- a/funcs/func_version.c +++ b/funcs/func_version.c @@ -47,7 +47,7 @@ <enumlist> <enum name="ASTERISK_VERSION_NUM"> <para>A string of digits is returned, e.g. 10602 for 1.6.2 or 100300 for 10.3.0, - or 999999 when using an SVN build.</para> + or 999999 when using a Git build.</para> </enum> <enum name="BUILD_USER"> <para>The string representing the user's name whose account @@ -73,9 +73,10 @@ </parameter> </syntax> <description> - <para>If there are no arguments, return the version of Asterisk in this format: SVN-branch-1.4-r44830M</para> - <para>Example: Set(junky=${VERSION()};</para> - <para>Sets junky to the string <literal>SVN-branch-1.6-r74830M</literal>, or possibly, <literal>SVN-trunk-r45126M</literal>.</para> + <para>If there are no arguments, return the version of Asterisk in this format: 18.12.0</para> + <example title="Get current version"> + same => n,Set(junky=${VERSION()} ; sets junky to 18.12.0, or possibly GITMasterxxxxxx + </example> </description> </function> ***/ diff --git a/funcs/func_vmcount.c b/funcs/func_vmcount.c index 66007034a1..b6302ccbae 100644 --- a/funcs/func_vmcount.c +++ b/funcs/func_vmcount.c @@ -57,7 +57,9 @@ <description> <para>Count the number of voicemails in a specified mailbox, you could also specify the mailbox <replaceable>folder</replaceable>.</para> - <para>Example: <literal>exten => s,1,Set(foo=${VMCOUNT(125@default)})</literal></para> + <example title="Mailbox folder count"> + exten => s,1,Set(foo=${VMCOUNT(125@default)}) + </example> <para>An ampersand-separated list of mailboxes may be specified to count voicemails in multiple mailboxes. If a folder is specified, this will apply to all mailboxes specified.</para> <example title="Multiple mailbox inbox count"> diff --git a/funcs/func_volume.c b/funcs/func_volume.c index a20bb76042..93728728d6 100644 --- a/funcs/func_volume.c +++ b/funcs/func_volume.c @@ -59,11 +59,24 @@ <description> <para>The VOLUME function can be used to increase or decrease the <literal>tx</literal> or <literal>rx</literal> gain of any channel.</para> - <para>For example:</para> - <para>Set(VOLUME(TX)=3)</para> - <para>Set(VOLUME(RX)=2)</para> - <para>Set(VOLUME(TX,p)=3)</para> - <para>Set(VOLUME(RX,p)=3)</para> + <example title="Increase volume"> + same => n,Set(VOLUME(TX)=3) + </example> + <example title="Increase volume"> + same => n,Set(VOLUME(RX)=2) + </example> + <example title="Increase volume with DTMF control"> + same => n,Set(VOLUME(TX,p)=3) + </example> + <example title="Increase RX volume with DTMF control"> + same => n,Set(VOLUME(RX,p)=3) + </example> + <example title="Decrease RX volume"> + same => n,Set(VOLUME(RX)=-4) + </example> + <example title="Reset to normal"> + same => n,Set(VOLUME(RX)=0) + </example> </description> </function> ***/ diff --git a/res/res_calendar.c b/res/res_calendar.c index 98f9169347..4af1fde72b 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -193,7 +193,9 @@ </parameter> </syntax> <description> - <para>Example: CALENDAR_WRITE(calendar,field1,field2,field3)=val1,val2,val3</para> + <example title="Set calendar fields"> + same => n,Set(CALENDAR_WRITE(calendar,field1,field2,field3)=val1,val2,val3) + </example> <para>The field and value arguments can easily be set/passed using the HASHKEYS() and HASH() functions</para> <variablelist> <variable name="CALENDAR_SUCCESS"> diff --git a/res/res_mutestream.c b/res/res_mutestream.c index 8040a3ac9b..93c6d0a9d8 100644 --- a/res/res_mutestream.c +++ b/res/res_mutestream.c @@ -69,16 +69,13 @@ </parameter> </syntax> <description> - <para>The MUTEAUDIO function can be used to mute inbound (to the PBX) or outbound audio in a call. - </para> - <para>Examples: - </para> - <para> - MUTEAUDIO(in)=on - </para> - <para> - MUTEAUDIO(in)=off - </para> + <para>The MUTEAUDIO function can be used to mute inbound (to the PBX) or outbound audio in a call.</para> + <example title="Mute incoming audio"> + exten => s,1,Set(MUTEAUDIO(in)=on) + </example> + <example title="Do not mute incoming audio"> + exten => s,1,Set(MUTEAUDIO(in)=off) + </example> </description> </function> <manager name="MuteAudio" language="en_US"> diff --git a/res/res_pjsip_config_wizard.c b/res/res_pjsip_config_wizard.c index 4c1c59b0ca..59976b1584 100644 --- a/res/res_pjsip_config_wizard.c +++ b/res/res_pjsip_config_wizard.c @@ -65,25 +65,24 @@ endpoint, aor, contact, auth and phoneprov objects necessary for a phone to get phone provisioning information, register, and make and receive calls. A hint is also created in the default context for extension 1000.</para> - <para> </para> - - <para>[myphone]</para> - <para>type = wizard</para> - <para>sends_auth = no</para> - <para>accepts_auth = yes</para> - <para>sends_registrations = no</para> - <para>accepts_registrations = yes</para> - <para>has_phoneprov = yes</para> - <para>transport = ipv4</para> - <para>has_hint = yes</para> - <para>hint_exten = 1000</para> - <para>inbound_auth/username = testname</para> - <para>inbound_auth/password = test password</para> - <para>endpoint/allow = ulaw</para> - <para>endpoint/context = default</para> - <para>phoneprov/MAC = 001122aa4455</para> - <para>phoneprov/PROFILE = profile1</para> - <para> </para> + <example title="myphone"> + [myphone] + type = wizard + sends_auth = no + accepts_auth = yes + sends_registrations = no + accepts_registrations = yes + has_phoneprov = yes + transport = ipv4 + has_hint = yes + hint_exten = 1000 + inbound_auth/username = testname + inbound_auth/password = test password + endpoint/allow = ulaw + endpoint/context = default + phoneprov/MAC = 001122aa4455 + phoneprov/PROFILE = profile1 + </example> <para>The first 8 items are specific to the wizard. The rest of the items are passed verbatim to the underlying objects.</para> @@ -92,21 +91,20 @@ <para>The following configuration snippet would create the endpoint, aor, contact, auth, identify and registration objects necessary for a trunk to another pbx or ITSP that requires registration.</para> - <para> </para> - - <para>[mytrunk]</para> - <para>type = wizard</para> - <para>sends_auth = yes</para> - <para>accepts_auth = no</para> - <para>sends_registrations = yes</para> - <para>accepts_registrations = no</para> - <para>transport = ipv4</para> - <para>remote_hosts = sip1.myitsp.com:5060,sip2.myitsp.com:5060</para> - <para>outbound_auth/username = testname</para> - <para>outbound_auth/password = test password</para> - <para>endpoint/allow = ulaw</para> - <para>endpoint/context = default</para> - <para> </para> + <example title="mytrunk"> + [mytrunk] + type = wizard + sends_auth = yes + accepts_auth = no + sends_registrations = yes + accepts_registrations = no + transport = ipv4 + remote_hosts = sip1.myitsp.com:5060,sip2.myitsp.com:5060 + outbound_auth/username = testname + outbound_auth/password = test password + endpoint/allow = ulaw + endpoint/context = default + </example> <para>Of course, any of the items in either example could be placed into templates and shared among wizard objects.</para> @@ -227,10 +225,10 @@ <para> <literal>exten => <hint_exten>,1,<hint_application></literal></para> <para> </para> <para>You can specify any valid extensions.conf application expression.</para> - <para>Examples: </para> - <para> <literal>Dial(${HINT})</literal></para> - <para> <literal>Gosub(stdexten,${EXTEN},1(${HINT}))</literal></para> - <para> </para> + <example title="Valid expressions"> + Dial(${HINT}) + Gosub(stdexten,${EXTEN},1(${HINT})) + </example> <para>Any extensions.conf style variables specified are passed directly to the dialplan.</para> <para> </para> diff --git a/res/res_pjsip_header_funcs.c b/res/res_pjsip_header_funcs.c index ee941479d7..fa6db34a3f 100644 --- a/res/res_pjsip_header_funcs.c +++ b/res/res_pjsip_header_funcs.c @@ -84,65 +84,59 @@ channel. One exception is that you can read headers that you have already added on the outbound channel.</para> <para>Examples:</para> - <para>;</para> - <para>; Set 'somevar' to the value of the 'From' header.</para> - <para>exten => 1,1,Set(somevar=${PJSIP_HEADER(read,From)})</para> - <para>;</para> - <para>; Set 'via2' to the value of the 2nd 'Via' header.</para> - <para>exten => 1,1,Set(via2=${PJSIP_HEADER(read,Via,2)})</para> - <para>;</para> - <para>; Set 'xhdr' to the value of the 1sx X-header.</para> - <para>exten => 1,1,Set(xhdr=${PJSIP_HEADER(read,X-*,1)})</para> - <para>;</para> - <para>; Add an 'X-Myheader' header with the value of 'myvalue'.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)</para> - <para>;</para> - <para>; Add an 'X-Myheader' header with an empty value.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=)</para> - <para>;</para> - <para>; Update the value of the header named 'X-Myheader' to 'newvalue'.</para> - <para>; 'X-Myheader' must already exist or the call will fail.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(update,X-MyHeader)=newvalue)</para> - <para>;</para> - <para>; Remove all headers whose names exactly match 'X-MyHeader'.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)</para> - <para>;</para> - <para>; Remove all headers that begin with 'X-My'.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(remove,X-My*)=)</para> - <para>;</para> - <para>; Remove all previously added headers.</para> - <para>exten => 1,1,Set(PJSIP_HEADER(remove,*)=)</para> - <para>;</para> - + <example title="Set somevar to the value of the From header"> + exten => 1,1,Set(somevar=${PJSIP_HEADER(read,From)}) + </example> + <example title="Set via2 to the value of the 2nd Via header"> + exten => 1,1,Set(via2=${PJSIP_HEADER(read,Via,2)}) + </example> + <example title="Set xhdr to the value of the 1st X-header"> + exten => 1,1,Set(xhdr=${PJSIP_HEADER(read,X-*,1)}) + </example> + <example title="Add an X-Myheader header with the value of myvalue"> + exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue) + </example> + <example title="Add an X-Myheader header with an empty value"> + exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=) + </example> + <example title="Update the value of the header named X-Myheader to newvalue"> + ; 'X-Myheader' must already exist or the call will fail. + exten => 1,1,Set(PJSIP_HEADER(update,X-MyHeader)=newvalue) + </example> + <example title="Remove all headers whose names exactly match X-MyHeader"> + exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=) + </example> + <example title="Remove all headers that begin with X-My"> + exten => 1,1,Set(PJSIP_HEADER(remove,X-My*)=) + </example> + <example title="Remove all previously added headers"> + exten => 1,1,Set(PJSIP_HEADER(remove,*)=) + </example> <note><para>The <literal>remove</literal> action can be called by reading - <emphasis>or</emphasis> writing PJSIP_HEADER.</para> - <para>;</para> - <para>; Display the number of headers removed</para> - <para>exten => 1,1,Verbose( Removed ${PJSIP_HEADER(remove,X-MyHeader)} headers)</para> - <para>;</para> - <para>; Set a variable to the number of headers removed</para> - <para>exten => 1,1,Set(count=${PJSIP_HEADER(remove,X-MyHeader)})</para> - <para>;</para> - <para>; Just remove them ignoring any count</para> - <para>exten => 1,1,Set(=${PJSIP_HEADER(remove,X-MyHeader)})</para> - <para>exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)</para> - <para>;</para> - </note> + <emphasis>or</emphasis> writing PJSIP_HEADER.</para></note> + <example title="Display the number of headers removed"> + exten => 1,1,Verbose( Removed ${PJSIP_HEADER(remove,X-MyHeader)} headers) + </example> + <example title="Set a variable to the number of headers removed"> + exten => 1,1,Set(count=${PJSIP_HEADER(remove,X-MyHeader)}) + </example> + <example title="Just remove them ignoring any count"> + exten => 1,1,Set(=${PJSIP_HEADER(remove,X-MyHeader)}) + exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=) + </example> <note><para>If you call PJSIP_HEADER in a normal dialplan context you'll be operating on the <emphasis>caller's (incoming)</emphasis> channel which may not be what you want. To operate on the <emphasis>callee's (outgoing)</emphasis> - channel call PJSIP_HEADER in a pre-dial handler. </para> - <para>Example:</para> - <para>;</para> - <para>[handler]</para> - <para>exten => addheader,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)</para> - <para>exten => addheader,2,Set(PJSIP_HEADER(add,X-MyHeader2)=myvalue2)</para> - <para>;</para> - <para>[somecontext]</para> - <para>exten => 1,1,Dial(PJSIP/${EXTEN},,b(handler^addheader^1))</para> - <para>;</para> - </note> + channel call PJSIP_HEADER in a pre-dial handler. </para></note> + <example title="Set headers on callee channel"> + [handler] + exten => addheader,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue) + exten => addheader,2,Set(PJSIP_HEADER(add,X-MyHeader2)=myvalue2) + + [somecontext] + exten => 1,1,Dial(PJSIP/${EXTEN},,b(handler^addheader^1)) + </example> </description> </function> <function name="PJSIP_HEADERS" language="en_US"> -- GitLab