diff --git a/docs/by-example/13-bytes.md b/docs/by-example/13-bytes.md index 38eaaca0ed9..00ea2c4ac3b 100644 --- a/docs/by-example/13-bytes.md +++ b/docs/by-example/13-bytes.md @@ -29,14 +29,6 @@ log(Json.stringify(base64)); log(Json.stringify(hex)); ``` -```bash title="Wing console output" -# Run locally with wing console -{"_data":{"0":104,"1":101,"2":108,"3":108,"4":111}} -{"_data":{"0":104,"1":101,"2":108,"3":108,"4":111}} -{"_data":{"0":104,"1":101,"2":108,"3":108,"4":111}} -{"_data":{"0":104,"1":101,"2":108,"3":108,"4":111}} -``` - diff --git a/docs/docs/04-winglibs/01-what-are-winglibs.md b/docs/docs/04-winglibs/01-what-are-winglibs.md deleted file mode 100644 index 88dae2004da..00000000000 --- a/docs/docs/04-winglibs/01-what-are-winglibs.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Wing Libraries -id: what-are-winglibs -description: Documentation about Wing libraries (winglibs) -sidebar_label: What are winglibs? -keywords: [Wing reference, Wing libraries, libraries, packaging, packages] ---- - -As you write larger Wing applications, organizing your code becomes increasingly important. -By grouping related functionality and separating code with distinct features, you'll make it easier to find code that implements a particular feature and where to go to change how a feature works. -As the project grows further, you can extract parts into separate libraries that become external dependencies. - -Any Wing project can be packaged as a library, which will export all public types (like classes and structs) so that they can be used by multiple applications. - -Wing libraries are also known as [**winglibs**](https://github.com/winglang/winglibs). - -The [Wing Trusted Library Ecosystem](https://github.com/winglang/winglibs) has an open source list of winglibs you can use including [openai](https://github.com/winglang/winglibs/tree/main/openai), [cognito](https://github.com/winglang/winglibs/tree/main/cognito), [dynamodb](https://github.com/winglang/winglibs/tree/main/dynamodb), and [many more](https://github.com/winglang/winglibs). - -### How to use a Wing library - -Wing libraries ([winglibs](https://github.com/winglang/winglibs)) can be installed using the npm command line tool. - -Here is an example of installing the [wing-redis winglib](https://github.com/winglang/winglibs/tree/main/redis). - -``` -npm i wing-redis -``` - -Then in your Wing source code, the library can be imported by name using a `bring` statement: - -```js -bring "wing-redis" as redis; - -new redis.Redis(); -``` - -Libraries can expose the following kinds of API elements: - -- Classes -- Structs -- Interfaces -- Enums -- Constants (coming soon - see https://github.com/winglang/wing/issues/3606 to track) - -APIs in libraries can also be organized hierarchically for better organization. -For example, a library may split up its API elements between multiple modules (also sometimes called "namespaces"): - -```js -bring "my-wing-payments-library" as payments; - -new payments.charges.Charge(); -new payments.customer.Customer(); -``` diff --git a/docs/docs/04-winglibs/02-using-winglibs.md b/docs/docs/04-winglibs/02-using-winglibs.md deleted file mode 100644 index 9ce484a4338..00000000000 --- a/docs/docs/04-winglibs/02-using-winglibs.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: Using winglibs -id: using-winglibs -description: Documentation for using winglibs -sidebar_label: Importing winglibs -keywords: [Wing reference, Wing libraries, libraries, packaging, packages] ---- - - -Wing libraries ([winglibs](https://github.com/winglang/winglibs)) can be installed using the npm command line tool. - -Here is an example of installing the [redis winglib](https://github.com/winglang/winglibs/tree/main/redis). - -``` -npm i @winglibs/redis -``` - -Then in your Wing source code, the library can be imported by name using a `bring` statement: - -```js -bring "@winglibs/redis" as redis; - -new redis.Redis(); -``` - -Libraries can expose the following kinds of API elements: - -- Classes -- Structs -- Interfaces -- Enums -- Constants (coming soon - see https://github.com/winglang/wing/issues/3606 to track) - -APIs in libraries can also be organized hierarchically for better organization. -For example, a library may split up its API elements between multiple modules (also sometimes called "namespaces"): - -```js -bring "my-wing-payments-library" as payments; - -new payments.charges.Charge(); -new payments.customer.Customer(); -``` diff --git a/docs/docs/04-winglibs/03-creating-winglibs.md b/docs/docs/04-winglibs/03-creating-winglibs.md deleted file mode 100644 index 0b0b6e39f86..00000000000 --- a/docs/docs/04-winglibs/03-creating-winglibs.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: Creating winglibs -id: creating-winglibs -description: Documentation for creating winglibs -sidebar_label: Creating winglibs -keywords: [Wing reference, Wing libraries, libraries, packaging, packages] ---- - -Packaging your own Wing code as a library is straightforward. -Let's walk through it step by step. - -First, check that your project is organized based on how you want to structure your library. -There are two main rules to be aware of: - -1. APIs can only be exported from non-entrypoint files (files that do not end in `.main.w` or `.test.w`). - Entrypoint files are perfect for writing tests and deployment scenarios that can be executed as-is - but if you have classes and other APIs you want to share, they have to be defined in non-entrypoint files (also known as module files). - -2. APIs are organized based on the project's directory structure. - If you want a group of classes to be part of a namespace named "storage", define them in a directory named "storage" (for example, some classes could be defined in `storage/file1.w`, several more in `storage/file2.w`, and so on). - All public APIs defined at the root of your project will be available at top-level namespace in your library. - -Next, run `npm init` to create a `package.json` file with information about your library. -Make sure you fill out the "name", "version", "description", "author", and "license" fields. - -Finally, run `wing pack` at the root of your project directory. -`wing pack` will compile your project and create a .tgz file that can be published to [npm](https://www.npmjs.com/), [GitHub Packages](https://github.com/features/packages), or any other Node.js package managing service. - diff --git a/docs/docs/04-winglibs/_category_.yml b/docs/docs/04-winglibs/_category_.yml deleted file mode 100644 index f1dfdf25377..00000000000 --- a/docs/docs/04-winglibs/_category_.yml +++ /dev/null @@ -1,6 +0,0 @@ -label: Wing Libraries (winglibs) -collapsible: true -collapsed: true -link: - type: generated-index - title: Wing Libraries (winglibs)