Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Dec 10, 2023
1 parent 1e9415b commit 97da5af
Show file tree
Hide file tree
Showing 33 changed files with 9,227 additions and 1,131 deletions.
58 changes: 46 additions & 12 deletions docs/concepts/task-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,87 @@ Here, you will see the technical specification of `AnyInput`
# Technical Specification

<!--start-doc-->
## `AnyInput`

Abstract base class representing a generalized input specification.
This class serves as a template for creating various input types,
providing a standardized interface for input handling and processing.

### `AnyInput.get_default`
## `Input`

Alias for BaseInput

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
```


### `Input.get_default`

Obtains the default value of the input.

__Returns:__

`Any`: The default value of the input. The type can be any, depending on the input specification.

### `AnyInput.get_name`
### `Input.get_name`

Retrieves the name of the input.

__Returns:__

`str`: The name of the input.

### `AnyInput.get_options`
### `Input.get_options`

Provides a mapping (dictionary) representing the input.

__Returns:__

`Mapping[str, Any]`: A dictionary where keys are option names and values are the corresponding details.

### `AnyInput.get_param_decl`
### `Input.get_param_decl`

Fetches a list of parameter option associated with the input (i.e., `-f` or `--file`).

__Returns:__

`List[str]`: A list containing strings of parameter options.

### `AnyInput.is_hidden`
### `Input.is_hidden`

Checks whether the input value is meant to be hidden from view or output.

__Returns:__

`bool`: True if the input is hidden, False otherwise.

### `AnyInput.should_render`
### `Input.should_render`

Determines whether or not the input should be rendered.

Expand Down
65 changes: 32 additions & 33 deletions docs/concepts/task-input/bool-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,42 @@
<!--start-doc-->
## `BoolInput`

A concrete implementation of the AnyInput abstract base class, representing a specific type of task input.
This class allows for the creation of interactive and configurable inputs for tasks, with various attributes
to customize its behavior and appearance.

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.
A specialized input class for handling boolean values in a task input context.

This class extends `BaseInput` and provides specific functionality for boolean type inputs,
including support for default values, prompts, flags, and various customization options.

__Arguments:__

- `name` (`str`): The name of the input.
- `shortcut` (`Optional[str]`): A shortcut string for the input.
- `default` (`Optional[Any]`): The default value for the input. Should be a boolean if set.
- `description` (`Optional[str]`): A brief description of the input.
- `show_default` (`Union[bool, str, None]`): Option to display the default value. Can be a boolean or string representation.
- `prompt` (`Union[bool, str]`): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
- `confirmation_prompt` (`Union[bool, str]`): If set to `True`, the user is asked to confirm the input.
- `prompt_required` (`bool`): If `True`, the prompt for input is mandatory.
- `hide_input` (`bool`): If `True`, the input is hidden (useful for sensitive information).
- `is_flag` (`Optional[bool]`): Indicates if the input is a flag. If `True`, the input accepts boolean flag values.
- `flag_value` (`Optional[Any]`): The value associated with the flag if `is_flag` is `True`.
- `multiple` (`bool`): If `True`, allows multiple values for the input.
- `count` (`bool`): If `True`, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If `True`, allows the input to be automatically populated from the environment.
- `hidden` (`bool`): If `True`, the input is not shown in help messages or documentation.
- `show_choices` (`bool`): If `True`, displays the choices available for the input.
- `show_envvar` (`bool`): Indicates whether to display the environment variable associated with this input.
- `nargs` (`int`): The number of arguments that the input can accept.
- `should_render` (`bool`): If `True`, the input is rendered in the UI or command-line interface.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
bool_input = BoolInput(name='confirm', prompt='Do you agree?', default=False)
bool_input.get_default()
```

```
False
```


Expand Down
67 changes: 34 additions & 33 deletions docs/concepts/task-input/choice-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,44 @@
<!--start-doc-->
## `ChoiceInput`

A concrete implementation of the AnyInput abstract base class, representing a specific type of task input.
This class allows for the creation of interactive and configurable inputs for tasks, with various attributes
to customize its behavior and appearance.

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.
A specialized input class for handling choice-based inputs in a task input context.

