Skip to content

Commit

Permalink
chore(docs): added bytes to wing by example also removed numbers in n…
Browse files Browse the repository at this point in the history
…av (#1029)

- Added new example "bytes" for Wing by example.
- Removed numbers on the navigation, this lets us manage and add/move
things around on this guide easier in the future

Closes winglang/wing#7154

---------

Co-authored-by: David Boyne <[email protected]>
  • Loading branch information
boyney123 and David Boyne authored Sep 30, 2024
1 parent c119290 commit 6de886c
Show file tree
Hide file tree
Showing 36 changed files with 64 additions and 35 deletions.
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/02-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Wing by example
id: hello-world
slug: /hello-world
sidebar_label: 1. Hello world
sidebar_label: Hello world
description: Hello world wing example
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/03-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Primitive values
id: primitives
slug: /primitive-values
sidebar_label: 2. Primitive values
sidebar_label: Primitive values
description: Hello world wing example
keywords: [Wing language, example, primitives, values]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/04-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Variables
id: Variables
slug: /Variables
sidebar_label: 4. Variables
sidebar_label: Variables
description: Using variables with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/05-for.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: For
id: for
slug: /for
sidebar_label: 5. For
sidebar_label: For
description: Using for loops with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/06-ifelse.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: If/Else
id: if-else
slug: /if-else
sidebar_label: 6. If/Else
sidebar_label: If/Else
description: Using if else with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/07-while.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: While
id: while
slug: /while
sidebar_label: 7. While
sidebar_label: While
description: Using while statements with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/08-optionality.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Optionality
id: optionality
slug: /optionality
sidebar_label: 8. Optionality
sidebar_label: Optionality
description: Using while statements with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/09-arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Arrays
id: arrays
slug: /arrays
sidebar_label: 9. Arrays
sidebar_label: Arrays
description: Using arrays with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/10-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Maps
id: maps
slug: /maps
sidebar_label: 10. Maps
sidebar_label: Maps
description: Using maps with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/11-sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Sets
id: sets
slug: /sets
sidebar_label: 11. Sets
sidebar_label: Sets
description: Using sets with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/12-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Structs
id: structs
slug: /structs
sidebar_label: 12. Structs
sidebar_label: Structs
description: Using arrays with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
29 changes: 29 additions & 0 deletions example_versioned_docs/version-latest/13-bytes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Bytes
id: bytes
slug: /bytes
sidebar_label: Bytes
description: Hash values in Wing with SHA256
keywords: [Wing language, Hash, SHA256]
image: /img/wing-by-example.png
---

When working with binary files like images, audio, or other binary formats, you often need to manipulate data at the byte level.

```js playground example title="main.w"
// get bytes from raw value
let rawData: bytes = bytes.fromRaw([104, 101, 108, 108, 111]);

// get the bytes from a string
let rawString: bytes = bytes.fromString("hello");

// get bytes from base64 encoded value
let base64: bytes = bytes.fromBase64("aGVsbG8=");

// get bytes from hex value
let hex: bytes = bytes.fromHex("68656c6c6f");
```




Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Trailing struct parameters
id: trailing-structs-parameters
slug: /trailing-structs-parameters
sidebar_label: 13. Trailing struct parameters
sidebar_label: Trailing struct parameters
description: Passing fields directly to a function
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Inflight functions
id: inflight-functions
slug: /inflight-functions
sidebar_label: 14. Async inflight functions
sidebar_label: Async inflight functions
description: Using functions with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/14-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Functions
id: functions
slug: /functions
sidebar_label: 14. Functions
sidebar_label: Functions
description: Using functions with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Variadic Functions
id: variadic-functions
slug: /variadic-functions
sidebar_label: 15. Variadic Functions
sidebar_label: Variadic Functions
description: Using variadic functions with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/16-closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Closures
id: closures
slug: /closures
sidebar_label: 16. Closures
sidebar_label: Closures
description: Closures with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/17-recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Recursion
id: recursion
slug: /recursion
sidebar_label: 17. Recursion
sidebar_label: Recursion
description: Recursion with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/18-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Methods
id: methods
slug: /methods
sidebar_label: 18. Methods
sidebar_label: Methods
description: Methods with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/19-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Interfaces
id: interfaces
slug: /interfaces
sidebar_label: 19. Interfaces
sidebar_label: Interfaces
description: Interfaces with Wing
keywords: [Wing language, interfaces]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/20-sleep.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Sleep
id: sleep
slug: /sleep
sidebar_label: 20. Sleep
sidebar_label: Sleep
description: Suspends execution for a given duration.
keywords: [Wing language, sleep]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: String functions
id: string-functions
slug: /string-functions
sidebar_label: 21. String functions
sidebar_label: String functions
description: Functions for string values in Wing
keywords: [Wing language, string, functions]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/22-regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Regular expressions
id: regex
slug: /regex
sidebar_label: 22. Regular expressions
sidebar_label: Regular expressions
description: Functions for string values in Wing
keywords: [Wing language, string, functions]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/23-Json.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Json
id: json
slug: /json
sidebar_label: 23. Json
sidebar_label: Json
description: Create Json values in Wing
keywords: [Wing language, json]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/24-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Time
id: time
slug: /time
sidebar_label: 24. Time
sidebar_label: Time
description: Create time/date values in Wing
keywords: [Wing language, time, date]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/25-random.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Random
id: random
slug: /random
sidebar_label: 25. Random
sidebar_label: Random
description: Create random values in Wing
keywords: [Wing language, random]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/26-number-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Number parsing
id: number-parsing
slug: /number-parsing
sidebar_label: 26. Number Parsing
sidebar_label: Number Parsing
description: Parse values into numbers
keywords: [Wing language, random]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/27-url-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: URL parsing
id: url-parsing
slug: /url-parsing
sidebar_label: 27. URL parsing
sidebar_label: URL parsing
description: Parse urls in Wing
keywords: [Wing language, URL]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/28-sha256.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: SHA256 Hashes
id: sha256
slug: /sha256
sidebar_label: 28. SHA256 Hashes
sidebar_label: SHA256 Hashes
description: Hash values in Wing with SHA256
keywords: [Wing language, Hash, SHA256]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Base64 Encoding
id: base64-encoding
slug: /base64-encoding
sidebar_label: 29. Base64 Encoding
sidebar_label: Base64 Encoding
description: Encode and decode Base64 values
keywords: [Wing language, Base64]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Reading and writing files
id: reading-and-writing-files
slug: /reading-and-writing-files
sidebar_label: 30. Reading and writing files
sidebar_label: Reading and writing files
description: Reading and writing files with Wing
keywords: [Wing language, Reading files, Writing files]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/31-directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Directories
id: directories
slug: /directories
sidebar_label: 31. Directories
sidebar_label: Directories
description: Directories
keywords: [Wing language, Directories]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/32-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Testing
id: testing
slug: /testing
sidebar_label: 32. Testing
sidebar_label: Testing
description: Directories
keywords: [Wing language, Directories]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/33-http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: HTTP Client
id: http-client
slug: /http-client
sidebar_label: 33. HTTP Client
sidebar_label: HTTP Client
description: Directories
keywords: [Wing language, HTTP]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/34-http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: HTTP Server
id: http-server
slug: /http-server
sidebar_label: 33. HTTP Server
sidebar_label: HTTP Server
description: Directories
keywords: [Wing language, HTTP]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/35-exec-processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Exec processes
id: exec-processed
slug: /exec-processed
sidebar_label: 35. Exec processes
sidebar_label: Exec processes
description: Exec'ing Processes
keywords: [Wing language, HTTP]
image: /img/wing-by-example.png
Expand Down

0 comments on commit 6de886c

Please sign in to comment.