Skip to content

Commit 201cc80

Browse files
Adds docs for new PNG/SVG export feature.
1 parent 111a66b commit 201cc80

7 files changed

Lines changed: 66 additions & 40 deletions

File tree

commands/03-server/21-diagrams/31-scripting.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,4 @@ The Structurizr UI provides a small JavaScript API that can be used to script an
1818
- `exportCurrentDiagramKeyToSVG`: Exports the current diagram key to SVG, and returns the resulting SVG markup.
1919
- `getViews()`: Gets an array of objects representing the views in the software architecture model.
2020
- `changeView(viewKey)`: Displays the specified view.
21-
- `getViewKey()`: Gets the key of the current view.
22-
23-
## Puppeteer
24-
25-
The diagram scripting API can be used in conjunction with tools such as Puppeteer (headless Chrome/Chromium),
26-
to automate the export of diagrams from the command line, perhaps as a part of a build process.
27-
The [structurizr-puppeteer repo on GitHub](https://github.com/structurizr/puppeteer) has some code samples of how to do this.
21+
- `getViewKey()`: Gets the key of the current view.

commands/03-server/23-documentation/04-export.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,4 @@ permalink: /server/documentation/export
1111

1212
The documentation export feature will create a single HTML page that includes all documentation currently being displayed. Please note that diagrams with a perspective enabled with not be interactive (you'll be missing the tooltips), and the graph visualisation will be excluded entirely from the export.
1313

14-
## Manual export
15-
1614
When viewing documentation, click the ![HTML filetype](/images/bootstrap-icons/filetype-html.svg) link. This feature may not work if popups are blocked, so please ensure that popups are allowed in your web browser.
17-
18-
## Automated export
19-
20-
Documentation is rendered client-side (i.e. in your web browser), so an automated export is only possible using a web browser
21-
in conjunction with an automation framework such as headless Chrome and Puppeteer.
22-
See the [structurizr-puppeteer repo on GitHub](https://github.com/structurizr/puppeteer) for an example script.

commands/03-server/23-documentation/11-scripting.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,4 @@ permalink: /server/documentation/scripting
1111

1212
The Structurizr UI provides a small JavaScript API that can be used to script and automate certain tasks. This is available under a JavaScript variable called `structurizr.scripting` when viewing the documentation pages. The following functions are provided:
1313

14-
- `exportDocumentationToOfflineHTMLPage(callback)`: Exports the currently loaded documentation to a single HTML page for offline use. The callback function is called when generation of the HTML page has been finished, and the first function argument is the resulting HTML markup.
15-
16-
## Puppeteer
17-
18-
The diagram scripting API can be used in conjunction with tools such as Puppeteer (headless Chrome/Chromium),
19-
to automate the export of documentation from the command line, perhaps as a part of a build process.
20-
The [structurizr-puppeteer repo on GitHub](https://github.com/structurizr/puppeteer) has some code samples of how to do this.
14+
- `exportDocumentationToOfflineHTMLPage(callback)`: Exports the currently loaded documentation to a single HTML page for offline use. The callback function is called when generation of the HTML page has been finished, and the first function argument is the resulting HTML markup.

commands/03-server/51-workspace-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ curl https://structurizr.example.com/api/workspace/123 -H "X-Authorization: 1234
5959

6060
## Notes
6161

62-
Please note that diagrams are rendered client-side (i.e. in your web browser), so this API __does not__ provide access to diagrams. An automated export is only possible using a web browser in conjunction with an automation framework such as headless Chrome and Puppeteer. See the [structurizr-puppeteer repo on GitHub](https://github.com/structurizr/puppeteer) for an example script.
62+
Please note that diagrams are rendered client-side (i.e. in your web browser), so this API __does not__ provide access to diagrams. An automated export is available via the [export PNG/SVG command](/export/png-and-svg).

commands/03-server/71-scripting.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,4 @@ The following functions are provided for diagrams:
2727

2828
And the following functions are provided for documentation:
2929

30-
- `exportDocumentationToOfflineHTMLPage(callback)`: Exports the currently loaded documentation to a single HTML page for offline use. The callback function is called when generation of the HTML page has been finished, and the first function argument is the resulting HTML markup.
31-
32-
## Puppeteer
33-
34-
The diagram scripting API can be used in conjunction with tools such as Puppeteer (headless Chrome/Chromium),
35-
to automate the export of diagrams from the command line, perhaps as a part of a build process.
36-
The [structurizr-puppeteer repo on GitHub](https://github.com/structurizr/puppeteer) has some code samples of how to do this.
30+
- `exportDocumentationToOfflineHTMLPage(callback)`: Exports the currently loaded documentation to a single HTML page for offline use. The callback function is called when generation of the HTML page has been finished, and the first function argument is the resulting HTML markup.

commands/04-export/06-png-and-svg.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,62 @@ has_children: false
88
has_toc: false
99
---
1010

11+
> This feature is currently only available by building from source or using [the preview version of the Java .war file](/binaries#java-war-file).
12+
1113
# PNG and SVG
1214

13-
Structurizr `local` and `server` render PNG/SVG diagrams in your web browser, and therefore exporting these diagrams is not supported from the `export` command.
14-
PNG/SVG diagram exports can instead be automated using headless Chrome and Puppeteer:
15+
Exports PNG or SVG images using the Structurizr browser-based renderer from:
16+
17+
- [A running local instance](#local)
18+
- [A running server instance](#server)
19+
- [A DSL or JSON file](#dsl-or-json-file)
20+
21+
## local
22+
23+
Export PNG/SVG images from a running [local](/local) instance:
24+
25+
```
26+
export -format png|svg -url <url> ...
27+
```
28+
29+
- `url`: The URL must be the _diagrams page_ for the workspace you would like to export (required); for example:
30+
- `http://localhost:8080/workspace/1/diagrams`
31+
- `-output`: The output directory (optional; default=current working directory)
32+
- `-mode`: `light` or `dark` colour scheme (optional; default=`light`)
33+
- `-animation`: `true` to export animation steps, `false` otherwise (optional; default=`false`)
34+
35+
## server
36+
37+
Export PNG/SVG images from a running [server](/server) instance:
38+
39+
```
40+
export -format png|svg -url <url> ...
41+
```
42+
43+
- `url`: The URL must be the _unauthenticated diagrams page_ for the workspace you would like to export (required); for example:
44+
- `http://structurizr.example.com/workspace/1/diagrams` (server with authentication disabled)
45+
- `http://structurizr.example.com/share/1/diagrams` (server with authentication enabled + workspace with public link enabled)
46+
- `http://structurizr.example.com/share/1/c2586b8c-91e5-4d62-b490-186112c51565/diagrams` (server with authentication enabled + workspace with sharing link enabled)
47+
- `-output`: The output directory (optional; default=`.`)
48+
- `-mode`: `light` or `dark` colour scheme (optional; default=`light`)
49+
- `-animation`: `true` to export animation steps, `false` otherwise (optional; default=`false`)
50+
51+
## DSL or JSON file
52+
53+
Export PNG/SVG images from a DSL or JSON file:
54+
55+
```
56+
export -format png|svg -workspace <path> ...
57+
```
58+
59+
- `workspace`: The path or URL to the workspace DSL/JSON file (required)
60+
- `-output`: The output directory (optional; default=workspace directory)
61+
- `-mode`: `light` or `dark` colour scheme (optional; default=`light`)
62+
- `-animation`: `true` to export animation steps, `false` otherwise (optional; default=`false`)
63+
64+
This will export the specified workspace to a [static site](/export/static-site) and export images from that static site. The same [workspace processing](/export/static-site#workspace-processing) applies as when exporting a static site, so you will need to use a JSON file if you have manual layout.
65+
66+
## Notes
1567

16-
- [server - Diagrams - Scripting](/server/diagrams/scripting)
17-
- [server - Documentation - Scripting](/server/documentation/scripting)
18-
- [github.com/structurizr/puppeteer](https://github.com/structurizr/puppeteer) for some example scripts
68+
- This feature uses the Microsoft Playwright framework to drive a headless version of the Chromium browser, and a version of Chromium will be automatically downloaded the first time. This may take some time.
69+
- Playwright requires some additional local dependencies to be available, so this feature isn't currently available via the prebuilt `structurizr/structurizr` Docker image.

commands/04-export/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ Structurizr playground, local, and server.
2020
- -workspace: The path or URL to the workspace JSON/DSL file (required)
2121
- -format (required):
2222
- plantuml: the same as `plantuml/structurizr`
23-
- [plantuml/structurizr](/export/plantuml): exports views to PlantUML.
24-
- [plantuml/c4plantuml](/export/c4plantuml): exports views to C4-PlantUML.
25-
- [mermaid](/export/mermaid): exports views to Mermaid.
26-
- [websequencediagrams](/export/websequencediagrams): exports dynamic views to WebSequenceDiagrams.
27-
- [static](/export/static-site): creates a static HTML site.
23+
- [plantuml/structurizr](/export/plantuml): exports views to PlantUML
24+
- [plantuml/c4plantuml](/export/c4plantuml): exports views to C4-PlantUML
25+
- [mermaid](/export/mermaid): exports views to Mermaid
26+
- [websequencediagrams](/export/websequencediagrams): exports dynamic views to WebSequenceDiagrams
27+
- [static](/export/static-site): creates a static HTML site
28+
- [png|svg](/export/png-and-svg): exports PNG|SVG images, using the Structurizr browser-based renderer
2829
- json: exports the workspace to the Structurizr JSON format
2930
- theme: creates a JSON theme based upon the styles and tags defined in the workspace
3031
- fully qualified class name: provides a way to use a custom exporter (see below)

0 commit comments

Comments
 (0)