Skip to content

Commit 7415f14

Browse files
jsoversonpkedy
andauthored
Updated copy and added documentation for new features. (#14)
* updated landing page, updated Apex->Apexlang, added task runner doc, added basic template documentation * Docusaurus update * refined copy --------- Co-authored-by: Phil Kedy <[email protected]>
1 parent dcad272 commit 7415f14

18 files changed

+1160
-953
lines changed

docs/customization/project-templates.md

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,70 @@ sidebar_position: 2
44

55
# Project Templates
66

7-
```cli
8-
apex new https://[email protected]/apexlang/codegen.git -p templates/go greeter \
9-
--var module=github.com/apexlang/greeter \
10-
--var package=greeter
7+
The `apex new` command can be used to create a new project from either a basic github repository or from a TypeScript template generator. Programmatic templates are useful when your project needs outgrow a simple `git clone` or directory copy.
8+
9+
To create a new project from a template, use `apex new`:
10+
11+
```sh
12+
apex new <template> <project-name>
1113
```
1214

13-
TODO
15+
When cloning from git repositories, you can use `-p` or `--path` to specify a subdirectory to use as the template source. This lets you keep examples and boilerplate in the same repositories as their main projects.
16+
17+
The following command uses the template located in the `templates/nodejs` directory of the repository housed at [github.com/apexlang/codegen](https://github.com/apexlang/codegen).
18+
19+
```sh
20+
apex new https://github.com/apexlang/codegen.git -p templates/nodejs my-project
21+
```
22+
23+
## Template files and data
24+
25+
Any file ending with a `.tmpl` extension will be processed as a template with data substituted from the user or environment.
26+
27+
This example `package.json` from the nodejs template uses the `name`, `version`, `description`, and `author` variables to fill in the package metadata.
28+
29+
```json
30+
{
31+
"name": "{{.name}}",
32+
"version": "{{.version}}",
33+
"description": "{{.description}}",
34+
"author": "{{.author}}",
35+
"main": "dist/index.js",
36+
"scripts": {
37+
"eslint": "eslint src/service.ts",
38+
"build": "tsc",
39+
"lint": "./node_modules/eslint/bin/eslint.js src --ext .ts",
40+
"fix-lint": "./node_modules/eslint/bin/eslint.js src --ext .ts --fix"
41+
},
42+
"dependencies": {
43+
"@types/uuid": "^8.3.4",
44+
"uuid": "^8.3.2"
45+
},
46+
"devDependencies": {
47+
"@types/node": "16.4.10",
48+
"@typescript-eslint/eslint-plugin": "4.29.0",
49+
"@typescript-eslint/parser": "4.29.0",
50+
"eslint": "7.32.0",
51+
"eslint-plugin-import": "2.23.4",
52+
"ts-node": "10.1.0",
53+
"typescript": "4.3.5"
54+
}
55+
}
56+
```
57+
58+
The data variables can be defined in a `.template` file in the same directory as the template. This file is a YAML file and looks like this:
59+
60+
```yaml
61+
description: A nodejs template
62+
variables:
63+
- name: author
64+
description: The project author
65+
prompt: Please enter the project author
66+
- name: description
67+
description: The project description
68+
prompt: Please enter the project description
69+
- name: version
70+
description: The project version
71+
prompt: Please enter the version
72+
default: 0.0.1
73+
```

docs/customization/task-runner.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Task Definitions
6+
7+
The `apex run` command runs tasks defined in the `tasks` block of an `apex.yaml` configuration file.
8+
9+
The following `apex.yaml` gives us a `greeter` task.
10+
11+
```yaml
12+
tasks:
13+
greeter:
14+
- echo Hello World
15+
- echo Have a great day!
16+
```
17+
18+
Running `apex run greeter` will execute each command in sequence.
19+
20+
```sh
21+
$ apex run greeter
22+
echo Hello World
23+
Hello World
24+
echo Have a great day!
25+
Have a great day!
26+
```
27+
28+
## Environment variables
29+
30+
You can access environment variables from tasks with the familiar `$NAME` syntax, e.g.
31+
32+
```yaml
33+
tasks:
34+
greeter:
35+
- echo $GREETING World
36+
```
37+
38+
Output when run with `GREETING` set:
39+
40+
```
41+
$ GREETING="Bonjour" apex run greeter
42+
echo $GREETING World
43+
Bonjour World
44+
```
45+
46+
## Local configuration
47+
48+
Sometimes environment variables aren't a good fit or you want to reuse apex configuration. In that case, `apex` exposes all of its configuration in variables that follow an `$apex_config_[key]` pattern. This example shows how to use the `greetingPrefix` configuration variable in a task.
49+
50+
```yaml
51+
config:
52+
greetingPrefix: 'Howdy'
53+
tasks:
54+
greeter:
55+
- echo $apex_config_greetingPrefix World
56+
```
57+
58+
Output:
59+
60+
```sh
61+
$ apex run greeter
62+
echo $apex_config_greetingPrefix World
63+
Howdy World
64+
```

docs/embedding.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
sidebar_position: 7
33
---
44

5-
# Embedding Apex into Apps
5+
# Embedding Apexlang into Apps
66

7-
Apex is most commonly used as a code generator for your projects. In some cases, your system may need to read in the information contained in an Apex specification. This could be useful for platforms or tools to inspect specifications dynamically. Some scenarios include:
7+
Apexlang is most commonly used as a code generator for your projects. In some cases, your system may need to read in the information contained in an Apexlang specification. This could be useful for platforms or tools to inspect specifications dynamically. Some scenarios include:
88

99
* Validating or sanitizing input data
1010
* Comparing two versions to detect a breaking change
1111
* Discovering data elements that are sensitive (PCI/DSS) or encrypted
1212

1313
## Libraries
1414

15-
Apex natively supports TypeScript and Go.
15+
Apexlang libraries exist for TypeScript and Go.
1616

17-
* [@apexlang/core](https://github.com/apexlang/apex-js) - TypeScript Apex parser used by the CLI and VS Code extension
18-
* [@apexlang/codegen](https://github.com/apexlang/codegen) - TypeScript code generation modules loaded by the Apex CLI (e.g. `apex generate`)
19-
* [github.com/apexlang/apex-go](https://github.com/apexlang/apex-go) - Go Apex parser for embedding in Go platforms
17+
* [@apexlang/core](https://github.com/apexlang/apex-js) - TypeScript Apexlang parser used by the CLI and VS Code extension
18+
* [@apexlang/codegen](https://github.com/apexlang/codegen) - TypeScript code generation modules loaded by the `apex` CLI (e.g. `apex generate`)
19+
* [github.com/apexlang/apex-go](https://github.com/apexlang/apex-go) - Go Apexlang parser for embedding in Go platforms
2020

2121
## WebAssembly module
2222

23-
To reach a broader set of languages, the Apex Go parser is also released as a WebAssembly module and loadable via a Wasm runtime such as [Wasmtime](https://wasmtime.dev). The module parses and validates an Apex specification and returns a JSON representation that is easier to interpret in languages with JSON support.
23+
To reach a broader set of languages, the Apexlang Go parser is also released as a WebAssembly module and loadable via a Wasm runtime such as [Wasmtime](https://wasmtime.dev). The module parses and validates an Apexlang specification and returns a JSON representation that is easier to interpret in languages with JSON support.
2424

2525
### Download
2626

27-
Two implementations of the Wasm module can be downloaded from the [Apex Go releases page](https://github.com/apexlang/apex-go/releases).
27+
Two implementations of the Wasm module can be downloaded from the [Apexlang Go releases page](https://github.com/apexlang/apex-go/releases).
2828

29-
* **[waPC](https://github.com/apexlang/apex-go/releases/latest/download/apex-wapc.wasm)** - Uses the [waPC protocol](https://wapc.io/docs/spec/) to invoke the Apex parser. This is the easiest method for integration, however you must be using a programming language that has a [waPC host implementation](https://github.com/wapc).
29+
* **[waPC](https://github.com/apexlang/apex-go/releases/latest/download/apex-wapc.wasm)** - Uses the [waPC protocol](https://wapc.io/docs/spec/) to invoke the Apexlang parser. This is the easiest method for integration, however you must be using a programming language that has a [waPC host implementation](https://github.com/wapc).
3030
* **[Core Wasm](https://github.com/apexlang/apex-go/releases/latest/download/apex-parser.wasm)** - Loadable by any programming language with a WebAssembly runtime (e.g. [Wasmtime](https://wasmtime.dev)); however, puts the responsibility of passing in the specification on your application.
3131

32-
Each parser accepts an Apex specification as a string and returns the JSON string represention. The JSON follows [this schema](https://github.com/apexlang/apex-go/blob/main/model.apexlang).
32+
Each parser accepts an Apexlang specification as a string and returns the JSON string represention. The JSON follows [this schema](https://github.com/apexlang/apex-go/blob/main/model.apexlang).
3333

3434
### waPC <small>(apex-wapc.wasm)</small>
3535

@@ -41,15 +41,15 @@ Input formatted as [MsgPack](https://msgpack.org)
4141

4242
```json
4343
{
44-
"source": "... Apex specification as string ..."
44+
"source": "... Apexlang specification as string ..."
4545
}
4646
```
4747

4848
Output formatted as [MsgPack](https://msgpack.org)
4949

5050
```json
5151
{
52-
"namespace": { /* The parsed Apex namespace. See model spec. */ },
52+
"namespace": { /* The parsed Apexlang namespace. See model spec. */ },
5353
/* or */
5454
"errors": [
5555
{
@@ -86,7 +86,7 @@ Input formatted as [MsgPack](https://msgpack.org)
8686

8787
The Wasm module exposes 3 functions:
8888

89-
* `_malloc(size u32) u32` - Allocate memory to pass in Apex specifications
89+
* `_malloc(size u32) u32` - Allocate memory to pass in Apexlang specifications
9090
* `_free(ptr u32)` - Free memory allocated by `_malloc`
9191
* `parse(ptr u32, size u32) u64` - The main parse function that returns a valid JSON representation
9292

@@ -101,24 +101,24 @@ ptr := uintptr(ptrsize >> 32)
101101
size := uint32(ptrsize & 0xFFFFFFFF)
102102
```
103103

104-
Embedding Apex parsing in your application follows these steps:
104+
Embedding Apexlang parsing in your application follows these steps:
105105

106-
1. calls `_malloc` to receive a buffer for the byte count of the Apex specification
107-
2. copies or directly load the Apex specification into the allocated buffer
106+
1. calls `_malloc` to receive a buffer for the byte count of the Apexlang specification
107+
2. copies or directly load the Apexlang specification into the allocated buffer
108108
3. calls `parse` with the buffer pointer and size
109109
4. extract the JSON (or error) string from the buffer returned
110110
5. call `_free` to release the memory allocated by `_malloc` in step 1
111111

112-
If the returned string starts with `error:` then the string represents and error in the parser. Otherwise, it contains a valid JSON representation of your Apex specification.
112+
If the returned string starts with `error:` then the string represents and error in the parser. Otherwise, it contains a valid JSON representation of your Apexlang specification.
113113

114114
#### Resolving imports
115115

116116
If a specification contains imports, the module makes a host call to `apex::resolve` to retrieve the contents of the imported specification.
117117

118-
* `resolve(location_ptr u32, location_size u32, from_ptr u32, from_size u32) u64` - Loads an imported Apex specification
118+
* `resolve(location_ptr u32, location_size u32, from_ptr u32, from_size u32) u64` - Loads an imported Apexlang specification
119119

120-
`location` and `from` are string values. `location` is the specification to load and `from` is the specification performing the import. The Apex CLI installs importable definitions in `~/.apex/definitions` your implementation could load them from alternate locations.
120+
`location` and `from` are string values. `location` is the specification to load and `from` is the specification performing the import. The `apex` CLI installs importable definitions in `~/.apex/definitions` your implementation could load them from alternate locations.
121121

122122
#### Example
123123

124-
[Here is an example](https://github.com/apexlang/apex-go/blob/main/cmd/host/main.go) using [wazero](https://wazero.io/) to invoke the Apex parser.
124+
[Here is an example](https://github.com/apexlang/apex-go/blob/main/cmd/host/main.go) using [wazero](https://wazero.io/) to invoke the Apexlang parser.

docs/generators/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"position": 5,
44
"link": {
55
"type": "generated-index",
6-
"description": "Built-in generators provided by core Apex."
6+
"description": "Built-in generators."
77
}
88
}

docs/generators/go.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ generates:
3737
| Field | Description |
3838
| ----------------------- | --------------------------------------------- |
3939
| `package` (common) | The name of the Go package |
40-
| `aliases` | Maps Apex aliases to specific Go types |
40+
| `aliases` | Maps Apexlang aliases to specific Go types |
4141

4242
#### Callbacks
4343

@@ -51,10 +51,10 @@ generates:
5151
| Class | Description | Override function(s) |
5252
| ----------------------- | --------------------------------------------- |-------------------|
5353
| [`ImportsVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/imports_visitor.ts) | Writes the imports required by the `.go` file. | `importsVisitor` |
54-
| [`InterfaceVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/interface_visitor.ts) | Writes an Go interface for all `@service` and `@dependency` Apex interfaces. | `serviceVisitor`, `dependencyVisitor` |
55-
| [`StructVisitor `](https://github.com/apexlang/codegen/blob/main/src/go/struct_visitor.ts) | Writes a simple Go struct for Apex types. | `structVisitor` |
54+
| [`InterfaceVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/interface_visitor.ts) | Writes an Go interface for all `@service` and `@dependency` Apexlang interfaces. | `serviceVisitor`, `dependencyVisitor` |
55+
| [`StructVisitor `](https://github.com/apexlang/codegen/blob/main/src/go/struct_visitor.ts) | Writes a simple Go struct for Apexlang types. | `structVisitor` |
5656
| [`EnumVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/enum_visitor.ts) | Writes an enum using `const` and various `func`s. | `enumVisitor` |
57-
| [`UnionVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/union_visitor.ts) | Writes an Apex union as a Go struct with optional fields for each declared type. | `unionVisitor` |
57+
| [`UnionVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/union_visitor.ts) | Writes an Apexlang union as a Go struct with optional fields for each declared type. | `unionVisitor` |
5858
| [`AliasVisitor`](https://github.com/apexlang/codegen/blob/main/src/go/alias_visitor.ts) | Writes an alias type to map to an internal or third-party Go type (e.g. UUID) | `aliasVisitor` |
5959

6060
## MainVisitor

docs/generators/openapi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: OpenAPI
44

55
# OpenAPI Specification
66

7-
Generate [Swagger/OpenAPI specification](https://swagger.io/specification/) files using Apex.
7+
Generate [Swagger/OpenAPI specification](https://swagger.io/specification/) files using Apexlang.
88

99
## OpenAPIV3Visitor
1010

docs/getting-started.mdx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ First, make sure you have [Deno](https://github.com/denoland/deno_install) insta
1616

1717
### CLI
1818

19-
The command line interface is a single binary that generates code from Apex documents.
20-
The Apex CLI is installed from the terminal/command prompt by executing the command below.
19+
The command line interface is a single binary that generates code from Apexlang documents.
20+
The `apex` CLI is installed from the terminal/command prompt by executing the command below.
2121

2222
```shell
2323
deno install -A --unstable -f -n apex https://deno.land/x/apex_cli/apex.ts
@@ -33,7 +33,7 @@ Output:
3333
Usage: apex
3434
Version: 0.0.2
3535
Description:
36-
A code generation tool using Apex, an interface definition language (IDL) for modeling software.
36+
A code generation tool using Apexlang, an interface definition language (IDL) for modeling software.
3737
Options:
3838
-h, --help - Show this help.
3939
Commands:
@@ -47,14 +47,14 @@ Output:
4747
completions - Generate shell completions.
4848
```
4949

50-
### VS Code extension
50+
### VS Code extension for the Apexlang IDL
5151

52-
Installing this extension is **recommended** but not required. It enables the following features while editing Apex documents:
52+
Installing this extension is **recommended** but not required. It enables the following features while editing Apexlang documents:
5353

54-
* Syntax highlighting
55-
* Completions
56-
* Parsing and validation checks
57-
* Go to definition
54+
- Syntax highlighting
55+
- Completions
56+
- Parsing and validation checks
57+
- Go to definition
5858

5959
Search for `apexlang` in the extension marketplace and click "Install". You can also build from source from this [GitHub repo](https://github.com/apexlang/vscode-extension).
6060

@@ -68,18 +68,20 @@ code --install-extension apexlang.apexlang
6868

6969
### Next steps
7070

71-
Now your environment is supercharged for cloud-native application development!
71+
Now your environment is supercharged for developing any applications!
7272

7373
<div>
7474
<Link
7575
className="button button--secondary button--lg"
76-
to="/docs/tutorial/create-a-spec">
76+
to="/docs/tutorial/create-a-spec"
77+
>
7778
Begin the tutorial - 5min ⏱️
7879
</Link>
7980
&nbsp;&nbsp;or&nbsp;&nbsp;
8081
<Link
8182
className="button button--secondary button--lg"
82-
to="/docs/specification">
83+
to="/docs/specification"
84+
>
8385
Learn the language - 15min ⏱️
8486
</Link>
85-
</div>
87+
</div>

0 commit comments

Comments
 (0)