This class extends `BaseInput` and provides functionality for inputs where the user
must select from a predefined set of choices. It includes support for default values,
prompts, flags, and various customization options.

__Arguments:__

- `name` (`str`): The name of the input.
- `shortcut` (`Optional[str]`): An optional shortcut string for the input.
- `choices` (`Iterable[Any]`): An iterable of choices from which the user can select.
- `default` (`Optional[Any]`): The default value for the input. Should be one of the choices if set.
- `description` (`Optional[str]`): A brief description of the input.
- `show_default` (`Union[bool, str, None]`): Option to display the default value. Can be a boolean or string representation.
- `prompt` (`Union[bool, str]`): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
- `confirmation_prompt` (`Union[bool, str]`): If set to `True`, the user is asked to confirm the input.
- `prompt_required` (`bool`): If `True`, the prompt for input is mandatory.
- `hide_input` (`bool`): If `True`, the input is hidden (useful for sensitive information).
- `is_flag` (`Optional[bool]`): Indicates if the input is a flag. If `True`, the input accepts boolean flag values.
- `flag_value` (`Optional[Any]`): The value associated with the flag if `is_flag` is `True`.
- `multiple` (`bool`): If `True`, allows multiple values for the input.
- `count` (`bool`): If `True`, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If `True`, allows the input to be automatically populated from the environment.
- `hidden` (`bool`): If `True`, the input is not shown in help messages or documentation.
- `show_choices` (`bool`): If `True`, displays the available choices to the user.
- `show_envvar` (`bool`): Indicates whether to display the environment variable associated with this input.
- `nargs` (`int`): The number of arguments that the input can accept.
- `should_render` (`bool`): If `True`, the input is rendered in the UI or command-line interface.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
choice_input = ChoiceInput(name='color', choices=['red', 'green', 'blue'], default='red')
choice_input.get_default()
```

```
'red'
```


Expand Down
65 changes: 32 additions & 33 deletions docs/concepts/task-input/float-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,42 @@
<!--start-doc-->
## `FloatInput`

A concrete implementation of the AnyInput abstract base class, representing a specific type of task input.
This class allows for the creation of interactive and configurable inputs for tasks, with various attributes
to customize its behavior and appearance.

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.
A specialized input class designed to handle floating-point numbers in a task input context.

Extending `BaseInput`, this class facilitates the handling of float-type inputs, accommodating
various features like default values, prompts, flags, and customization options.

__Arguments:__

- `name` (`str`): The name of the input.
- `shortcut` (`Optional[str]`): An optional shortcut string for the input.
- `default` (`Optional[Any]`): The default value for the input, expected to be a float if set.
- `description` (`Optional[str]`): A brief description of the input's purpose.
- `show_default` (`Union[bool, str, None]`): Option to display the default value. Can be a boolean or string.
- `prompt` (`Union[bool, str]`): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
- `confirmation_prompt` (`Union[bool, str]`): If `True`, the user is asked to confirm the input.
- `prompt_required` (`bool`): If `True`, the prompt for input is mandatory.
- `hide_input` (`bool`): If `True`, the input is hidden, useful for sensitive information.
- `is_flag` (`Optional[bool]`): Indicates if the input is a flag. If `True`, the input accepts boolean flag values.
- `flag_value` (`Optional[Any]`): The value associated with the flag if `is_flag` is `True`.
- `multiple` (`bool`): If `True`, allows multiple float values for the input.
- `count` (`bool`): If `True`, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If `True`, allows the input to be automatically populated from the environment.
- `hidden` (`bool`): If `True`, the input is not shown in help messages or documentation.
- `show_choices` (`bool`): If `True`, displays the available choices to the user (relevant if there are restricted float choices).
- `show_envvar` (`bool`): Indicates whether to display the environment variable associated with this input.
- `nargs` (`int`): The number of arguments that the input can accept.
- `should_render` (`bool`): If `True`, the input is rendered in the UI or command-line interface.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
float_input = FloatInput(name='threshold', default=0.5, description='Set the threshold value')
float_input.get_default()
```

```
0.5
```


Expand Down
Loading

0 comments on commit 97da5af

Please sign in to comment.