Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(docs): added new api section and refactor to pages #951

Merged
merged 14 commits into from
Jul 8, 2024
20 changes: 20 additions & 0 deletions api_versioned_docs/version-latest/01-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: "API"
id: api
slug: /
sidebar_label: Introduction
description: API documentation for Wing
keywords: [Wing language, api]
---


## Quick links

- [CLI User Manual](/docs/api/cli)
- Learn and explore the Wing Cli
- [Wing Language](/docs/api/language/variable-declaration)
- Dive deeper into the Wing Language, learn how to [declare variables](/docs/api/language/variable-declaration), [functions](/docs/api/language/functions-example), [structs](/docs/api/language/structs) and much more.
- [Standard Library](/docs/api/standard-library)
- API references for the Wing standard library and supported modules
- [Language Reference](/docs/api/language-reference)
- The Wing programming language reference
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
title: "CLI User Manual: Compile, Test, and Run Wing Programs"
title: "CLI User Manual"
id: cli
slug: /cli
sidebar_label: CLI User Manual
description: Wing CLI reference
keywords: [Wing reference, Wing language, language, Wing language spec, Wing programming language, cli]
---

## Compile, Test, and Run Wing Programs

The Wing CLI is a command line interface for Wing. It is used to compile, test, and run Wing
programs in your terminal, and we hope it will become your best friend.

Expand Down Expand Up @@ -75,11 +78,11 @@ is `sim`.

You can use one of the built-in platform providers:

* [Wing Cloud Simulator](../055-platforms/sim.md) - `sim`
* [Terraform/AWS](../055-platforms/tf-aws.md) - `tf-aws`
* [Terraform/Azure](../055-platforms/tf-azure.md) - `tf-azure`
* [Terraform/GCP](../055-platforms/tf-gcp.md) - `tf-gcp`
* [AWS CDK](../055-platforms/awscdk.md) - `@winglang/platform-awscdk`
* [Wing Cloud Simulator](/docs/platforms/sim) - `sim`
* [Terraform/AWS](/docs/platforms/AWS/tf-aws) - `tf-aws`
* [Terraform/Azure](/docs/platforms/microsoft-azure/tf-azure) - `tf-azure`
* [Terraform/GCP](/docs/platforms/google-cloud/tf-gcp) - `tf-gcp`
* [AWS CDK](/docs/platforms/AWS/awscdk) - `@winglang/platform-awscdk`

## Test: `wing test`

Expand Down Expand Up @@ -237,7 +240,7 @@ $ wing pack

