From d1a26677e67d92590febe752d71168fd2327fed6 Mon Sep 17 00:00:00 2001 From: Mary Anthony Date: Mon, 12 Aug 2019 15:40:48 -0700 Subject: [PATCH] Reference is not complete Signed-off-by: Mary Anthony --- README.md | 7 +++--- _core/smart/clarityRef.md | 51 +++++++++++++++++++++------------------ _data/clarityRef.json | 4 +-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 44721a49..be03d38b 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,10 @@ The `_data/cliRef.json` file is generated from the `blockstack-cli` subcommand ` 3. Make sure the generated docs are clean. -## Clarity Command Line +## Clarity Reference -As of 8/19 Clarity is in the [develop](https://github.com/blockstack/blockstack-core/tree/develop) branch of core. You can build the Clarity command line from the Docker image. +As of 8/12/19 Clarity is in the [develop](https://github.com/blockstack/blockstack-core/tree/develop) branch of core. You can build the Clarity command line from the Docker image. `core/src/vm/docs/mod.rs` -docker run -it -v $HOME/blockstack-dev-data:/data/ 6524 blockstack-core docgen | jsonpp > ~/repos/docs.blockstack/_data/clarityRef.json 1. Pull the latest developer preview from the Docker Hub. @@ -89,7 +88,7 @@ docker run -it -v $HOME/blockstack-dev-data:/data/ 6524 blockstack-core docgen | 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 ``` -3. Build the documentation and verify the CLI docs are building correctly. +3. Build the documentation and verify the Clarity reference is building correctly. # Technology Reference diff --git a/_core/smart/clarityRef.md b/_core/smart/clarityRef.md index c1830b1b..cf16e734 100644 --- a/_core/smart/clarityRef.md +++ b/_core/smart/clarityRef.md @@ -129,27 +129,36 @@ Response types represent the result of a public function. Use this type to indic Response types contain two subtypes -- a response type in the event of `ok` (that is, a public function returns an integer code on success) and an `err` type (that is, a function returns a buffer on error). -## Native variables +## Keyword reference -The Clarity language includes native variables you can use in your contract. - -### block-height - -The height of a block in the Stacks blockchain. Block height is the number of blocks in the chain between any given block and the very first block in the blockchain. You can obtain a `block-height` via the `get-block-info` function. +{% capture keyword_list %} +{% for entry in site.data.clarityRef.keywords %} +{{ entry.name }}||{{ entry.output_type }}||{{ entry.description }}||{{ entry.example }} +{% if forloop.last == false %}::{% endif%} +{% endfor %} +{% endcapture %} +{% assign keyword_array = keyword_list | split: '::' | sort %} +{% for keyword in keyword_array %} +{% assign keyword_vals = keyword | split: '||' %} +### {{keyword_vals[0] | lstrip | rstrip}} -### contract-name +{{keyword_vals[1] | lstrip | rstrip }} -Represents the current contract. +{{keyword_vals[2]}} -### tx-sender +**Example** -Represents the current principal. This variable does not change during inter-contract calls. This means that if a transaction invokes a function in a given smart contract, that function is able to make calls into other smart contracts on your behalf. This enables a wide variety of applications, but it comes with some dangers for users of smart contracts. Static analysis of Clarity contracts guarantees the language allows clients to deduce which functions a given smart contract will ever call. Good clients should always warn users about any potential side effects of a given transaction. +```cl +{{keyword_vals[3] | lstrip | rstrip }} +``` +
+{% endfor %} -## Clarity function reference +## Function reference {% capture function_list %} -{% for entry in site.data.clarityRef %} +{% for entry in site.data.clarityRef.functions %} {{ entry.name }}||{{ entry.signature }}||{{ entry.input_type }}||{{ entry.output_type }}||{{ entry.description }}||{{ entry.example }} {% if forloop.last == false %}::{% endif%} {% endfor %} @@ -162,20 +171,16 @@ Represents the current principal. This variable does not change during inter-con **Syntax** ```{{function_vals[1] | lstrip | rstrip }} ``` - - - - - - - - - -
Input type:{{function_vals[2] | lstrip | rstrip }}
Output type:{{function_vals[3] | rstrip }}
+INPUT: {{function_vals[2] | lstrip | rstrip }}
+OUTPUT: {{function_vals[3] | lstrip | rstrip }} + {{function_vals[4]}} -

Example

+ +**Example** + ```cl {{function_vals[5] | lstrip | rstrip }} ```
{% endfor %} + diff --git a/_data/clarityRef.json b/_data/clarityRef.json index f727fa88..9054ff65 100644 --- a/_data/clarityRef.json +++ b/_data/clarityRef.json @@ -44,7 +44,7 @@ "name": "<= (less than or equal)", "input_type": "int, int", "output_type": "bool", - "signature": "(> i1 i2)", + "signature": "(<= i1 i2)", "description": "Compares two integers, returning true if `i1` is less than or equal to `i2` and `false` otherwise.", "example": "(<= 1 1) ;; Returns 'true\n(<= 5 2) ;; Returns 'false\n" }, @@ -499,4 +499,4 @@ "example": "\n(define (only-if-positive (a int))\n (if (> a 0)\n (some a)\n none))\n(only-if-positive 4) ;; Returns (some 4)\n(only-if-positive (- 3)) ;; Returns none\n" } ] -} +}