Skip to content

Commit

Permalink
docs: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Nov 10, 2024
1 parent 127a9c3 commit a75f6ed
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 11 deletions.
18 changes: 15 additions & 3 deletions docs/api/safeds/data/tabular/containers/Column.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pipeline example {
*/
attr type: DataType

/*
/**
* Return the distinct values in the column.
*
* @param ignoreMissingValues Whether to ignore missing values.
Expand Down Expand Up @@ -915,17 +915,29 @@ pipeline example {

## <code class="doc-symbol doc-symbol-function"></code> `getDistinctValues` {#safeds.data.tabular.containers.Column.getDistinctValues data-toc-label='[function] getDistinctValues'}

Return the distinct values in the column.

**Parameters:**

| Name | Type | Description | Default |
|------|------|-------------|---------|
| `ignoreMissingValues` | [`Boolean`][safeds.lang.Boolean] | - | `#!sds true` |
| `ignoreMissingValues` | [`Boolean`][safeds.lang.Boolean] | Whether to ignore missing values. | `#!sds true` |

**Results:**

| Name | Type | Description |
|------|------|-------------|
| `distinctValues` | [`List<T?>`][safeds.lang.List] | - |
| `distinctValues` | [`List<T?>`][safeds.lang.List] | The distinct values in the column. |

**Examples:**

```sds hl_lines="3"
pipeline example {
val column = Column("test", [1, 2, 3, 2]);
val result = column.getDistinctValues();
// [1, 2, 3]
}
```

??? quote "Stub code in `Column.sdsstub`"

Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nav:
- pipeline-language/statements/README.md
- Expression Statements: pipeline-language/statements/expression-statements.md
- Assignments: pipeline-language/statements/assignments.md
- Output Statements: pipeline-language/statements/output-statements.md
- Expressions:
- pipeline-language/expressions/README.md
- Literals: pipeline-language/expressions/literals.md
Expand Down
12 changes: 7 additions & 5 deletions docs/pipeline-language/statements/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Statements

Statements are used to run some action. Safe-DS has only two type of statements:
Statements are used to run some action. Safe-DS only has three type of statements:

- [Expression statements][expression-statements] evaluate an [expression][expressions] and discard any results. They are
only useful if the expression has side effects, such as writing to a file.
- [Assignments][assignments] also evaluate an [expression][expressions], but then store results in
[placeholders][placeholders]. This allows reusing the results multiple times without having to recompute them.
- [Output statements][output-statements] evaluate an [expression][expressions] as well, and provide options to inspect
its results. Unlike when using assignments, the result cannot be reused.


[assignments]: ./assignments.md
[expression-statements]: ./expression-statements.md
[assignments]: assignments.md
[expression-statements]: expression-statements.md
[output-statements]: output-statements.md
[expressions]: ../expressions/README.md
[placeholders]: ./assignments.md#declaring-placeholders
[placeholders]: assignments.md#declaring-placeholders
6 changes: 4 additions & 2 deletions docs/pipeline-language/statements/assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ This assignment to a placeholder has the following syntactic elements:
- The name of the placeholder, here `titanic`. It can be any combination of lower- and uppercase letters, underscores,
and numbers, as long as it does not start with a number.
- An `#!sds =` sign.
- The expression to evaluate (right-hand side).
- The [expression][expressions] to evaluate (right-hand side).
- A semicolon at the end.

??? info "Name convention"

Use `#!sds lowerCamelCase` for the name of the placeholder. You may prefix the name of an unused placeholder with an
underscore (`_`) to indicate that it is intentionally unused, e.g. to
[inspect its value](#inspecting-placeholder-values-in-vs-code). This disables the "unused" warning.
[inspect its value](#inspecting-placeholder-values-in-vs-code). This disables the "unused" warning. For value
inspection, also consider using an [output statement][output-statements] instead.

### References to Placeholder

Expand Down Expand Up @@ -104,6 +105,7 @@ such cases.
[expressions]: ../expressions/README.md
[expression-statements]: expression-statements.md
[installation]: ../../getting-started/installation.md
[output-statements]: output-statements.md
[references]: ../expressions/references.md#references
[runner]: https://github.com/Safe-DS/Runner
[results]: ../segments.md#results
26 changes: 26 additions & 0 deletions docs/pipeline-language/statements/output-statements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Output Statements

Output statements are used to evaluate an expression and inspect its results. Unlike when using assignments, the results
cannot be reused. However, it is also not necessary to think of unique names for placeholders, which saves time and
keeps the namespace clean.

The next snippet shows how the singular result of an expression (the loaded
[`Table`][safeds.data.tabular.containers.Table]) can be inspected:

```sds
out Table.fromCsvFile("titanic.csv");
```

This output statement has the following syntactic elements:

- The keyword `#!sds out`, which indicates that we want to inspect the results of an expression.
- The expression to evaluate.
- A semicolon at the end.

Inspecting values requires a working installation of the [Safe-DS Runner][runner]. Follow the instructions in the
[installation guide][installation] to install it. Afterward, you can inspect values of various types via
_code lenses_ in the editor, as explained for [assignments][value-inspection].

[installation]: ../../getting-started/installation.md
[runner]: https://github.com/Safe-DS/Runner
[value-inspection]: assignments.md#inspecting-placeholder-values-in-vs-code
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Column<out T = Any?>(
*/
attr type: DataType

/*
/**
* Return the distinct values in the column.
*
* @param ignoreMissingValues Whether to ignore missing values.
Expand Down

0 comments on commit a75f6ed

Please sign in to comment.