
Function rand() and some others sometimes don't appear in the API on the website
Pieter12345 opened this issue ยท 4 comments
Usage of rand()
seems to work as intended and reflect_docs('rand', 'description')
results in
Returns a random number from 0 to max or min to max, depending on usage. Max is exclusive. Min must be less than max. This will return an integer. If no arguments are given, a random double from 0.0 to 1.0 (exclusive) will be returned.
as expected.
The rand()
function does have its own API page that works: https://methodscript.com/docs/3.3.5/API/functions/rand.html
I'm expecting this to be a bug in the API webpage generation code, which might affect other functions as well.
We've seen seen something like this before. I think it can even be random, funnily enough, as seemingly unrelated changes brought back the rand() in the API list during the next site deploy. I still went through and fixed some errors during site-deploy, though. We just have to occasionally check the logs for that task in the azure pipelines.
We've seen seen something like this before. I think it can even be random, funnily enough, as seemingly unrelated changes brought back the rand() in the API list during the next site deploy. I still went through and fixed some errors during site-deploy, though. We just have to occasionally check the logs for that task in the azure pipelines.
I still had a browser tab open with the API. I'm expecting this to go wrong at an earlier point, but I'm including the HTML part around rand()
or where it should be anyways for reference.
API HTML without rand()
:
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/postinc.html">postinc</a>()</td><td> ivar</td><td> var, <strong>[</strong>x<strong>]</strong></td><td> CastException</td><td>
Adds x to var, and stores the new value. Equivalent to var++ in other
languages. Expects ivar to be a variable, then returns a copy of the old
ivar, or, if var is a constant number, simply adds x to it, and returns
the new number. Operator notation is also supported: @var++<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/postinc.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/pow.html">pow</a>()</td><td> double</td><td> x, n</td><td> CastException</td><td> Returns x to the power of n. Operator syntax is also supported: @x ** @n<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/pow.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/round.html">round</a>()</td><td> double</td><td> number, <strong>[</strong>precision<strong>]</strong></td><td> CastException<br>RangeException</td><td>
Unlike floor and ceil, rounds the number to the nearest double that is
equal to an integer. Precision defaults to 0, but if set to 1 or more,
rounds decimal places. For instance, round(2.29, 1) would return 2.3. If
precision is &lt; 0, a RangeException is thrown.<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/round.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/round15.html">round15</a>()</td><td> double</td><td> value</td><td> CastException</td><td>
Rounds value to the 15th place. This is useful when doing math using
approximations. For instance, sin(math_const('PI')) returns
1.2246467991473532E-16, but sin of pi is actually 0. This happens
because pi cannot be accurately represented on a computer, it is an
approximation. Using round15, you can round to the next nearest value,
which often time should give a more useful answer to display. For
instance, round15(sin(math_const('PI'))) is 0. This functionality is not
provided by default in methods like sin(), because it technically makes
the result less accurate, given the inputs. In general, you should only
use this function just before displaying the value to the user.
Internally, you should keep the value returned by the input functions.<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/round15.html#Examples">Examples...</a>)
API HTML with rand()
:
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/postinc.html">postinc</a>()</td><td> ivar</td><td> var, <strong>[</strong>x<strong>]</strong></td><td> CastException</td><td>
Adds x to var, and stores the new value. Equivalent to var++ in other
languages. Expects ivar to be a variable, then returns a copy of the old
ivar, or, if var is a constant number, simply adds x to it, and returns
the new number. Operator notation is also supported: @var++<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/postinc.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/pow.html">pow</a>()</td><td> double</td><td> x, n</td><td> CastException</td><td> Returns x to the power of n. Operator syntax is also supported: @x ** @n<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/pow.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/rand.html">rand</a>()</td><td> mixed</td><td> <strong>[</strong><strong>]</strong> <hr> min/max, <strong>[</strong>max<strong>]</strong></td><td> RangeException<br>CastException</td><td>
Returns a random number from 0 to max or min to max, depending on
usage. Max is exclusive. Min must be less than max. This will return an
integer. If no arguments are given, a random double from 0.0 to 1.0
(exclusive) will be returned.<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/rand.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/round.html">round</a>()</td><td> double</td><td> number, <strong>[</strong>precision<strong>]</strong></td><td> CastException<br>RangeException</td><td>
Unlike floor and ceil, rounds the number to the nearest double that is
equal to an integer. Precision defaults to 0, but if set to 1 or more,
rounds decimal places. For instance, round(2.29, 1) would return 2.3. If
precision is &lt; 0, a RangeException is thrown.<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/round.html#Examples">Examples...</a>)
<p></p></td><td> <span class="api_no">No</span></td></tr><tr><td> <a href="https://methodscript.com/docs/3.3.5/API/functions/round15.html">round15</a>()</td><td> double</td><td> value</td><td> CastException</td><td>
Rounds value to the 15th place. This is useful when doing math using
approximations. For instance, sin(math_const('PI')) returns
1.2246467991473532E-16, but sin of pi is actually 0. This happens
because pi cannot be accurately represented on a computer, it is an
approximation. Using round15, you can round to the next nearest value,
which often time should give a more useful answer to display. For
instance, round15(sin(math_const('PI'))) is 0. This functionality is not
provided by default in methods like sin(), because it technically makes
the result less accurate, given the inputs. In general, you should only
use this function just before displaying the value to the user.
Internally, you should keep the value returned by the input functions.<br>(<a href="https://methodscript.com/docs/3.3.5/API/functions/round15.html#Examples">Examples...</a>)
In my still loaded API page, assign()
, noop()
, exit()
and sys_out()
are also missing. This has returned in the newly generated API page without obvious changes in sourcecode that could have caused this.