Skip to content

Commit

Permalink
Fix slint doctests with Astro
Browse files Browse the repository at this point in the history
The comma as separator is not permitted, but a space is fine. This also fixes an actual syntax error found by the test :)
  • Loading branch information
tronical committed Nov 14, 2024
1 parent d5263f7 commit dca1836
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/src/content/docs/guide/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ Fine-tune animations using the following parameters:

It's also possible to animate several properties with the same animation, so:

```slint
```slint no-test
animate x, y { duration: 100ms; easing: ease-out-bounce; }
```

is the same as:

```slint
```slint no-test
animate x { duration: 100ms; easing: ease-out-bounce; }
animate y { duration: 100ms; easing: ease-out-bounce; }
```
2 changes: 1 addition & 1 deletion docs/src/content/docs/guide/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ When creating components, it's sometimes useful to influence where child
elements are placed when used. For example, a component that draws
a label above an element inside:

```slint
```slint no-test
export component MyApp inherits Window {
BoxWithLabel {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guide/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ instructs the Slint compiler to include the font and makes the font families glo

For example:

```slint
```slint no-test
import "./NotoSans-Regular.ttf";
export component Example inherits Window {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guide/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Export a global to make it accessible from other files (see [Modules](modules.md
the file also exporting the main application component to make it visible
to native code in the business logic.

```slint
```slint no-test
export global Logic {
in-out property <int> the-value;
pure callback magic-operation(int) -> int;
Expand Down
12 changes: 6 additions & 6 deletions docs/src/content/docs/guide/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export component Button inherits Rectangle {

Similarly, components exported from other files may be imported:

```slint
```slint no-test
import { Button } from "./button.slint";
export component App inherits Rectangle {
Expand All @@ -67,7 +67,7 @@ export component App inherits Rectangle {
In the event that two files export a type under the same name, then you have the option
of assigning a different name at import time:

```slint
```slint no-test
import { Button } from "./button.slint";
import { Button as CoolButton } from "../other_theme/button.slint";
Expand All @@ -83,7 +83,7 @@ Elements, globals and structs can be exported and imported.
It's also possible to export globals (see [Global Singletons](globals.md)) imported from
other files:

```slint
```slint no-test
import { Logic as MathLogic } from "math.slint";
export { MathLogic } // known as "MathLogic" when using native APIs to access globals
```
Expand All @@ -92,7 +92,7 @@ export { MathLogic } // known as "MathLogic" when using native APIs to access gl

The following syntax is supported for importing types:

```slint
```slint no-test
import { export1 } from "module.slint";
import { export1, export2 } from "module.slint";
import { export1 as alias1 } from "module.slint";
Expand All @@ -101,7 +101,7 @@ import { export1, export2 as alias2, /* ... */ } from "module.slint";

The following syntax is supported for exporting types:

```slint
```slint no-test
// Export declarations
export component MyButton inherits Rectangle { /* ... */ }
Expand All @@ -125,7 +125,7 @@ well within a project's own directory structure. To share libraries of
components between projects without hardcoding their relative paths, use
the component library syntax:

```slint
```slint no-test
import { MySwitch } from "@mylibrary/switch.slint";
import { MyButton } from "@otherlibrary";
```
Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/guide/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Additionally, if a property's value changes and then reverts to its original sta
```slint
export component Example {
in-out property <int> foo;
property bar: foo + 1;
property <int> bar: foo + 1;
// This setup creates a potential loop between `foo` and `bar`, and the outcome is undefined.
changed bar => { foo += 1; }
}
Expand All @@ -200,13 +200,13 @@ Therefore, it's crucial not to overuse changed callbacks.

For instance, avoid doing this:

```slint
```slint no-test
changed bar => { foo = bar + 1; }
```

Instead, opt for:

```slint
```slint no-test
foo: bar + 1;
```

Expand Down
10 changes: 5 additions & 5 deletions docs/src/content/docs/guide/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ Callback handlers may contain complex statements:

Assignment:

```slint
```slint no-test
clicked => { some-property = 42; }
```

Self-assignment with `+=` `-=` `*=` `/=`

```slint
```slint no-test
clicked => { some-property += 42; }
```

Calling a callback

```slint
```slint no-test
clicked => { root.some-callback(); }
```

Conditional statements

```slint
```slint no-test
clicked => {
if (condition) {
foo = 42;
Expand All @@ -40,7 +40,7 @@ clicked => {

Empty expression

```slint
```slint no-test
clicked => { }
// or
clicked => { ; }
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/reference/builtins/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ Fine-tune animations using the following parameters:

It's also possible to animate several properties with the same animation, so:

```slint
```slint no-test
animate x, y { duration: 100ms; easing: ease-out-bounce; }
```

is the same as:

```slint
```slint no-test
animate x { duration: 100ms; easing: ease-out-bounce; }
animate y { duration: 100ms; easing: ease-out-bounce; }
```
1 change: 1 addition & 0 deletions tests/doctests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rest = match rest.split_once('\n') {
Some((",no-preview", rest)) | Some((",no-auto-preview", rest)) => rest,
Some(("", rest)) => rest,
Some((" no-test", ..)) => continue,
_ => continue,
};

Expand Down

0 comments on commit dca1836

Please sign in to comment.