Skip to content

Commit

Permalink
Add documentation contribution information to nodes.md (chaiNNer-org#…
Browse files Browse the repository at this point in the history
…2019)

* Add documentation contribution information to nodes.md

* Update docs/nodes.md

Co-authored-by: Michael Schmidt <[email protected]>

---------

Co-authored-by: Michael Schmidt <[email protected]>
  • Loading branch information
2 people authored and stonerl committed Aug 1, 2023
1 parent af7f93c commit db86e36
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions docs/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Metadata is used to define a contract between a node, the rest of the backend, a
When choosing a name, make sure that it is descriptive and unique. If you are implementing a node that already exists in another package, make sure to use the same name. E.g. PyTorch and NCNN both have a Load Model node.

- **Description** \
A description of the node. This is currently only used in the node's tooltip in the node selector sidebar.
A description of the node. This is currently used in the node's tooltip in the node selector sidebar, as well as the Node Documentation modal. If given an array of strings, only the first string will populate the tooltip, while all strings will populate the modal.
- **Icon** \
The icon of the node. Use the search bar on [React Icons](https://react-icons.github.io/react-icons) for which icons you want to use. Note that we only support icons from the `Bs`, `Cg`, `Md`, and `Im` families.
- **Inputs/Outputs** \
Expand All @@ -54,7 +54,7 @@ Metadata is used to define a contract between a node, the rest of the backend, a

Nodes must explicitly declare all their inputs and outputs as part of their metadata. This is done using the `inputs` and `outputs` properties. Each argument of the python function has a corresponding input, and the return value of the function has a corresponding output. See [The anatomy of a node](#the-anatomy-of-a-node) for an example.

The main purpose of the explicitly declaring inputs and outputs is to provide more information about the node. E.g. the type information is used to determine which connections are valid, the minimum/maximum information is used to validate user inputs, and placeholder and defaults are used to improve the user experience. They also [make guarantees about input data and enforce conventions](./data-representation.md).
The main purpose of explicitly declaring inputs and outputs is to provide more information about the node. E.g. the type information is used to determine which connections are valid, the minimum/maximum information is used to validate user inputs, and placeholder and defaults are used to improve the user experience. They also [make guarantees about input data and enforce conventions](./data-representation.md).

The most common classes used to declare inputs are `NumberInput`, `TextInput`, and `ImageInput`. There is also `SliderInput` as an alternative to `NumberInput`. Many more inputs are available.

Expand Down Expand Up @@ -211,6 +211,25 @@ Let's take a look at the inputs and outputs of the Create Border node. This node
],
```

### Documentation

Inputs and outputs both allow optional documentation to be added to add more information about it to the Node Documentation modal. You can add documentation to an input or output using the `.with_docs()` method, like so:

```python
inputs=[
ImageInput().with_docs(
"An example image input.",
"Each string passed in will be its own paragraph in the resulting docs page.",
"And, it supports _markdown_ *formatting*.",
),
NumberInput().with_docs(
"Confusing inputs can be given a hint flag, which will show a tooltip icon on the input in the node itself.",
"Use these when you think people would need an explanation about something regardless of if they have looked at the docs modal."
hint=True,
)
],
```

## Broadcasts

Broadcasts are a way of sending data from the backend to the frontend. They are used for updating previews (e.g. image previews), enhancing error messages with useful information, and providing the type system with additional information. Output classes (e.g. `ImageOutput`) are responsible for generating broadcasts.
Expand Down

0 comments on commit db86e36

Please sign in to comment.