Candle Corporation
Published in

Candle Corporation

https://apexlang.io

Apexlang: Project Scaffolding & Code Generation

Generate code, docs, and more from a single source

$ apex new git@github.com:apexlang/codegen.git -p templates/nodejs my-project
Cloning into '/var/folders/pg/h7s94pd90w54hcbjpkvm58240000gn/T/77f11564'...
remote: Enumerating objects: 256, done.
remote: Counting objects: 100% (256/256), done.
remote: Compressing objects: 100% (210/210), done.
remote: Total 256 (delta 54), reused 135 (delta 18), pack-reused 0
Receiving objects: 100% (256/256), 150.38 KiB | 6.27 MiB/s, done.
Resolving deltas: 100% (54/54), done.
? Please enter the project description ›
INFO Writing file my-project/package.json (mode:100644)
INFO Writing file my-project/apex.yaml (mode:100644)
INFO Writing file my-project/apex.axdl (mode:100644)
INFO Writing file my-project/.gitignore (mode:100644)
INFO Writing file my-project/tsconfig.json (mode:100644)
INFO Writing file my-project/.vscode/settings.json (mode:100644)
INFO Writing file my-project/.vscode/tasks.json (mode:100644
spec: apex.axdl
plugins:
- 'https://raw.githubusercontent.com/apexlang/codegen/main/src/typescript/plugin.ts'
namespace "greeting.v1"

interface Greeter {
sayHello(to: Person): string
}

type Person {
firstName: string
lastName: string
}
$ apex generate
INFO Writing file ./src/api.ts (mode:644)
INFO Writing file ./src/interfaces.ts (mode:644)
export interface Greeter {
sayHello(to: Person): string;
}

export class Person {
firstName: string;
lastName: string;
constructor({
firstName = "",
lastName = ""
}: { firstName?: string; lastName?: string } = {}) {
this.firstName = firstName;
this.lastName = lastName;
}
}
import { Greeter, Person } from "./interfaces";

class GreeterImpl implements Greeter {
sayHello(to: Person): string {
return "";
}
}
namespace "greeting.v1"

"A simple greeting service"
interface Greeter {
"Say hello to a Person"
sayHello(to: Person): string
}
"An instance of a person"
type Person {
"The person's first name"
firstName: string
"The person's last name"
lastName: string
}
// A simple greeting service
export interface Greeter {
// Say hello to a Person
sayHello(to: Person): string;
}

// An instance of a person
export class Person {
// The person's first name
firstName: string;
// The person's last name
lastName: string;
[rest snipped...]
}

More generators!

generates:
API.md:
module: https://deno.land/x/apex_codegen/markdown/mod.ts
config:
title: 'My Awesome Project'
# My Awesome Project

Namespace: **`greeting.v1`**

## Interfaces

### **Greeter**

A simple greeting service

- **`sayHello(to: Person) -> string`**: Say hello to a Person

## Types

### **Person**

An instance of a person

- **`firstName: string`** : The person's first name
- **`lastName: string`** : The person's last name

What’s next?

--

--

Blogs from Candle Employees. https://candle.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jarrod Overson

I write about JavaScript, Reverse Engineering, Security, and Credential Stuffing. Also a speaker, O'Reilly Author, creator of Plato, Director at Shape Security.