Skip to content

Commit e6c7bea

Browse files
minimal documentation for engine extensions
to be expanded
1 parent 8e11c30 commit e6c7bea

File tree

5 files changed

+131
-19
lines changed

5 files changed

+131
-19
lines changed

_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ website:
477477
- text: "Metadata Extensions"
478478
href: docs/extensions/metadata.qmd
479479
- docs/extensions/brand.qmd
480+
- docs/extensions/engine.qmd
480481

481482
- id: reference
482483
title: "Reference"

docs/extensions/brand.qmd

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ title: "Brand Extensions"
44

55
Brand extensions are Quarto extensions that provide a [brand.yml](../authoring/brand.qmd) file and its assets.
66

7-
::: callout-important
8-
9-
Currently, brand extensions merge project-level metadata, so they can only be used with a `_quarto.yml` [project](../projects/quarto-projects.qmd) present in the place where they are installed. This limitation may be lifted in the future.
10-
11-
:::
12-
137
### Quick Start
148

159
Here we'll describe how to create a simple brand extension. We'll use the `quarto create` command to do this. If you are using VS Code, Positron, or RStudio you should execute `quarto create` within their respective integrated Terminal panes.
@@ -68,7 +62,7 @@ color:
6862
dark: "#fff"
6963
```
7064

71-
This is just enough `brand.yml` to enable dark mode. If you preview the `example.qmd` provided in the root of your brand extension
65+
This uses [light and dark colors](../authoring/brand.qmd#light-and-dark-colors) to enable dark mode. If you preview the `example.qmd` provided in the root of your brand extension
7266

7367
```bash
7468
quarto preview example.qmd
@@ -85,15 +79,7 @@ project:
8579
type: default
8680
```
8781
88-
::: {.callout-note}
89-
90-
The example brand.yml is using the unified light and dark brand feature. Documentation for this feature is on the way.
91-
92-
Any color in the color or typography sections of [brand.yml](https://posit-dev.github.io/brand-yml/) can be specified with `light` and `dark` components or as a string. If a string, the value is used for both light and dark modes.
93-
94-
This works for colors only.
95-
96-
:::
82+
The example brand.yml is to demonstrate dark mode.
9783
9884
## How Brand Extensions Work
9985

docs/extensions/engine.qmd

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: "Engine Extensions"
3+
---
4+
5+
Engine extensions are Quarto extensions that provide an execution engine for running code blocks and capturing their output in Quarto documents.
6+
7+
::: callout-important
8+
9+
Currently there is one execution engine per Quarto document, so you can't have some code blocks executed by an engine extension and other code blocks executed by e.g. `jupyter` or `knitr`.
10+
11+
Engine extensions do not allow control over the cell language handlers for [diagrams](/docs/authoring/diagrams.qmd) like `mermaid` and `dot`.
12+
13+
This is likely to improve in the future.
14+
:::
15+
16+
### Quick Start
17+
18+
Here we'll describe how to create a basic engine extension. We'll use the `quarto create` command to do this. If you are using VS Code, Positron, or RStudio you should execute `quarto create` within their respective integrated Terminal panes.
19+
20+
To get started, execute `quarto create extension engine` within the parent directory where you'd like the engine extension to be created:
21+
22+
```{.bash filename="Terminal"}
23+
$ quarto create extension engine
24+
? Extension Name › my-language-engine
25+
? Default cell language name (my-language-engine) › my-language
26+
```
27+
28+
As shown above, you'll be prompted for an engine name and a cell language name for cells, e.g.
29+
30+
````markdown
31+
```{my-language}
32+
x = 42
33+
```
34+
````
35+
36+
The language name will default to the engine name. Type each name and press Enter---the engine extension is then created:
37+
38+
```bash
39+
? Extension Name › my-prerender-scripts
40+
Creating extension at /Users/gordon/src/my-language-engine:
41+
- Created example.qmd
42+
- Created README.md
43+
- Created _extensions/my-language-engine/_extension.yml
44+
- Created .gitignore
45+
- Created src/my-language-engine.ts
46+
? Open With
47+
❯ positron
48+
vscode
49+
rstudio
50+
(don't open)
51+
```
52+
53+
If you are running within VS Code, Positron, or RStudio a new window will open with the extension project.
54+
55+
## Contents of Engine Extensions
56+
57+
The `quarto create extension engine` command has created an `_extensions` directory, which is what gets installed for users of your extension, and a `src` directory containing the TypeScript source.
58+
59+
The `_extensions/my-language-engine/` directory will contain a Quarto extension configuration like this:
60+
61+
``` {.yaml filename="_extensions/my-language-engine/_extension.yml"}
62+
title: My-language-engine
63+
author: Gordon Woodhull
64+
version: 1.0.0
65+
quarto-required: ">=1.9.0"
66+
contributes:
67+
engines:
68+
- path: my-language-engine.js
69+
```
70+
71+
To generate the JavaScript bundle this points to, run
72+
73+
```bash
74+
quarto call build-ts-extension
75+
```
76+
77+
This builds the TypeScript source `src/my-language-engine.ts` against the types and import map distributed with Quarto, and outputs `_extensions/my-language-engine/my-language-engine.js`.
78+
79+
## How Engine Extensions Work
80+
81+
The `ExecutionEngineDiscovery` interface specifies
82+
83+
* an `init` method providing the **Quarto API**[The **Quarto API** is not documented yet. See the Typescript types in [quarto-types](https://github.com/quarto-dev/quarto-cli/tree/main/packages/quarto-types)]{.aside} to the engine
84+
* methods used in determining which engine to use
85+
* a `launch` method which takes the `EngineProjectContext` and provides methods for executing cells and capturing output, and returns an `ExecutionEngineInstance`.
86+
87+
The `ExecutionEngineInstance.execute` method processes the entire markdown of the document after includes and embeds, and before cell language handlers and Pandoc.
88+
89+
For the languages that it claims, it should replace each code block with:
90+
91+
1. If `options.format.execute.echo` is true, the same code block in non-executable syntax.
92+
93+
E.g. if the input is
94+
95+
````markdown
96+
```{{python}}
97+
```
98+
````
99+
100+
Then the output should be
101+
102+
````markdown
103+
``` {.python}
104+
```
105+
````
106+
107+
adding other classes and attributes as appropriate.
108+
109+
If `echo` is false, the code should not be output.
110+
2. Any outputs from executing the code block, depending on `options.format.execute.output`
111+
112+
See [Execution Options](/docs/computations/execution-options.qmd) for more information on execution options.

docs/extensions/metadata.qmd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Metadata extensions are Quarto extensions that provide metadata (YAML objects) t
66

77
::: callout-important
88

9-
Currently, metadata extensions only merge project-level metadata. This limitation will be lifted in the future.
9+
Currently, metadata extensions only merge project-level metadata. (If there is no project, a temporary default project is created in memory.)
10+
11+
This limitation will be lifted in the future.
1012

1113
:::
1214

@@ -60,6 +62,8 @@ Quarto projects using metadata extensions do not need to change their project ty
6062

6163
::: callout-note
6264

63-
As noted above, metadata extensions only merge project-level metadata in the `project` key. This limitation will be lifted in the future.
65+
As noted above, metadata extensions only merge project-level metadata in the `project` key (empty if there is no project).
66+
67+
This limitation will be lifted in the future.
6468

6569
:::

docs/prerelease/1.9/_highlights.qmd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@ Quarto 1.9 includes the following new features:
22

33
- [Privacy-first cookie consent](/docs/websites/website-tools.qmd#cookie-consent): The default for cookie consent has changed to `type: express`, providing opt-in consent that blocks cookies until users explicitly agree. This privacy-conscious default is designed with modern privacy regulations in mind.
44

5-
- [`aria-label` for videos](/docs/authoring/videos.qmd#accessibility-label): Improve accessibility of embedded videos by providing custom descriptive labels for screen readers instead of the default "Video Player" label.
5+
- [`aria-label` for videos](/docs/authoring/videos.qmd#accessibility-label): Improve accessibility of embedded videos by providing custom descriptive labels for screen readers instead of the default "Video Player" label.
6+
7+
- Metadata and brand extensions now work without a `_quarto.yml` project. A temporary default project is created in memory.
8+
9+
- [Engine extensions](/docs/extensions/engine.qmd) allow replacement of the execution engine:
10+
- Julia is now a bundled extension instead of being built-in.
11+
- **quarto-marimo** will soon change from a filter extension to an engine extension.
12+
- New `quarto create extension engine` command.
13+
- New `quarto call build-ts-extension` command.
14+
- New **Quarto API** for engine extensions to use. (This is in flux and will not be documented for the next few releases, but there will be a dev blog post about it.)

0 commit comments

Comments
 (0)