Skip to content

Commit ec1c1fa

Browse files
committed
[Docs] Add contribution to docs section; add from_opt in runtime representations
1 parent 22fa849 commit ec1c1fa

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

site/docsource/Dev-mode-How-to.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ Suppose you have mocha installed, if not, try `npm install mocha`
113113
* See the coverage
114114
115115
`npm run cover`
116+
117+
### Contributing to the documentation
118+
119+
You'll need http://asciidoctor.org/[Asciidoctor] installed. Modify the section you want in `site/docsource/`, then run `site/docsource/build.sh`.

site/docsource/Runtime-representation.adoc

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
## Runtime representation
33

4-
Below is a description of how OCaml values are encoded in JavaScript,
5-
the *internal* description means **users should not rely on its actual
4+
Below is a description of how OCaml values are encoded in JavaScript,
5+
the *internal* description means **users should not rely on its actual
66
encoding (and it is subject to change)**. We recommend that you write
77
setter/getter functions to manipulate safely OCaml values from JavaScript.
88

@@ -80,7 +80,7 @@ Simple Variants: (Variants with only one non-nullary constructor)
8080
[source,ocaml]
8181
--------------
8282
type tree =
83-
\| Leaf
83+
\| Leaf
8484
\| Node of int * tree * tree
8585
(* Leaf --> 0 *)
8686
(* Node(a,b,c) --> [a,b,c]*)
@@ -90,7 +90,7 @@ Complex Variants: (Variants with more than one non-nullary constructor)
9090
9191
[source,ocaml]
9292
-------------
93-
type u =
93+
type u =
9494
\| A of string
9595
\| B of int
9696
(* A a --> [a].tag=0 -- tag 0 assignment is optional *)
@@ -123,29 +123,22 @@ For example:
123123
val Js.to_bool: Js.boolean -> bool
124124
-----
125125
126-
| `'a Js.Null.t` a| either `'a` or `null`
126+
| `'a Js.Null.t` a| either `'a` or `null`. `Js.Null.empty` represents `null` too.
127127
128128
[source,ocaml]
129129
.Js.Null module
130130
--------------
131131
val to_opt : 'a t -> 'a option
132-
132+
val from_opt : 'a option -> 'a t
133133
val return : 'a -> 'a t
134-
135134
val test : 'a t -> bool
136135
--------------
137136
138-
| `'a Js.Undefined.t` a| either `'a` or `undefined`
139-
140-
[source,ocaml]
141-
.Js.Undefined
142-
--------------
143-
val to_opt : 'a t -> 'a option
144-
val return : 'a -> 'a t
145-
val test : 'a t -> bool
146-
--------------
137+
| `'a Js.Undefined.t` a| either `'a` or `undefined`.
138+
Same operations as `'a Js.Null.t`.
147139
148-
|`'a Js.Null_undefined.t` a| either `'a`, `null` or `undef`
140+
|`'a Js.Null_undefined.t` a| either `'a`, `null` or `undef`.
141+
Same operations as `'a Js.Null.t`.
149142
|==============
150143
151144
NOTE: `Js.to_opt` is optimized when the `option` is not escaped

0 commit comments

Comments
 (0)