Browse Source

Updating reference material

Signed-off-by: Mary Anthony <mary@blockstack.com>
feat/clarity-updates
Mary Anthony 5 years ago
parent
commit
541419496c
  1. 2
      README.md
  2. 14
      _data/clarityRef.json

2
README.md

@ -82,7 +82,7 @@ As of 8/12/19 Clarity is in the [develop](https://github.com/blockstack/blocksta
2. Build the lastest JSON.
```
docker run -it -v $HOME/blockstack-dev-data:/data/ blockstack/blockstack-core:clarity-developer-preview blockstack-core docgen | jsonpp > ~/repos/docs.blockstack/_data/clarityRef.json
$ docker run --name docsbuild -it blockstack-test blockstack-core docgen | jsonpp > ~/repos/docs.blockstack/_data/clarityRef.json
```
3. Build the documentation and verify the Clarity reference is building correctly.

14
_data/clarityRef.json

@ -173,7 +173,7 @@
"input_type": "buff|list",
"output_type": "uint",
"signature": "(len buffer)",
"description": "The `len` function returns the length of a given buffer / list.",
"description": "The `len` function returns the length of a given buffer or list.",
"example": "(len \"blockstack\") ;; Returns 10\n(len (list 1 2 3 4 5)) ;; Returns 5\n"
},
{
@ -205,7 +205,7 @@
"input_type": "MapName, tuple",
"output_type": "(optional (tuple))",
"signature": "(map-get map-name key-tuple)",
"description": "The `map-get` function looks up and returns an entry from a contract's data map.\nThe value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a (none) option. Otherwise,\nit returns (some value)",
"description": "The `map-get` function looks up and returns an entry from a contract's data map.\nThe value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a `` option. Otherwise,\nit returns `(some value)`.",
"example": "(expects! (map-get names-map (tuple (name \"blockstack\"))) (err 1)) ;; Returns (tuple (id 1337))\n(expects! (map-get names-map ((name \"blockstack\"))) (err 1)) ;; Same command, using a shorthand for constructing the tuple\n"
},
{
@ -213,7 +213,7 @@
"input_type": "ContractName, MapName, tuple",
"output_type": "(optional (tuple))",
"signature": "(contract-map-get .contract-name map-name key-tuple)",
"description": "The `contract-map-get` function looks up and returns an entry from a\ncontract other than the current contract's data map. The value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a (none) option. Otherwise,\nit returns (some value).",
"description": "The `contract-map-get` function looks up and returns an entry from a\ncontract other than the current contract's data map. The value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a `(none)` option. Otherwise,\nit returns `(some value)`.",
"example": "(expects! (contract-map-get .names-contract names-map (tuple (name \"blockstack\")) (err 1))) ;; Returns (tuple (id 1337))\n(expects! (contract-map-get .names-contract names-map ((name \"blockstack\")) (err 1)));; Same command, using a shorthand for constructing the tuple\n"
},
{
@ -376,6 +376,14 @@
"description": "The `default-to` function attempts to 'unpack' the second argument: if the argument is\na `(some ...)` option, it returns the inner value of the option. If the second argument is a `(none)` value,\n`default-to` it returns the value of `default-value`.",
"example": "(default-to 0 (get id (map-get names-map (tuple (name \"blockstack\"))))) ;; Returns 1337\n(default-to 0 (get id (map-get names-map (tuple (name \"non-existant\"))))) ;; Returns 0\n"
},
{
"name": "asserts!",
"input_type": "bool, C",
"output_type": "bool",
"signature": "(asserts! bool-expr thrown-value)",
"description": "The `asserts!` function admits a boolean argument and asserts its evaluation: \nif bool-expr is `true`, `asserts!` returns `true` and proceeds in the program execution. \nIf the supplied argument is returning a 'false value, `asserts!` _returns_ `thrown-value` and exits the current \ncontrol-flow.",
"example": "(asserts! (eq? 1 1) (err 1)) ;; Returns 'true"
},
{
"name": "expects!",
"input_type": "(optional A) | (response A B), C",

Loading…
Cancel
Save