mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 09:31:43 +02:00
📚 Update docs.
This commit is contained in:
parent
8e00ba7457
commit
0f5f2a1715
5 changed files with 52 additions and 39 deletions
|
@ -6,13 +6,9 @@ and backend, such as: code style hints, architecture dicisions, etc...
|
|||
|
||||
## Assertions ##
|
||||
|
||||
UXBOX source code has 3 types of assertions that can be used: simple,
|
||||
spec, and dev-spec.
|
||||
UXBOX source code has this types of assertions:
|
||||
|
||||
The simple assertion consists in using the clojure builting `assert`
|
||||
macro. This asserts are only executed on development mode. On
|
||||
production environment all assets like this will be ignored by
|
||||
runtime.
|
||||
**assert**: just using the clojure builtin `assert` macro.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -20,6 +16,11 @@ Example:
|
|||
(assert (number? 3) "optional message")
|
||||
```
|
||||
|
||||
This asserts are only executed on development mode. On production
|
||||
environment all assets like this will be ignored by runtime.
|
||||
|
||||
**spec/assert**: using the `uxbox.common.spec/assert` macro.
|
||||
|
||||
Also, if you are using clojure.spec, you have the spec based
|
||||
`clojure.spec.alpha/assert` macro. In the same way as the
|
||||
`clojure.core/assert`, on production environment this asserts will be
|
||||
|
@ -28,25 +29,33 @@ removed by the compiler/runtime.
|
|||
Example:
|
||||
|
||||
````clojure
|
||||
(require '[clojure.spec.alpha :as s])
|
||||
(require '[clojure.spec.alpha :as s]
|
||||
'[uxbox.common.spec :as us])
|
||||
|
||||
(s/def ::number number?)
|
||||
|
||||
(s/assert ::number 3)
|
||||
(us/assert ::number 3)
|
||||
```
|
||||
|
||||
And finally, for cases when you want a permanent assert (including in
|
||||
production code), you need to use `uxbox.common.spec/assert` macro. It
|
||||
has the same call signature as `clojure.spec.alpha/assert`.
|
||||
In the same way as the `assert` macro, this performs the spec
|
||||
assertion only on development build. On production this code will
|
||||
completely removed.
|
||||
|
||||
**spec/verify**: An assertion type that is executed always.
|
||||
|
||||
Example:
|
||||
|
||||
```clojure
|
||||
(require '[uxbox.common.spec :as us])
|
||||
|
||||
(us/assert ::number 3)
|
||||
(us/verify ::number 3)
|
||||
```
|
||||
|
||||
This macro enables you have assetions on production code.
|
||||
|
||||
**Why don't use the `clojure.spec.alpha/assert` instead of the `uxbox.common.spec/assert`?**
|
||||
|
||||
The uxbox variant does not peforms additional runtime checks for know
|
||||
if asserts are disabled in "runtime". As a result it generates much
|
||||
simplier code at development and production builds.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue