Browse Source

Reference is not complete

Signed-off-by: Mary Anthony <mary@blockstack.com>
feat/clarity-updates
Mary Anthony 5 years ago
parent
commit
d1a26677e6
  1. 7
      README.md
  2. 51
      _core/smart/clarityRef.md
  3. 4
      _data/clarityRef.json

7
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. 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. 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 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 # Technology Reference

51
_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). 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. {% capture keyword_list %}
{% for entry in site.data.clarityRef.keywords %}
### block-height {{ entry.name }}||{{ entry.output_type }}||{{ entry.description }}||{{ entry.example }}
{% if forloop.last == false %}::{% endif%}
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. {% 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 <code>{{keyword_vals[1] | lstrip | rstrip }}</code>
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 }}
```
<hr class="uk-divider-icon">
{% endfor %}
## Clarity function reference ## Function reference
{% capture function_list %} {% 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 }} {{ entry.name }}||{{ entry.signature }}||{{ entry.input_type }}||{{ entry.output_type }}||{{ entry.description }}||{{ entry.example }}
{% if forloop.last == false %}::{% endif%} {% if forloop.last == false %}::{% endif%}
{% endfor %} {% endfor %}
@ -162,20 +171,16 @@ Represents the current principal. This variable does not change during inter-con
**Syntax** **Syntax**
```{{function_vals[1] | lstrip | rstrip }} ``` ```{{function_vals[1] | lstrip | rstrip }} ```
<table class="uk-table uk-table-small"> INPUT: <code>{{function_vals[2] | lstrip | rstrip }}</code><br>
<tr> OUTPUT: <code>{{function_vals[3] | lstrip | rstrip }}</code>
<th class="uk-width-small">Input type:</th>
<td><code>{{function_vals[2] | lstrip | rstrip }}</code></td>
</tr>
<tr>
<th>Output type:</th>
<td><code>{{function_vals[3] | rstrip }}</code></td>
</tr>
</table>
{{function_vals[4]}} {{function_vals[4]}}
<h4>Example</h4>
**Example**
```cl ```cl
{{function_vals[5] | lstrip | rstrip }} {{function_vals[5] | lstrip | rstrip }}
``` ```
<hr class="uk-divider-icon"> <hr class="uk-divider-icon">
{% endfor %} {% endfor %}

4
_data/clarityRef.json

@ -44,7 +44,7 @@
"name": "<= (less than or equal)", "name": "<= (less than or equal)",
"input_type": "int, int", "input_type": "int, int",
"output_type": "bool", "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.", "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" "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" "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"
} }
] ]
} }

Loading…
Cancel
Save