This will compile your current Wing directory, and bundle it as a tarball that can be published to [GitHub packages](https://github.com/features/packages) or [npm](https://www.npmjs.com/).

See [Libraries](../05-libraries.md) for more details on packaging and consuming Wing libraries.
See [Libraries](/docs/category/wing-libraries-winglibs) for more details on packaging and consuming Wing libraries.

:::

Expand Down
7 changes: 7 additions & 0 deletions api_versioned_docs/version-latest/03-language/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
label: Wing Language
collapsible: true
collapsed: false
link:
type: generated-index
slug: language
title: Wing Language
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ collapsed: true
link:
type: generated-index
title: Wing Standard Library
slug: standard-library
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@ An extended Web App example including static Website, API Gateway and a Redis da

Review the [Website RFC](https://www.winglang.io/contributing/rfcs/2023-04-16-website-resource) for detailed information.

### Pass variables to the website
You can pass dynamic variables from the main.w file to the website, and recuperate them by fetching the config.js file.
// inside main.w

```ts
bring cloud;

let website = new cloud.Website(path: "./static");
let api = new cloud.Api();

website.addJson("config.json", { api: api.url });
```

inside ./static/index.html

```html
<html lang="en">
<html>
<body>
...
<script>
// Fetch the config file and get the API URL
let ApiUrl;
fetch('/config.json')
.then(response => response.json())
.then(data => {
ApiUrl = data.api;
});
</script>
</body>
</html>
```


### Simulator (`sim`)

sim implementations of `cloud.Website` is using [nodejs express](https://expressjs.com/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ the following properties (given an example intrinsic `@x`):
| `@assert()` | checks a condition and _throws_ if evaluated to false |
| `@dirname` | current source directory |
| `@unsafeCast()` | cast a value into a different type |
| `@nodeof()` | obtain the [tree node](./02-concepts/02-application-tree.md) of a preflight object |
| `@lift()` | explicitly qualify a [lift](./02-concepts/01-preflight-and-inflight.md#explicit-lift-qualification) of a preflight object |
| `@nodeof()` | obtain the [tree node](/docs/concepts/application-tree) of a preflight object |
| `@lift()` | explicitly qualify a [lift](/docs/concepts/inflights) of a preflight object |

> ```TS
> @log("Hello {name}");
Expand Down
8 changes: 8 additions & 0 deletions api_versioned_sidebars/version-latest-sidebars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"defaultSidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}
3 changes: 3 additions & 0 deletions api_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"latest"
]
2 changes: 1 addition & 1 deletion blog/2023-07-18-wing-cloud-launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ backends for existing resources based on the needs of their environment.

The WCL is a major project and in its early days. You can see the coverage of resources and targets
through this [compatibility
matrix](https://www.winglang.io/docs/standard-library/compatibility-matrix) and make sure to "+1"
matrix](https://www.winglang.io/docs/api/standard-library/compatibility-matrix) and make sure to "+1"
the relevant GitHub issue if coverage is missing.

<br/>
Expand Down
4 changes: 2 additions & 2 deletions blog/2023-12-12-magazine-007.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Winglang combines infrastructure and runtime into a single programming model, ma
developer to build serverless applications without having to become a DevOps expert.

Winglang compiles to Terraform + JavaScript and can be deployed on AWS, GCP and Azure (see [support
matrix](https://www.winglang.io/docs/standard-library/compatibility-matrix)).
matrix](https://www.winglang.io/docs/api/standard-library/compatibility-matrix)).

Winglang is designed to be a familiar and friendly language to learn for developers who come from modern object-oriented background, so it will take you [5 minutes](https://github.com/winglang/workshop-react/blob/main/cheatsheet.md) to learn.

Expand Down Expand Up @@ -215,7 +215,7 @@ here](https://youtube.com/playlist?list=PL-P8v-FRassZBWsNoSafL_ReO0JO0xJVm&si=tr
Here are a few segments from the previous shows we thought might be interesting to check out:

- [Containers are finally taking flight](https://youtu.be/3kFcyzKt3MU): In this video from our Wingly Update, Elad and Eyal are playing around with containers in Wing. They show how local simulation works with Docker and how apps can be seamlessly deployed to Kubernetes through Helm. Exciting times!
- [Creating a FIFO Queue](TBD): [Eyal](https://github.com/ekeren) and [Elad](https://github.com/eladcohen) are walking us through on how to create a *FIfo* Queue!
- [Creating a FIFO Queue](https://www.youtube.com/watch?v=7jbm0LXulCA): [Eyal](https://github.com/ekeren) and [Elad](https://github.com/eladcohen) are walking us through on how to create a *FIfo* Queue!
- [Winglang - How to Build Resources](https://youtu.be/wJVT1DaH8lA): In this clip from The Wingly Update #21, Elad walks us through building resources in Winglang. Listen in to get some details on more advanced topics such as sim.State and tokens.

### Winglang Workshops
Expand Down
2 changes: 1 addition & 1 deletion blog/2023-12-21-magazine-006.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ We are back with another issue of the **Wing Inflight Magazine** and excited to
Winglang is an open-source programming language for the cloud. It combines infrastructure and runtime into a single programming model, making it easy for any developer
to build serverless cloud-native applications without having to become a DevOps expert.

Winglang code compiles to Terraform + JavaScript and can be deployed on AWS, GCP and Azure (see [support matrix](https://www.winglang.io/docs/standard-library/compatibility-matrix)).
Winglang code compiles to Terraform + JavaScript and can be deployed on AWS, GCP and Azure (see [support matrix](https://www.winglang.io/docs/api/standard-library/compatibility-matrix)).

Winglang is designed to be a familiar and friendly language to learn for developers who come from modern object-oriented background, so it will take you [5 minutes](https://github.com/winglang/workshop-react/blob/main/cheatsheet.md) to learn.

Expand Down
2 changes: 1 addition & 1 deletion blog/2024-03-13-magazine-008.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ We are back with another issue of the **Wing Inflight Magazine** and excited to

Wing is shipped with a **powerful cloud simulator** which allows developers to write and test complete cloud application without having to deploy anything to the cloud.

The language combines cloud infrastructure ***and*** runtime into a single programming model and **compiles to Terraform/CloudFormation and JavaScript** that are ready to deploy to AWS, GCP and Azure (see [support matrix](https://www.winglang.io/docs/standard-library/compatibility-matrix)).
The language combines cloud infrastructure ***and*** runtime into a single programming model and **compiles to Terraform/CloudFormation and JavaScript** that are ready to deploy to AWS, GCP and Azure (see [support matrix](https://www.winglang.io/docs/api/standard-library/compatibility-matrix)).

We are designing Wing to be **familiar and friendly** for developers who come from modern object-oriented background, so it will take you [5 minutes](https://github.com/winglang/workshop-react/blob/main/cheatsheet.md) to learn.

Expand Down
2 changes: 1 addition & 1 deletion blog/2024-04-19-magazine-009.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ about [Cloudflare](https://github.com/winglang/wing/issues/4298),
[Pulumi](https://github.com/winglang/wing/issues/6272),
[OpenShift](https://github.com/winglang/wing/issues/6273), [Azure
Bicep](https://github.com/winglang/wing/issues/6271). Check out the [compatibility
matrix](https://www.winglang.io/docs/standard-library/compatibility-matrix), add your 👍 to the
matrix](https://www.winglang.io/docs/api/standard-library/compatibility-matrix), add your 👍 to the
relevant issue, and share your use case to help us prioritize!

Platform teams can also create their own custom platforms using CDK constructs. This offers central
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ This example is quite detailed, so we will break it down section by section to f

This module, by convention named `middleware.w`, features a [Winglang preflight](https://www.winglang.io/docs/concepts/inflights#preflight-code) class called `ServiceFactory`. This class encapsulates the following public resources and methods, which are crucial for the middleware's operation:

- `api: [cloud.Api](https://www.winglang.io/docs/standard-library/cloud/api)`: resource from the [Winglang Standard Library](https://www.winglang.io/docs/category/cloud)
- `api: [cloud.Api](https://www.winglang.io/docs/standard-library/cloud/api)`: resource from the [Winglang Standard Library](https://www.winglang.io/docs/api/category/cloud)
- `logger: logging.Logger`: resource, extending the [Winglang libraries](https://www.winglang.io/docs/libraries), which was discussed previously in terms of its utility and possible implementation implementation [here](https://medium.com/itnext/implementing-production-grade-crud-rest-api-in-winglang-7b8f6917efc2)
- `makeRequestHandler()`: [Factory Method](https://en.wikipedia.org/wiki/Factory_method_pattern) that applies the [Template Method Design Pattern](https://en.wikipedia.org/wiki/Template_method_pattern) tailored to each request handler
- `getApiBuilder()`: another [Factory Method](https://en.wikipedia.org/wiki/Factory_method_pattern) this time applying the [Builder Design Pattern](https://en.wikipedia.org/wiki/Builder_pattern) to configure specific resource API calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ These targets contain a combination of provisioning engine and cloud environment

## Portability

The [Wing Cloud Library](/docs/category/cloud) has several classes representing abstracted cloud resources, whose APIs are not specific to a single cloud provider.
The [Wing Cloud Library](/docs/api/category/cloud) has several classes representing abstracted cloud resources, whose APIs are not specific to a single cloud provider.
This allows you to write code that can be deployed to any supported cloud environment or provisioning engine.

Here's an example of a portable code snippet:
Expand All @@ -45,7 +45,7 @@ let bucket = new cloud.Bucket();
```

Each resource needs a dedicated implementation to work on a given compiler target.
A catalog of which resources are supported on each cloud can be found [here](/docs/standard-library/compatibility-matrix).
A catalog of which resources are supported on each cloud can be found [here](/docs/api/standard-library/compatibility-matrix).

### Provisioning engines

Expand Down
59 changes: 46 additions & 13 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const discordUrl = "https://t.winglang.io/discord";

const winglangOrgUrl = "https://github.com/winglang";
const redirects = require('./redirects');

// const { crete} = require('@docusaurus/plugin-client-redirects')

const keywords = [
"Wing language",
Expand Down Expand Up @@ -78,12 +81,14 @@ const config = {
[
"@docusaurus/plugin-client-redirects",
{
redirects: [
{
to: "/docs/",
from: ["/docs/start-here/installation"],
},
],
redirects,
createRedirects(existingPath) {

if (existingPath.includes('/docs/api/standard-library')) {
return [existingPath.replace('/docs/api/standard-library', '/docs/standard-library')];
}
return undefined; // Return a falsy value: no redirect created
},
},
],
[
Expand All @@ -98,7 +103,21 @@ const config = {
includeCurrentVersion: false,
// sidebarPath: require.resolve('./sidebarsCommunity.js'),
// ... other options
},
}
],
[
"@docusaurus/plugin-content-docs",
{
id: "api",
path: "api",
routeBasePath: "docs/api",
editUrl: (params) =>
`${winglangOrgUrl}/wing/tree/main/docs/api/${params.docPath}`,
breadcrumbs: true,
includeCurrentVersion: false,
// sidebarPath: require.resolve('./sidebarsCommunity.js'),
// ... other options
}
],
],
presets: [
Expand Down Expand Up @@ -217,16 +236,30 @@ const config = {
target: "_self",
},
{
href: "https://www.winglang.io/play/",
to: "docs/why-wing",
position: "left",
label: "Playground",
label: "Learn",
className: "header-text-link",
target: "_self",
},
{
to: "docs",
to: "docs/api",
position: "left",
label: "API",
className: "header-text-link",
target: "_self",
},
{
href: "https://github.com/winglang/examples",
position: "left",
label: "Docs",
label: "Examples",
className: "header-text-link",
target: "_blank",
},
{
href: "https://www.winglang.io/play/",
position: "left",
label: "Playground",
className: "header-text-link",
target: "_self",
},
Expand Down Expand Up @@ -303,11 +336,11 @@ const config = {
items: [
{
label: "Language Specification",
to: "/docs/language-reference",
to: "/docs/api/language-reference",
},
{
label: "API Reference",
to: "/docs/category/standard-library",
to: "/docs/api/standard-library",
},
],
},
Expand Down
Loading
Loading