Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function rand() and some others sometimes don't appear in the API on the website #1397

Open
Pieter12345 opened this issue Feb 20, 2025 · 4 comments

Comments

@Pieter12345
Copy link
Contributor

Pieter12345 commented Feb 20, 2025

Function: https://github.com/EngineHub/CommandHelper/blob/master/src/main/java/com/laytonsmith/core/functions/Math.java#L1118-L1120

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.

@PseudoKnight
Copy link
Contributor

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.

@Pieter12345
Copy link
Contributor Author

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 &amp;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 &amp;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>)

@Pieter12345
Copy link
Contributor Author

Pieter12345 commented Mar 12, 2025

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.

@Pieter12345 Pieter12345 changed the title Function rand() does not appear in the API on the website Function rand() and some others sometimes don't appear in the API on the website Mar 12, 2025
@PseudoKnight
Copy link
Contributor

PseudoKnight commented Mar 13, 2025

This is because of the LLVM functions by the same name. Presumably when the set of functionClasses is compared by name in SiteDeploy, they're considered equal and one is dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants