Skip to content

Commit

Permalink
docs: add custom Prism syntax highlighter to Docs (#4725)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Feb 28, 2025
1 parent 51479c4 commit f934804
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 42 deletions.
4 changes: 2 additions & 2 deletions docs/docs/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class Alice {

When you create a new module, FTL generates a schema that represents your code. For the examples above, the schema would look like:

```
```schema
module alice {
verb echo(String?) String
}
Expand Down Expand Up @@ -250,7 +250,7 @@ Note that the `EchoClient` is generated by FTL and must be imported. Unfortunate

When you create a second module that calls the first one, the schema would look like:

```
```schema
module alice {
export verb echo(String?) String
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/reference/cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MyCron {
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module example {
verb hourly(Unit) Unit
+cron "0 * * * *"
Expand Down Expand Up @@ -107,7 +107,7 @@ class MyCron {
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module example {
verb twiceADay(Unit) Unit
+cron "12h"
Expand Down Expand Up @@ -158,7 +158,7 @@ class MyCron {
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module example {
verb mondays(Unit) Unit
+cron "Mon"
Expand Down
7 changes: 3 additions & 4 deletions docs/docs/reference/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Note that this will likely change significantly in future once JVM supports SQL

In the FTL schema, databases are represented using the `database` keyword with the engine type and name:

```
```schema
module example {
// Database declaration
database postgres testdb
Expand Down Expand Up @@ -138,7 +138,6 @@ module example {
// Custom verb that uses a database query
export verb getUserEmail(Int) String
+calls example.getUser
}
```

Expand Down Expand Up @@ -303,7 +302,7 @@ func Query(ctx context.Context, db MydbHandle) ([]string, error) {

In the FTL schema, the database handle is represented by the `+database calls` annotation on verbs:

```
```schema
module example {
// Database declaration
database postgres mydb
Expand Down Expand Up @@ -371,7 +370,7 @@ func GetEmail(ctx context.Context, id int, query GetUserClient) (string, error)

In the FTL schema, the generated query clients are represented as verbs with the `+database calls` and `+sql query` annotations:

```
```schema
module example {
// Database declaration
database postgres testdb
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/externaltypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ You can also specify mappings for other runtimes:

In the FTL schema, external types are represented as type aliases with the `+typemap` annotation:

```
```schema
module example {
// External type widened to Any
typealias FtlType Any
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Under the hood these HTTP invocations are being mapped to verbs that take a `bui

In the FTL schema, HTTP ingress is represented by the `+ingress` annotation on verbs:

```
```schema
module example {
data GetRequestPathParams {
userId String
Expand Down
15 changes: 9 additions & 6 deletions docs/docs/reference/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ interface InvoicesTopic extends WriteableTopic<Invoice, SinglePartitionMapper> {
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module payments {
// The Invoice data type that will be published to the topic
data Invoice {
Expand Down Expand Up @@ -183,7 +183,7 @@ interface InvoicesTopic extends WriteableTopic<Invoice, PartitionMapper> {
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module payments {
// The Invoice data type that will be published to the topic
data Invoice {
Expand Down Expand Up @@ -238,7 +238,7 @@ void publishInvoice(InvoiceRequest request, InvoicesTopic topic) throws Exceptio
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module payments {
data InvoiceRequest {
invoiceNo String
Expand Down Expand Up @@ -330,14 +330,17 @@ interface InvoicesTopic extends ConsumableTopic<Invoice> {}
</TabItem>
<TabItem value="schema" label="Schema">

```
```schema
module payments {
data InvoiceRequest {
invoiceNo String
}
data Invoice {
invoiceNo String
}
// The topic that is being subscribed to
export topic invoices payments.Invoice
topic invoices payments.Invoice
// A verb that subscribes to the invoices topic
verb sendInvoiceEmail(payments.Invoice) Unit
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/retries.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void recoverPaymentProcessing(CatchRequest<Payment> req) {

In the FTL schema, retry policies are represented by the `+retry` annotation on verbs:

```
```schema
module example {
data Invoice {}
Expand Down
13 changes: 5 additions & 8 deletions docs/docs/reference/secretsconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ HelloResponse hello(HelloRequest helloRequest, @Config("defaultUser") String def

In the FTL schema, configuration values are declared as follows:

```
```schema
module example {
// Configuration declaration
config apiUrl String
config defaultUser example.Username
config defaultUser String
// Using configuration in a verb
verb hello(example.HelloRequest) example.HelloResponse
+config defaultUser
verb hello(Unit) String
+config example.defaultUser
}
```

Expand Down Expand Up @@ -145,7 +142,7 @@ HelloResponse hello(HelloRequest helloRequest, @Secret("apiKey") String apiKey)

In the FTL schema, secrets are declared as follows:

```
```schema
module example {
// Secret declaration
secret apiToken String
Expand Down
20 changes: 10 additions & 10 deletions docs/docs/reference/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ In the FTL schema, these are the primitive types that can be used directly:
| `[T]` | Array of type T |

Example usage in schema:
```
```schema
module example {
data Person {
name String
Expand Down Expand Up @@ -149,7 +149,7 @@ public class Person {

In the FTL schema, data structures are defined using the `data` keyword:

```
```schema
module example {
data Person {
name String
Expand All @@ -160,7 +160,7 @@ module example {

Fields can have optional values by adding a `?` suffix:

```
```schema
module example {
data Person {
name String
Expand Down Expand Up @@ -217,7 +217,7 @@ public class Pair<T, U> {

In the FTL schema, generic types are defined with type parameters:

```
```schema
module example {
data Pair<T, U> {
first T
Expand All @@ -228,7 +228,7 @@ module example {

Generic types can be used in other type definitions:

```
```schema
module example {
data Pair<T, U> {
first T
Expand Down Expand Up @@ -290,7 +290,7 @@ class Dog() : Animal

In the FTL schema, sum types (type enums) are represented as a union of types:

```
```schema
module example {
data Cat {}
Expand All @@ -305,7 +305,7 @@ module example {

When used in other types or verbs, the sum type can be referenced directly:

```
```schema
module example {
verb processAnimal(example.Animal) Unit
}
Expand Down Expand Up @@ -402,7 +402,7 @@ public enum Status {

In the FTL schema, value enums are represented as an enum with string or integer values:

```
```schema
module example {
enum Colour: String {
Red = "red"
Expand Down Expand Up @@ -464,15 +464,15 @@ public class UserID {

In the FTL schema, type aliases are defined using the `typealias` keyword:

```
```schema
module example {
typealias UserID String
}
```

Type aliases can be used in data structures:

```
```schema
module example {
typealias UserID String
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/reference/verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class EchoClass {

In the FTL schema, verbs are declared with their input and output types:

```
```schema
module example {
data EchoRequest {}
Expand All @@ -100,7 +100,7 @@ module example {

Verbs can be exported to make them callable from other modules:

```
```schema
module example {
export verb echo(example.EchoRequest) example.EchoResponse
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public interface TimeClient {

In the FTL schema, verb calls are represented by the `+calls` annotation:

```
```schema
module echo {
data EchoRequest {}
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/reference/visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TimeResponse time() {

In the FTL schema, exported declarations are prefixed with the `export` keyword:

```
```schema
module example {
export data TimeResponse {
time Time
Expand All @@ -87,7 +87,7 @@ module example {

Non-exported declarations are visible only within their module:

```
```schema
module example {
data InternalConfig {
setting String
Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const config: Config = {
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
additionalLanguages: ['java', 'kotlin', 'bash', 'hcl'],
additionalLanguages: ['java', 'kotlin', 'bash', 'hcl', 'schema'],
},
} satisfies Preset.ThemeConfig,
}
Expand Down
Loading

0 comments on commit f934804

Please sign in to comment.