Skip to content

Commit c6f384a

Browse files
authored
Add technical reference labels everywhere (#251)
The labels will allow us to cross-reference between parts of the documentation more easily.
1 parent 90847a0 commit c6f384a

5 files changed

Lines changed: 157 additions & 0 deletions

File tree

docs/reference/asyncoption.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _class-AsyncOption:
2+
13
AsyncOption
24
===========
35

@@ -36,6 +38,8 @@ Or you can use the :ref:`Option.toAsyncOption() <method-Option-toAsyncOption>` m
3638
3739
const option3 = Some(1).toAsyncOption()
3840
41+
.. _method-AsyncOption-andThen:
42+
3943
``andThen()``
4044
-------------
4145

@@ -60,6 +64,8 @@ Example:
6064
await hasValue.andThen(async (value) => None).promise // None
6165
await noValue.andThen(async (value) => Some(value * 2)).promise // None
6266
67+
.. _method-AsyncOption-map:
68+
6369
``map()``
6470
---------
6571

@@ -83,6 +89,8 @@ Example:
8389
await noValue.map(async (value) => value * 2).promise // None
8490
8591
92+
.. _method-AsyncOption-or:
93+
8694
``or()``
8795
--------
8896

@@ -129,6 +137,8 @@ Example:
129137
130138
131139
140+
.. _attribute-AsyncOption-promise:
141+
132142
``promise``
133143
-----------
134144

@@ -142,6 +152,8 @@ You can await it to convert ``AsyncOption<T>`` to ``Option<T>``, but prefer
142152
awaiting ``AsyncOption`` directly (see: `then()`_). Only use this property
143153
if you need the underlying Promise for specific use cases.
144154

155+
.. _method-AsyncOption-then:
156+
145157
``then()``
146158
----------
147159

@@ -165,6 +177,8 @@ Example:
165177
const asyncOption = new AsyncOption(Some(42))
166178
const option = await asyncOption // Returns Option<number>
167179
180+
.. _method-AsyncOption-toResult:
181+
168182
``toResult()``
169183
--------------
170184

docs/reference/asyncresult.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _class-AsyncResult:
2+
13
AsyncResult
24
===========
35

@@ -37,6 +39,8 @@ Or you can use the :ref:`Result.toAsyncResult() <method-Result-toAsyncResult>` m
3739
const result3 = Ok(1).toAsyncResult()
3840
3941
42+
.. _method-AsyncResult-andThen:
43+
4044
``andThen()``
4145
-------------
4246
@@ -61,6 +65,8 @@ Example:
6165
await badResult.andThen(async (value) => Ok(value * 2)).promise // Err('boo')
6266
6367
68+
.. _method-AsyncResult-map:
69+
6470
``map()``
6571
---------
6672
@@ -83,6 +89,8 @@ Example:
8389
await goodResult.map(async (value) => value * 2).promise // Ok(2)
8490
await badResult.andThen(async (value) => value * 2).promise // Err('boo')
8591
92+
.. _method-AsyncResult-mapErr:
93+
8694
``mapErr()``
8795
------------
8896
@@ -104,6 +112,8 @@ Example:
104112
await badResult.mapErr(async (error) => `Error is ${error}`).promise // Err('Error is boo')
105113
106114
115+
.. _method-AsyncResult-or:
116+
107117
``or()``
108118
--------
109119
@@ -153,6 +163,8 @@ Example:
153163
await goodResult.orElse(() => Ok(123)).promise // Ok(1)
154164
155165
166+
.. _attribute-AsyncResult-promise:
167+
156168
``promise``
157169
-----------
158170
@@ -166,6 +178,8 @@ You can await it to convert ``AsyncResult<T, E>`` to ``Result<T, E>``, but prefe
166178
awaiting ``AsyncResult`` directly (see: `then()`_). Only use this property
167179
if you need the underlying Promise for specific use cases.
168180
181+
.. _method-AsyncResult-then:
182+
169183
``then()``
170184
----------
171185
@@ -190,6 +204,8 @@ Example:
190204
const result = await asyncResult // Returns Result<number, Error>
191205
192206
207+
.. _method-AsyncResult-toOption:
208+
193209
``toOption()``
194210
--------------
195211

docs/reference/option.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _class-Option:
2+
13
Option
24
======
35

@@ -20,6 +22,8 @@ Construction:
2022
const some = Some('some value')
2123
// None is a singleton, no construction necessary
2224
25+
.. _method-Option-all:
26+
2327
``all()``
2428
---------
2529

@@ -45,6 +49,8 @@ Example:
4549
let optionsWithNone: Option<number>[] = [Some(1), None, Some(3)];
4650
Option.all(optionsWithNone); // None, type: Option<number[]>
4751
52+
.. _method-Option-any:
53+
4854
``any()``
4955
---------
5056
@@ -69,6 +75,8 @@ Example:
6975
Option.any([None, None, Some(3)]); // Some(3), type: Option<number>
7076
Option.any([None, None, None]); // None, type: Option<never>
7177
78+
.. _attribute-Some-EMPTY:
79+
7280
``Some.EMPTY``
7381
--------------
7482
@@ -85,6 +93,8 @@ Example:
8593
8694
const x: Option<void> = Some.EMPTY
8795
96+
.. _method-Option-andThen:
97+
8898
``andThen()``
8999
-------------
90100
@@ -95,11 +105,15 @@ Example:
95105
Calls ``mapper`` if the ``Option`` is ``Some``, otherwise returns ``None``.
96106
This function can be used for control flow based on ``Option`` values.
97107
108+
.. _attribute-Some-value:
109+
98110
``value``
99111
---------
100112
101113
The value contained in ``Some``. Only present on ``Some`` objects.
102114
115+
.. _method-Option-expect:
116+
103117
``expect()``
104118
------------
105119
@@ -116,6 +130,8 @@ there won't be an exception thrown on access.
116130
117131
``msg``: the message to throw if no ``Some`` value.
118132
133+
.. _method-Option-isNone:
134+
119135
``isNone()``
120136
------------
121137
@@ -125,6 +141,8 @@ there won't be an exception thrown on access.
125141
126142
``true`` when the ``Option`` is ``None``.
127143
144+
.. _method-Option-isSome:
145+
128146
``isSome()``
129147
------------
130148
@@ -134,6 +152,8 @@ there won't be an exception thrown on access.
134152
135153
``true`` when the ``Option`` is ``Some``.
136154
155+
.. _method-Option-map:
156+
137157
``map()``
138158
---------
139159
@@ -146,6 +166,8 @@ leaving a ``None`` value untouched.
146166
147167
This function can be used to compose the Options of two functions.
148168
169+
.. _method-Option-mapOr:
170+
149171
``mapOr()``
150172
-----------
151173
@@ -159,6 +181,8 @@ of ``Some``) or using the ``default_`` value (in case of ``None``).
159181
If ``default_`` is a result of a function call consider using `mapOrElse()`_ instead, it will
160182
only evaluate the function when needed.
161183
184+
.. _method-Option-mapOrElse:
185+
162186
``mapOrElse()``
163187
---------------
164188
@@ -169,6 +193,8 @@ only evaluate the function when needed.
169193
Maps an ``Option<T>`` to ``Option<U>`` by either converting ``T`` to ``U`` using ``mapper`` (in case
170194
of ``Some``) or producing a default value using the ``default_`` function (in case of ``None``).
171195
196+
.. _method-Option-or:
197+
172198
``or()``
173199
--------
174200
@@ -188,6 +214,8 @@ Example:
188214
Some(1).or(Some(2)) // => Some(1)
189215
None.or(Some(2)) // => Some(2)
190216
217+
.. _method-Option-orElse:
218+
191219
``orElse()``
192220
------------
193221
@@ -207,6 +235,8 @@ Example:
207235
Some(1).orElse(() => Some(2)) // => Some(1)
208236
None.orElse(() => Some(2)) // => Some(2)
209237
238+
.. _type-OptionSomeType:
239+
210240
``OptionSomeType``
211241
------------------
212242
@@ -223,6 +253,8 @@ Example:
223253
type Input = Option<string>
224254
type Output = OptionSomeType<Input> // string
225255
256+
.. _type-OptionSomeTypes:
257+
226258
``OptionSomeTypes``
227259
-------------------
228260
@@ -254,6 +286,8 @@ Creates an `AsyncOption` based on this `Option`.
254286
Useful when you need to compose results with asynchronous code.
255287
256288
289+
.. _method-Option-toResult:
290+
257291
``toResult()``
258292
--------------
259293
@@ -263,6 +297,8 @@ Useful when you need to compose results with asynchronous code.
263297
264298
Maps an ``Option<T>`` to a ``Result<T, E>``.
265299
300+
.. _method-Option-unwrap:
301+
266302
``unwrap()``
267303
------------
268304
@@ -281,6 +317,8 @@ there won't be an exception thrown on access.
281317
282318
Throws if the value is ``None``.
283319
320+
.. _method-Option-unwrapOr:
321+
284322
``unwrapOr()``
285323
--------------
286324
@@ -290,6 +328,8 @@ Throws if the value is ``None``.
290328
291329
Returns the contained ``Some`` value or a provided default.
292330
331+
.. _method-Option-unwrapOrElse:
332+
293333
``unwrapOrElse()``
294334
------------------
295335
@@ -311,6 +351,8 @@ Example:
311351
312352
None.unwrapOrElse(() => 'UGH') // => 'UGH'
313353
354+
.. _method-Option-Iterable:
355+
314356
Iterable
315357
--------
316358

0 commit comments

Comments
 (0)