Merge branch 'toplevel-doc' into 'dev'

Add toplevel page for API reference.

See merge request ligolang/ligo!543
This commit is contained in:
Christian Rinderknecht 2020-04-02 11:36:24 +00:00
commit 2e528e3e49
3 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,86 @@
---
id: toplevel
title: Toplevel
description: Available functions at the top level
hide_table_of_contents: true
---
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
These functions are available without any needed prefix.
<SyntaxTitle syntax="pascaligo">
function is_nat: int -> option(nat)
</Syntax>
<SyntaxTitle syntax="pascaligo">
val is_nat: int -> nat option
</Syntax>
<SyntaxTitle syntax="pascaligo">
let is_nat: int => option(nat)
</Syntax>
Convert an `int` to a `nat` if possible.
<SyntaxTitle syntax="pascaligo">
function abs: int -> nat
</Syntax>
<SyntaxTitle syntax="pascaligo">
val abs: int -> nat
</Syntax>
<SyntaxTitle syntax="pascaligo">
let abs: int => nat
</Syntax>
Cast an `int` to `nat`.
<SyntaxTitle syntax="pascaligo">
function int: nat -> int
</Syntax>
<SyntaxTitle syntax="pascaligo">
val int: nat -> int
</Syntax>
<SyntaxTitle syntax="pascaligo">
let int: nat => int
</Syntax>
Cast an `nat` to `int`.
<SyntaxTitle syntax="pascaligo">
const unit: unit
</Syntax>
<SyntaxTitle syntax="pascaligo">
val unit: unit
</Syntax>
<SyntaxTitle syntax="pascaligo">
let (): unit
</Syntax>
A helper to create a unit.
<SyntaxTitle syntax="pascaligo">
function failwith : string -> unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
function failwith : string -> unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
function failwith : string -> unit
</SyntaxTitle>
Cause the contract to fail with an error message.
> ⚠ Using this currently requires in general a type annotation on the
> `failwith` call.
<SyntaxTitle syntax="pascaligo">
function assert : bool -> unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
function assert : bool -> unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
function assert : bool -> unit
</SyntaxTitle>
Check if a certain condition has been met. If not the contract will fail.

View File

@ -27,6 +27,7 @@
"api/cheat-sheet" "api/cheat-sheet"
], ],
"API":[ "API":[
"reference/toplevel",
"reference/big-map-reference", "reference/big-map-reference",
"reference/bitwise-reference", "reference/bitwise-reference",
"reference/bytes-reference", "reference/bytes-reference",

View File

@ -125,6 +125,9 @@ let md_files = [
"/gitlab-pages/docs/advanced/inline.md"; "/gitlab-pages/docs/advanced/inline.md";
"/gitlab-pages/docs/api/cli-commands.md"; "/gitlab-pages/docs/api/cli-commands.md";
"/gitlab-pages/docs/api/cheat-sheet.md"; "/gitlab-pages/docs/api/cheat-sheet.md";
"/gitlab-pages/docs/reference/toplevel.md";
"/gitlab-pages/docs/reference/bitwise.md";
"/gitlab-pages/docs/reference/bytes.md";
"/gitlab-pages/docs/reference/list.md"; "/gitlab-pages/docs/reference/list.md";
"/gitlab-pages/docs/reference/map.md"; "/gitlab-pages/docs/reference/map.md";
"/gitlab-pages/docs/reference/set.md"; "/gitlab-pages/docs/reference/set.md";