Skip to content

Commit 173815d

Browse files
committed
minor docs improvements
1 parent 5cd8114 commit 173815d

7 files changed

Lines changed: 35 additions & 20 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ node --env-file .typescript.env ./examples/doc-snippets/helloWorld.ts
3030

3131
## Build
3232

33-
Once done with [Requirements](#requirements) to build the project, just run:
33+
To build everything, once done with [Requirements](#requirements) just run:
3434

3535
```sh
3636
npm run build

dflow.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type DflowDataType =
2727
| "array"
2828
| "object";
2929

30-
// Inputs, outputs and links.
30+
// Inputs, outputs, links and nodes.
3131
// ////////////////////////////////////////////////////////////////////
3232

3333
/** Connects two nodes in the graph. */
@@ -78,9 +78,6 @@ export type DflowOutput = {
7878
types: DflowDataType[];
7979
};
8080

81-
// DflowNode
82-
// ////////////////////////////////////////////////////////////////////
83-
8481
/** Defines a block of code: it can have inputs and outputs. */
8582
export type DflowNode = {
8683
kind: string;
@@ -434,9 +431,7 @@ export class Dflow {
434431
}
435432
}
436433

437-
/**
438-
* A graph contains nodes and links.
439-
*/
434+
/** A graph contains nodes and links. */
440435
get graph(): DflowGraph {
441436
const node: DflowGraph["node"] = {};
442437
const data: DflowGraph["data"] = {};
@@ -506,6 +501,8 @@ export class Dflow {
506501
* ```ts
507502
* Dflow.input([], { name: "foo" })
508503
* ```
504+
*
505+
* @see {@link https://fibo.github.io/dflow/#dflow.input} for more examples.
509506
*/
510507
static input(
511508
typing: DflowDataType | DflowDataType[] = [],
@@ -523,8 +520,10 @@ export class Dflow {
523520
* @example Named output with `number` type.
524521
*
525522
* ```ts
526-
* Dflow.output("number", { name: "amount" })
523+
* Dflow.output("number", { name: "count" })
527524
* ```
525+
*
526+
* @see {@link https://fibo.github.io/dflow/#dflow.output} for more examples.
528527
*/
529528
static output(
530529
typing: DflowDataType | DflowDataType[] = [],

docs/examples/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# dflow examples
22

3-
First do steps in [this Requirements section](../../.github/CONTRIBUTING.md).
3+
First you need dflow.js bundle in the package root folder. You can build it with something like:
4+
5+
```sh
6+
npm install esbuild --no-save
7+
npm run esbuild
8+
```
49

510
Then you can run examples via an npm script:
611

docs/index.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ <h2>API</h2>
207207
<h3 id="constructor">Constructor</h3>
208208

209209
<p>
210-
<code>Dflow</code> constructor requires a list of node definitions.
210+
<code>Dflow</code> constructor requires a list of node definitions which is an <code>Array<<a href="#dflownode">DflowNode</a>></code>.
211211
</p>
212212

213-
<!-- START file:docs/snippets/helloWorld.ts -->
213+
<!-- START file:docs/examples/snippets/helloWorld.ts -->
214214
<pre><code>
215215
import { Dflow, type DflowNode } from "dflow";
216216

@@ -229,7 +229,7 @@ <h3 id="constructor">Constructor</h3>
229229
// Run the dflow graph.
230230
dflow.run()
231231
</code></pre>
232-
<!-- END file:docs/snippets/helloWorld.ts -->
232+
<!-- END file:docs/examples/snippets/helloWorld.ts -->
233233

234234
<h3 id="methods">Methods</h3>
235235

@@ -308,20 +308,20 @@ <h4>dflow.out</h4>
308308

309309
<h3 id="static-methods">Static methods</h3>
310310

311-
<h4>Dflow.input()</h4>
311+
<h4 id="dflow.input">Dflow.input()</h4>
312312

313313
<p class="description">
314314
Helper to define inputs.
315315
</p>
316316

317-
<h4>Dflow.output()</h4>
317+
<h4 id="dflow.output">Dflow.output()</h4>
318318

319319
<p class="description">
320320
Helper to define outputs.
321321
</p>
322322

323323
<p>
324-
Define an output named π (PI) for a constant node
324+
Define an output named <code>π</code> (PI) for a constant node
325325
</p>
326326

327327
<!-- ./examples/nodes/math.ts -->
@@ -370,6 +370,14 @@ <h4 id="dflowdatatype">DflowDataType</h4>
370370
<li><code>"object"</code></li>
371371
</ul>
372372

373+
<p>
374+
Both <code>DflowInput</code> and <code>DflowOutput</code> have a <code>types: DflowDataType[]</code> attribute which is used to check if they can be connected.
375+
</p>
376+
377+
<p>
378+
A special case is when <code>types</code> is an empty array. In this case, the input or output can accept <strong>any</strong> data type.
379+
</p>
380+
373381
<h4 id="dflowinput">DflowInput</h4>
374382

375383
<p>
@@ -407,7 +415,7 @@ <h4 id="dflowlink">DflowLink</h4>
407415
Connects two nodes in the graph.
408416
</p>
409417

410-
<h4>DflowNode</h4>
418+
<h4 id="dflownode">DflowNode</h4>
411419

412420
<p class="description">
413421
Defines a block of code: it can have inputs and outputs.

docs/style.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ h2 { font-size: 2.5rem; }
7575
h3 { font-size: 2rem; }
7676
h4, h5, h6 { font-size: 1.5rem; }
7777

78-
p {
78+
p, dl {
7979
max-width: 71ch;
80+
}
81+
82+
p {
8083
line-height: 1.7;
8184
margin: var(--margin-text);
8285
}
@@ -159,7 +162,7 @@ ul {
159162

160163

161164
footer {
162-
margin-top: 5rem;
165+
margin-top: 25vh;
163166
font-size: 0.75em;
164167
padding: 2rem 1rem;
165168
background: #f8e0b5;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"esbuild": "esbuild dflow.ts --minify --outfile=dflow.js",
1919
"example:async_nodes": "node docs/examples/async_nodes.ts",
2020
"example:context": "node docs/examples/context.ts",
21-
"example:hello_world": "node docs/examples/hello_world.ts",
21+
"example:hello_world": "node docs/examples/snippets/hello_world.ts",
2222
"example:usage": "node docs/examples/usage.ts",
2323
"install_precommit_hook": "echo '#!/bin/sh\nnpm test && npm run prettier--check && npm run build\n' > .git/hooks/pre-commit; chmod +x .git/hooks/pre-commit",
2424
"prettier": "prettier --write .",

0 commit comments

Comments
 (0)