📝 docs(custom.mdx): update table formatting and clarify field_type and options usage in custom component documentation

📝 docs(custom-component.mdx): remove is_list from function field and clarify options usage in build_config method
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-28 11:57:13 -03:00
commit 1d47d47c4d
2 changed files with 16 additions and 19 deletions

View file

@ -34,19 +34,19 @@ The top level keys are the field names.
Their values are of type _`dict`_ with any of the following keys (all of them are **optional**):
| Key | Description |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| _`field_type: str`_ | The type of the field (can be any of the types supported by the _`build`_ method) |
| _`is_list: bool`_ | If the field is a list |
| _`options: List[str]`_ | If, and only if, the _`is_list`_ is _`True`_, this defines the options to be displayed. If you set the _`value`_ attribute to one of the options, it will be selected by default. Having _`is_list`_ and _`options`_ will display a dropdown menu. |
| _`multiline: bool`_ | When the field is a string, if it should be multiline |
| _`input_types: List[str]`_ | To be used when you want a _`str`_ field to have connectable handles |
| _`display_name: str`_ | To define the name of the field |
| _`advanced: bool`_ | To hide the field in default view |
| _`password: bool`_ | To mask the input text |
| _`required: bool`_ | To make the field required |
| _`info: str`_ | To add a tooltip to the field |
| _`file_types: List[str]`_ | This is a requirement if the _`field_type`_ is file. Defines which file types will be accepted. For example, json, yaml or yml |
| Key | Description |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| _`field_type: str`_ | The type of the field (can be any of the types supported by the _`build`_ method) |
| _`is_list: bool`_ | If the field is a list |
| _`options: List[str]`_ | This defines the options to be displayed. The _`field_type`_ should invariably be _`str`_. If you set the _`value`_ attribute to one of the options, it will be selected by default. Having _`options`_ will display a dropdown menu. |
| _`multiline: bool`_ | When the field is a string, if it should be multiline |
| _`input_types: List[str]`_ | To be used when you want a _`str`_ field to have connectable handles |
| _`display_name: str`_ | To define the name of the field |
| _`advanced: bool`_ | To hide the field in default view |
| _`password: bool`_ | To mask the input text |
| _`required: bool`_ | To make the field required |
| _`info: str`_ | To add a tooltip to the field |
| _`file_types: List[str]`_ | This is a requirement if the _`field_type`_ is file. Defines which file types will be accepted. For example, json, yaml or yml |
Now we can load the flow using the _`load_flow`_ method.

View file

@ -35,8 +35,7 @@ class DocumentProcessor(CustomComponent):
def build_config(self) -> dict:
options = ["Uppercase", "Lowercase", "Titlecase"]
return {
"function": {"is_list": True,
"options": options,
"function": {"options": options,
"value": options[0]}}
def build(self, document: Document, function: str) -> Document:
@ -268,8 +267,7 @@ This method is called when the component is built (i.e. when you click the _Buil
The _`build_config`_ method will be used to configure the fields of the component.
- _`is_list`_ allows an input field to contain multiple values. When paired with _`options`_, it will transform it into a dropdown menu.
- _`options`_ is a list of values to be used in the dropdown menu.
- _`options`_ defines that the field will be a dropdown menu. The values must be _`str`_ and the type of the field should also be _`str`_.
- _`value`_ is the default value of the field.
- _`display_name`_ is the name of the field to be displayed in the canvas.
@ -286,8 +284,7 @@ class DocumentProcessor(CustomComponent):
def build_config(self) -> dict:
options = ["Uppercase", "Lowercase", "Titlecase"]
return {
"function": {"is_list": True,
"options": options,
"function": {"options": options,
"value": options[0],
"display_name": "Function"
},