Skip to content

Commit

Permalink
Merge pull request #156 from Flipez/refactor-documentation-generator
Browse files Browse the repository at this point in the history
Co-authored-by: Flipez <[email protected]>

Refactor documentation generator
  • Loading branch information
Flipez committed Nov 25, 2022
2 parents 66153bc + 74525fe commit e580bee
Show file tree
Hide file tree
Showing 72 changed files with 1,859 additions and 1,594 deletions.
3 changes: 3 additions & 0 deletions docs/builtins/http.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
functions:
new:
description: "Creates a new instance of HTTP"
7 changes: 7 additions & 0 deletions docs/builtins/io.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
functions:
open:
description: "Opens a file pointer to the file at the path, mode and permission can be set optionally."
input: |
IO.open("main.go", "r", "0644")
output: |
<file:main.go>
9 changes: 9 additions & 0 deletions docs/builtins/json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
functions:
parse:
description: "Takes a STRING and parses it to a HASH or ARRAY. Numbers are always FLOAT."
input: |
JSON.parse('{"test": 123}')
JSON.parse('["test", 123]')
output: |
{"test": 123.0}
["test", 123.0]
123 changes: 123 additions & 0 deletions docs/builtins/math.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
functions:
abs:
description: ""
acos:
description: "Returns the arccosine, in radians, of the argument"
input: |
Math.acos(1.0)
output: |
0.0
asin:
description: "Returns the arcsine, in radians, of the argument"
input: |
Math.asin(0.0)
output: |
0.0
atan:
description: "Returns the arctangent, in radians, of the argument"
input: |
Math.atan(0.0)
output: |
0.0
ceil:
description: "Returns the least integer value greater or equal to the argument"
input: |
Math.ceil(1.49)
output: |
2.0
copysign:
description: "Returns a value with the magnitude of first argument and sign of second argument"
input: |
Math.copysign(3.2, -1.0)
output: |
-3.2
cos:
description: "Returns the cosine of the radion argument"
input: |
Math.cos(Pi/2)
output: |
0.0
exp:
description: "Returns e**argument, the base-e exponential of argument"
input: |
Math.exp(1.0)
output: |
2.72
floor:
description: "Returns the greatest integer value less than or equal to argument"
input: |
Math.floor(1.51)
output: |
1.0
log:
description: "Returns the natural logarithm of argument"
input: |
Math.log(2.7183)
output: |
1.0
log10:
description: "Returns the decimal logarithm of argument"
input: |
Math.log(100.0)
output: |
2.0
log2:
description: "Returns the binary logarithm of argument"
input: |
Math.log2(256.0)
output: |
8.0
max:
description: "Returns the larger of the two numbers"
input: |
Math.max(5.0, 10.0)
output: |
10.0
min:
description: "Returns the smaller of the two numbers"
input: |
Math.min(5.0, 10.0)
output: |
5.0
pow:
description: "Returns argument1**argument2, the base-argument1 exponential of argument2"
input: |
Math.pow(2.0, 3.0)
output: |
8.0
rand:
description: "Returns a pseudo-random number in the half-open interval [0.0, 1.0]."
input: |
Math.rand()
output: |
0.6046602879796196
remainder:
description: "Returns the IEEE 754 floating-point remainder of argument1/argument2"
input: |
Math.remainder(100.0, 30.0)
output: |
10.0
round:
description: "Returns the nearest integer, rounding half away from zero"
input: |
Math.round(73.3)
output: |
73.0
sin:
description: "Returns the sine of the radion argument"
input: |
Math.sin(Pi)
output: |
0.0
sqrt:
description: "Returns the square root of argument"
input: |
Math.sqrt(3.0 * 3.0 + 4.0 * 4.0)
output: |
5.0
tan:
description: "Returns the tangent of the radion argument"
input: |
Math.tan(0.0)
output: |
0.0
14 changes: 14 additions & 0 deletions docs/builtins/os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
functions:
exit:
description: "Terminates the program with the given exit code."
input: |
OS.exit(1)
output: |
exit status 1
raise:
description: "Terminates the program with the given exit code and prints the error message."
input: |
OS.raise(1, "broken")
output: |
🔥 RocketLang raised an error: "broken"
exit status 1
37 changes: 37 additions & 0 deletions docs/builtins/time.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
functions:
format:
description: |
Formats the given unix timestamp with the given layout
[Go date and time formats](https://gosamples.dev/date-time-format-cheatsheet/) are natively supported.
You can also use some but not all [formats present in many other languages](https://apidock.com/ruby/Time/strftime) which are not fully supported.
Take a look at [the source](https://github.com/Flipez/rocket-lang/blob/main/stdlib/time.go) to see which formatters are supported.
input: |
Time.format(Time.unix(), "Mon Jan _2 15:04:05 2006")
Time.format(Time.unix(), "%a %b %e %H:%M:%S %Y")
output: |
"Mon Oct 31 00:08:10 2022"
"Mon Oct 31 00:28:43 2022"
parse:
description: |
Parses a given string with the given format to a unix timestamp.
[Go date and time formats](https://gosamples.dev/date-time-format-cheatsheet/) are natively supported.
You can also use some but not all [formats present in many other languages](https://apidock.com/ruby/Time/strftime) which are not fully supported.
Take a look at [the source](https://github.com/Flipez/rocket-lang/blob/main/stdlib/time.go) to see which formatters are supported.
input: |
Time.parse("2022-03-23", "2006-01-02")
Time.parse("2022-03-23", "%Y-%m-%d")
output: |
1647993600
1647993600
sleep:
description: "Stops the RocketLang routine for at least the stated duration in seconds"
input: |
Time.sleep(2)
unix:
description: "Returns the current time as unix timestamp"
input: |
Time.unix()
output: |
1668788502
28 changes: 28 additions & 0 deletions docs/components/CodeBlockSimple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import CodeBlock from '@theme/CodeBlock';

class CodeBlockSimple extends React.Component {
constructor(props){
super(props);
}

render() {
return (
<div
style={{
backgroundColor: '#303846',
borderRadius: 5,
}}>
<CodeBlock language="js" showLineNumbers>
{this.props.input}
</CodeBlock>
{ this.props.output ? (
<CodeBlock language="js" title='Output'>
{this.props.output}
</CodeBlock>) : ("") }
</div>
);
}
}

export default CodeBlockSimple
5 changes: 5 additions & 0 deletions docs/docs/builtins/HTTP.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CodeBlockSimple from '@site/components/CodeBlockSimple'

# HTTP


Expand All @@ -13,6 +15,9 @@ Creates a new instance of HTTP





## Properties
| Name | Value |
| ---- | ----- |

10 changes: 6 additions & 4 deletions docs/docs/builtins/IO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CodeBlockSimple from '@site/components/CodeBlockSimple'

# IO


Expand All @@ -11,13 +13,13 @@
Opens a file pointer to the file at the path, mode and permission can be set optionally.


```js
🚀 > IO.open("main.go", "r", "0644")
=> <file:main.go>
```
<CodeBlockSimple input='IO.open("main.go", "r", "0644")
' output='<file:main.go>
' />



## Properties
| Name | Value |
| ---- | ----- |

14 changes: 8 additions & 6 deletions docs/docs/builtins/JSON.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CodeBlockSimple from '@site/components/CodeBlockSimple'

# JSON


Expand All @@ -11,15 +13,15 @@
Takes a STRING and parses it to a HASH or ARRAY. Numbers are always FLOAT.


```js
🚀 > JSON.parse('{"test": 123}')
=> {"test": 123.0}
🚀 > JSON.parse('["test", 123]')
=> ["test", 123.0]
```
<CodeBlockSimple input='JSON.parse(&apos;{"test": 123}&apos;)
JSON.parse(&apos;["test", 123]&apos;)
' output='{"test": 123.0}
["test", 123.0]
' />



## Properties
| Name | Value |
| ---- | ----- |

Loading

2 comments on commit e580bee

@vercel
Copy link

@vercel vercel bot commented on e580bee Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e580bee Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.