archsight 0.4.3 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +4 -0
- data/docs/configuration.md +6 -0
- data/docs/diagram.md +5 -0
- data/docs/index.md.erb +2 -0
- data/docs/pdf-export.md +118 -0
- data/docs/slide-decks.md +58 -0
- data/lib/archsight/analysis/typst_renderer.rb +25 -78
- data/lib/archsight/assets.rb +37 -1
- data/lib/archsight/cli.rb +37 -0
- data/lib/archsight/diagram/graph/attributes.rb +3 -1
- data/lib/archsight/diagram/graph/node.rb +18 -1
- data/lib/archsight/diagram/layout/expander.rb +75 -3
- data/lib/archsight/diagram/layout/rank_arranger.rb +3 -1
- data/lib/archsight/linter.rb +13 -0
- data/lib/archsight/markdown.rb +17 -1
- data/lib/archsight/pdf/cache.rb +41 -0
- data/lib/archsight/pdf/compiler.rb +69 -0
- data/lib/archsight/pdf/dependency_graph.rb +127 -0
- data/lib/archsight/pdf/document.rb +227 -0
- data/lib/archsight/pdf/embeds.rb +134 -0
- data/lib/archsight/pdf/images.rb +94 -0
- data/lib/archsight/pdf/markdown.rb +217 -0
- data/lib/archsight/pdf/remote_image.rb +122 -0
- data/lib/archsight/pdf/resource_sheet.rb +129 -0
- data/lib/archsight/pdf/sample_document.rb +67 -0
- data/lib/archsight/pdf/tables.rb +72 -0
- data/lib/archsight/pdf/theme.rb +125 -0
- data/lib/archsight/pdf/typst/archsight.typ +152 -0
- data/lib/archsight/pdf/typst.rb +45 -0
- data/lib/archsight/pdf.rb +30 -0
- data/lib/archsight/resources/config.rb +147 -0
- data/lib/archsight/resources/page.rb +8 -0
- data/lib/archsight/slides.rb +88 -0
- data/lib/archsight/version.rb +1 -1
- data/lib/archsight/web/api/openapi/spec.yaml +312 -1
- data/lib/archsight/web/api/page_helpers.rb +2 -0
- data/lib/archsight/web/api/pdf_helpers.rb +46 -0
- data/lib/archsight/web/api/routes.rb +45 -0
- data/lib/archsight/web/public/vue/DocPage-CkTW4dsq.js +1 -0
- data/lib/archsight/web/public/vue/EditorPage-DSxjLS7O.js +35 -0
- data/lib/archsight/web/public/vue/ErrorPage-t0nIF3Mt.js +2 -0
- data/lib/archsight/web/public/vue/GraphView-cjbSm9VK.js +1 -0
- data/lib/archsight/web/public/vue/HomePage-CNTs4DbN.js +2 -0
- data/lib/archsight/web/public/vue/{InstanceRouter-CJSkGdBG.css → InstanceRouter-BCKbW-Wp.css} +1 -1
- data/lib/archsight/web/public/vue/InstanceRouter-DVwn6cFX.js +1 -0
- data/lib/archsight/web/public/vue/KindList-Bc6JpBac.js +1 -0
- data/lib/archsight/web/public/vue/PageView-I-RdgItl.js +1 -0
- data/lib/archsight/web/public/vue/QueryError-C2MuoLnX.js +1 -0
- data/lib/archsight/web/public/vue/ResourceList-B442GZt_.js +2 -0
- data/lib/archsight/web/public/vue/SearchResults-Dnv-7uqa.js +1 -0
- data/lib/archsight/web/public/vue/{WikiPage-TpmM1VAF.css → WikiPage-CuUi4C8v.css} +1 -1
- data/lib/archsight/web/public/vue/WikiPage-D6pLR-8Q.js +3 -0
- data/lib/archsight/web/public/vue/{index-DMhBow5t.js → index-1Vr7UBrY.js} +2 -2
- data/lib/archsight/web/public/vue/index-MTJVvg_J.css +1 -0
- data/lib/archsight/web/public/vue.html +2 -2
- metadata +37 -17
- data/lib/archsight/web/public/vue/DocPage-L0GzDFiV.js +0 -1
- data/lib/archsight/web/public/vue/EditorPage-B3iNbh1u.js +0 -35
- data/lib/archsight/web/public/vue/ErrorPage-Lro5vwhy.js +0 -2
- data/lib/archsight/web/public/vue/GraphView-BRKwxa--.js +0 -1
- data/lib/archsight/web/public/vue/HomePage-DKgI1DXr.js +0 -2
- data/lib/archsight/web/public/vue/InstanceRouter-CX6qxVTm.js +0 -1
- data/lib/archsight/web/public/vue/KindList-C556gf23.js +0 -1
- data/lib/archsight/web/public/vue/PageView-DAqHjL1x.js +0 -1
- data/lib/archsight/web/public/vue/QueryError-DvspMrsh.js +0 -1
- data/lib/archsight/web/public/vue/ResourceList-BZOYa68X.js +0 -2
- data/lib/archsight/web/public/vue/SearchResults-DaaOPG3t.js +0 -1
- data/lib/archsight/web/public/vue/WikiPage-Bfx92Iig.js +0 -3
- data/lib/archsight/web/public/vue/index-B_YGrWD8.css +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2723181f6ae7a954a2bb04948ab141390a8234a5c59671c182f3fd5b0a93794
|
|
4
|
+
data.tar.gz: f775f486c1049cc0db5136939a97a8aa003864f874b029bc33724367fa991c05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07354f46a3af0e3d202531ce61c1b61778da83ce2084ad571cbf84d63727c2402e90ff0377ae4c3c76d3d868c32a80cf20639a8eed63e8d9924a818b6204810b
|
|
7
|
+
data.tar.gz: 2f50d7f09171a3f22bb960158efb79cb1a2fce7c4f0e76acdde11ff72506dc65ba27f27913e8c116e208aa613f137ffc7f3569450441d0ae05cf36aad27c3197
|
data/Dockerfile
CHANGED
|
@@ -25,6 +25,10 @@ ENV GEM_HOME=/usr/local/bundle
|
|
|
25
25
|
ENV GEM_PATH=/usr/local/bundle:/usr/local/lib/ruby/gems/4.0.0
|
|
26
26
|
ENV PATH="/usr/local/bundle/bin:${PATH}"
|
|
27
27
|
|
|
28
|
+
# PDF export (Archsight::Pdf): typst typesets the documents, rsvg-convert turns the diagrams into vector graphics,
|
|
29
|
+
# graphviz draws the dependency graph of a resource
|
|
30
|
+
RUN apk add --no-cache typst rsvg-convert font-liberation font-dejavu font-noto-emoji graphviz
|
|
31
|
+
|
|
28
32
|
RUN mkdir -p /resources
|
|
29
33
|
|
|
30
34
|
ENV ARCHSIGHT_RESOURCES_DIR=/resources
|
data/docs/configuration.md
CHANGED
|
@@ -37,6 +37,12 @@ that is set but empty counts as not set.
|
|
|
37
37
|
| `jira.server` | `ARCHSIGHT_JIRA_SERVER` | Name of the Jira server as Confluence knows it (the `server` parameter of its Jira macro). Needed by the Confluence export when Confluence has more than one Jira server: without it the exported `{jira:KEY}` macros have no server and Confluence shows an error |
|
|
38
38
|
| `jira.server_id` | `ARCHSIGHT_JIRA_SERVER_ID` | Id of that server (the `serverId` parameter). Copy both from the storage format of a Jira macro that already works in Confluence (page "Edit in storage format") |
|
|
39
39
|
| `jira.token` | `ARCHSIGHT_JIRA_TOKEN` | Reserved, nothing uses it yet |
|
|
40
|
+
| `pdf.typst` | `ARCHSIGHT_PDF_TYPST` | Path of the `typst` command that typesets the [PDF export](/doc/pdf-export), if it is not on the `PATH` |
|
|
41
|
+
| `pdf.dot` | `ARCHSIGHT_PDF_DOT` | Path of Graphviz' `dot` command that draws the dependency graph in the [PDF export](/doc/pdf-export), if it is not on the `PATH`. Without it the PDF of a resource has no graph |
|
|
42
|
+
| `pdf.timeout` | `ARCHSIGHT_PDF_TIMEOUT` | Seconds a PDF may take to typeset before it is cancelled. Default `60` |
|
|
43
|
+
| `pdf.remote_images` | `ARCHSIGHT_PDF_REMOTE_IMAGES` | `false` stops the PDF export from fetching images that a page embeds by URL (default: fetched, public hosts only) |
|
|
44
|
+
| `pdf.max_analyses` | `ARCHSIGHT_PDF_MAX_ANALYSES` | How many `![[Analysis/...]]` embeds one PDF may run (each can take as long as its own timeout). Default `5`; further ones are shown as a note |
|
|
45
|
+
| `slides.script_hosts` | `ARCHSIGHT_SLIDES_SCRIPT_HOSTS` | `https://` hosts (space or comma separated) from which an HTML [slide deck](/doc/slide-decks) may load scripts, styles and fonts. Default `https://unpkg.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com` |
|
|
40
46
|
| `import.cache_root` | `ARCHSIGHT_IMPORT_CACHE_ROOT` | Where the GitHub, GitLab and repository imports clone repositories, and what importers of the resources repository get as `cache_root` / `ARCHSIGHT_CACHE_DIR`. Default `~/.cache/archsight/git`; an import's own `import/config/cacheRoot` wins, see [Importers of the Resources Repository](/doc/import#importers-of-the-resources-repository). Every import makes sure the clones are not indexed by Spotlight (macOS): an empty `.metadata_never_index` in `~/.cache/archsight`, or in the cache root when it is elsewhere |
|
|
41
47
|
|
|
42
48
|
## Command line
|
data/docs/diagram.md
CHANGED
|
@@ -145,6 +145,11 @@ hint for near misses), never silently ignored.
|
|
|
145
145
|
| `link` | nodes, containers | `http(s)://…`, `mailto:…` or a relative URL |
|
|
146
146
|
| `resource` | nodes, containers | a resource name (`Archsight:Web`) or `Kind/Name` (`ApplicationService/Archsight:Web`); see *Linking to resources* |
|
|
147
147
|
| `extend` | nodes, containers | `true`, `false`; containers also `height` |
|
|
148
|
+
| `anchor` | containers | `top`, `bottom`, `left`, `right`, `center` |
|
|
149
|
+
|
|
150
|
+
`extend "height"` on a direct child of a `layer` grows it to its tallest sibling. Inside such a box (also through a `boundary` around a `stack`), a `stack` child carrying `extend "height"` takes the extra height and moves the ranks below it down, so e.g. a footer rank lines up across the columns. The child can be a `layer` too; its own `extend "height"` children then fill the layer's new height.
|
|
151
|
+
|
|
152
|
+
`anchor` says where a container's content sits when its box grows: `bottom` (or `top`) when it is made taller, `right` (or `left`) when it is made wider, `center` for the middle. Default: top for `extend "height"`, centered otherwise. It is not inherited, and has no effect on a box whose room is taken by a stack child with `extend "height"`.
|
|
148
153
|
| `shape` | leaves | `rectangle`, `circle`, `cylinder`, `pipe`, `actor`, `file`, `module` |
|
|
149
154
|
| `gap` | containers | pixels (`40`), a percentage (`150%`) or a signed one (`+20%`, `-50%`) |
|
|
150
155
|
| `ranks` | containers | `auto`, `on`, `down`, `right`, `off` |
|
data/docs/index.md.erb
CHANGED
|
@@ -8,6 +8,8 @@ Welcome to the Architecture Documentation System. This documentation covers how
|
|
|
8
8
|
- [Configuration](/doc/configuration) - The configuration file and environment variables for tokens and URLs
|
|
9
9
|
- [Query Syntax](/doc/search) - Search and filter resources
|
|
10
10
|
- [Wiki Pages](/doc/pages) - Author markdown pages and arrange them in the sidebar tree
|
|
11
|
+
- [PDF Export](/doc/pdf-export) - Download pages and resources as PDF, with a Config for the look
|
|
12
|
+
- [Slide Decks](/doc/slide-decks) - Show a finished PDF or HTML deck on a page, listed in a Slides menu
|
|
11
13
|
- [Architecture Modeling](/doc/modeling) - How to model your architecture
|
|
12
14
|
- [REST API Documentation](/docs/api) - JSON API for programmatic access
|
|
13
15
|
- [Diagrams](/doc/diagram) - Render `.asd` diagram files to SVG
|
data/docs/pdf-export.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# PDF Export
|
|
2
|
+
|
|
3
|
+
Every [page](/doc/pages) and every resource can be downloaded as a PDF. The document is typeset by [Typst](https://typst.app),
|
|
4
|
+
so the server (or the machine running the CLI) needs the `typst` command; the container image has it, together with
|
|
5
|
+
`rsvg-convert` (turns diagrams into vector graphics), `dot` of Graphviz (draws the dependency graph) and a few fonts.
|
|
6
|
+
|
|
7
|
+
## Getting a PDF
|
|
8
|
+
|
|
9
|
+
- **Web UI:** the **PDF** button next to **Edit** on a page or resource.
|
|
10
|
+
- **API:** `GET /api/v1/pages/{name}/pdf` and `GET /api/v1/kinds/{kind}/instances/{name}/pdf`, see the [REST API documentation](/docs/api).
|
|
11
|
+
The response has an `ETag` that changes whenever the page, an image, a diagram or the template changes.
|
|
12
|
+
Query parameters: `template` (name of a pdf Config) and `draft=1` (watermark).
|
|
13
|
+
- **CLI:** `archsight pdf <page>` or `archsight pdf Kind/Name`, with `-o file.pdf`, `--template` and `--draft`.
|
|
14
|
+
|
|
15
|
+
Without `typst` the API answers `503` and the button shows the reason.
|
|
16
|
+
|
|
17
|
+
## What is in the document
|
|
18
|
+
|
|
19
|
+
- A **page** is typeset as written: headings, text, tables (with their alignment), task lists, code, images next to the page,
|
|
20
|
+
`asd` diagrams (as vector graphics), `[[links]]` (as their label), `{status:...}` (a coloured box), `{jira:KEY}` (a link
|
|
21
|
+
when `jira.issue_url` is set) and `{emoticon:...}`. Macros that need the running application (`{children}`) are left out.
|
|
22
|
+
Mermaid blocks and draw.io images cannot be drawn on the server: a note stands there (and the Mermaid source).
|
|
23
|
+
- **Tables** have horizontal rules only: a stronger one under the header row and a light one under every other row, no frame
|
|
24
|
+
and no vertical lines, in the muted colour of the Config; the first column is flush with the text.
|
|
25
|
+
- **Live content is the data of the moment of the export**, as in the Confluence export:
|
|
26
|
+
- `![[View/Name]]` and ```` ```view ```` blocks are tables (title, number of items, repeated header row; long columns
|
|
27
|
+
share the width), `` ```requirements `` blocks are the requirements table.
|
|
28
|
+
- `![[Analysis/Name]]` runs the analysis and puts its sections (headings, text, tables, lists, messages) into the document.
|
|
29
|
+
An analysis runs for as long as its own `analysis/timeout` allows, so at most 5 run per document (`pdf.max_analyses`),
|
|
30
|
+
and a result is reused for a minute. A failed analysis shows its error.
|
|
31
|
+
- `![[Kind/Name]]` of another kind is the resource's description.
|
|
32
|
+
- Only an embed on a line of its own (or several, one per line) is content; inside a sentence it stays its name.
|
|
33
|
+
- What cannot be shown (unknown or ambiguous reference, an invalid view or requirements block) is a visible note in the
|
|
34
|
+
document, never blank space. Embeds inside an embedded description are not expanded again.
|
|
35
|
+
- **Images by URL** (``) are fetched by the server so they can go into the PDF. Only public hosts on https/http
|
|
36
|
+
are contacted (never loopback, private or link-local addresses, so the server cannot be used to reach the network
|
|
37
|
+
behind it), at most 10 MB and 10 seconds each, and only real png, jpeg, gif or webp files are used; otherwise the alt text
|
|
38
|
+
is shown. `pdf.remote_images: false` turns this off.
|
|
39
|
+
- Any other **resource** becomes a generated document: its description, its properties, its relations and its
|
|
40
|
+
`architecture/diagram`, and its **dependency graph**, shown first, as on its page (the resources its relations lead to, two steps
|
|
41
|
+
deep, following its own layer and the one below it, nodes coloured by layer), drawn by `dot` in the direction, left to
|
|
42
|
+
right or top to bottom, in which it is larger on the page. A resource without
|
|
43
|
+
relations has no graph, and without `dot` the document is made without it. Properties are a label and value list (related annotations kept together; lists as "a, b";
|
|
44
|
+
multi-line and markdown values as sections of their own). Relations are shown in both directions, **Outgoing** (what this
|
|
45
|
+
resource points to) and **Incoming** (what points to it, read from the other side): the relation is named once, with the
|
|
46
|
+
kind next to it and the resources flowing in two columns, so a resource with many relations stays readable.
|
|
47
|
+
|
|
48
|
+
## Steering the layout with tags
|
|
49
|
+
|
|
50
|
+
Tags of the page (`tags:` in the frontmatter) or of a resource (`architecture/tags`):
|
|
51
|
+
|
|
52
|
+
| Tag | Effect |
|
|
53
|
+
|-----|--------|
|
|
54
|
+
| `pdf:cover` | A cover page (logo band, title, id, version, date, owner) instead of the title block |
|
|
55
|
+
| `pdf:toc` | A table of contents |
|
|
56
|
+
| `pdf:landscape` | Landscape pages |
|
|
57
|
+
| `pdf:draft` | A "draft" watermark on every page |
|
|
58
|
+
| `pdf:no-graph` | Leave the dependency graph out of a resource's document |
|
|
59
|
+
| `pdf:template:<name>` | Use the pdf Config `<name>` instead of `default` |
|
|
60
|
+
| `version:<x>` | The document version in the header (else the page property `Version`, else `1`) |
|
|
61
|
+
|
|
62
|
+
Further page data used by the layout: `title`, `owner` (else `author`), `updated` (else today), and the page properties
|
|
63
|
+
`Document ID` (default `Kind/name`) and `Classification` (red marking in the footer, default from the template).
|
|
64
|
+
|
|
65
|
+
## The look: Config
|
|
66
|
+
|
|
67
|
+
A `Config` resource (layer *Other*) holds settings of a feature of the tool, kept with the model; `config/type` says
|
|
68
|
+
which feature. The PDF export reads the Configs of type `pdf`: colours, fonts, logo and the text around the pages. The one
|
|
69
|
+
named `default` is used for every document that does not name another (`pdf:template:<name>`); `brand`, `PDF:brand` and
|
|
70
|
+
`Config:PDF:brand` all name the same Config. Without any a neutral look is used. A Config of another type is never used
|
|
71
|
+
for the PDF, so every feature can have its own `default`. (The per-user file with tokens and URLs stays
|
|
72
|
+
[`~/.config/archsight/archsight.yaml`](/doc/configuration).)
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
apiVersion: architecture/v1alpha1
|
|
76
|
+
kind: Config
|
|
77
|
+
metadata:
|
|
78
|
+
name: Config:PDF:default
|
|
79
|
+
annotations:
|
|
80
|
+
config/type: pdf
|
|
81
|
+
pdf/color-primary: "#1f3a5f"
|
|
82
|
+
pdf/color-accent: "#2f7fd1"
|
|
83
|
+
pdf/logo: assets/logo.svg
|
|
84
|
+
pdf/logo-light: assets/logo-white.svg
|
|
85
|
+
pdf/footer-text: Generated with Archsight
|
|
86
|
+
pdf/classification: Internal
|
|
87
|
+
pdf/font-body: Open Sans
|
|
88
|
+
pdf/font-dir: assets/fonts
|
|
89
|
+
spec: {}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Annotation | Meaning |
|
|
93
|
+
|------------|---------|
|
|
94
|
+
| `config/type` | `pdf` for these settings |
|
|
95
|
+
| `pdf/color-primary`, `-accent`, `-text`, `-muted`, `-ok`, `-warn`, `-danger` | Hex colours (`#rrggbb`) |
|
|
96
|
+
| `pdf/font-body`, `-heading`, `-mono` | Font families, tried before the built-in fallbacks |
|
|
97
|
+
| `pdf/font-dir` | Directory (relative to the resources directory) with font files (ttf, otf) that ship with the model |
|
|
98
|
+
| `pdf/logo`, `pdf/logo-light` | svg or png, relative to the resources directory. `logo` is shown on white (page header), `logo-light` on the cover band |
|
|
99
|
+
| `pdf/footer-text`, `pdf/classification` | Texts in the footer of every page |
|
|
100
|
+
| `pdf/header-meta` | Parts of the header line: `id, version, date, owner` |
|
|
101
|
+
| `pdf/lang` | Language of the fixed texts: `en` or `de` |
|
|
102
|
+
| `pdf/paper`, `pdf/margin` | `a4`, `a5` or `us-letter`; horizontal margin such as `16mm` |
|
|
103
|
+
|
|
104
|
+
Values are checked when they are loaded (and by `archsight lint`): something that is not a colour, a font name or a length is
|
|
105
|
+
ignored and the default is used.
|
|
106
|
+
|
|
107
|
+
## Seeing the look
|
|
108
|
+
|
|
109
|
+
The page of a Config of type `pdf` shows its settings as they look (the colours, the fonts, the logo on white and on
|
|
110
|
+
the cover band, the page settings) and, beside them, a **preview**: a fixed sample document (a cover page and a page with
|
|
111
|
+
headings, a list, a quote, a table with status badges and code) typeset by the server with exactly these settings, one
|
|
112
|
+
tab for the cover and one for the page. It shows the saved Config; after an edit the page typesets it again.
|
|
113
|
+
The same sample is `GET /api/v1/kinds/Config/instances/{name}/preview` (`?part=cover` or `?part=page` for one page).
|
|
114
|
+
|
|
115
|
+
## Settings
|
|
116
|
+
|
|
117
|
+
`pdf.typst` (`ARCHSIGHT_PDF_TYPST`) is the path of the `typst` command if it is not on the `PATH`, `pdf.dot` (`ARCHSIGHT_PDF_DOT`) the same for `dot`, `pdf.timeout`
|
|
118
|
+
(`ARCHSIGHT_PDF_TIMEOUT`) the seconds a document may take (default 60), `pdf.remote_images` (`ARCHSIGHT_PDF_REMOTE_IMAGES`) `false` to never fetch images by URL, `pdf.max_analyses` (`ARCHSIGHT_PDF_MAX_ANALYSES`) the number of analyses one document may run (default 5). See [Configuration](/doc/configuration).
|
data/docs/slide-decks.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Slide Decks
|
|
2
|
+
|
|
3
|
+
A [page](/doc/pages) can show a finished slide deck above its text. Archsight does not make or render slides: the deck is
|
|
4
|
+
the file your slide tool produced, and the page is its summary. That works for every tool that can write a PDF or one
|
|
5
|
+
self-contained HTML page (Slidev, reveal.js, Marp, PowerPoint, Keynote, Google Slides, ...).
|
|
6
|
+
|
|
7
|
+
## Layout
|
|
8
|
+
|
|
9
|
+
One folder per deck, and one menu that lists them, so a large collection stays orderly:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
resources/slides/
|
|
13
|
+
menu.yaml # a PageMenu "Slides": spec.contains.pages lists the decks in display order
|
|
14
|
+
2026-06-08-guardrails/
|
|
15
|
+
2026-06-08-guardrails.md # the page: frontmatter and a summary
|
|
16
|
+
deck.pdf # the deck (or deck.html)
|
|
17
|
+
cover.png # optional poster image
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
A deck page is an ordinary page: it is searchable, can link and embed, has an owner and tags, and is edited and exported
|
|
21
|
+
like any other. Page names are unique across the resources, so name the page after its folder rather than `index.md`.
|
|
22
|
+
Only `*.yaml` files are loaded, so the menu is `menu.yaml`. A deck missing from the menu appears under "Unsorted" and is
|
|
23
|
+
reported by `archsight lint`.
|
|
24
|
+
|
|
25
|
+
## Frontmatter
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
---
|
|
29
|
+
title: Guardrails for the Target Picture
|
|
30
|
+
owner: Architecture Team
|
|
31
|
+
slides: deck.pdf # or deck.html, a file next to the page
|
|
32
|
+
cover: cover.png # optional; with a cover the page shows a poster and loads the deck on a click
|
|
33
|
+
---
|
|
34
|
+
The summary of the deck, in markdown.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`slides` and `cover` are resolved like images (relative to the page, never outside the resources directory). The page shows
|
|
38
|
+
the deck in a frame with **Full screen**, **Open** and **Download** links. The page's own PDF button still exports the
|
|
39
|
+
summary text. Without a cover the deck is shown right away.
|
|
40
|
+
|
|
41
|
+
## HTML decks run in a sandbox
|
|
42
|
+
|
|
43
|
+
An HTML deck is a program written by someone else, so it is served by `GET /api/v1/decks/<path>` (not as an image or asset)
|
|
44
|
+
and only with a `Content-Security-Policy` that starts with `sandbox allow-scripts` and has no `allow-same-origin`: the deck
|
|
45
|
+
cannot read the API, cookies or storage of Archsight, also when its file is opened on its own, and it cannot load data from
|
|
46
|
+
other hosts (`connect-src` allows only `blob:` and `data:`). Scripts, styles and fonts may be loaded from the hosts of
|
|
47
|
+
the setting `slides.script_hosts` (`ARCHSIGHT_SLIDES_SCRIPT_HOSTS`, `https://` hosts separated by spaces or commas), by default
|
|
48
|
+
`unpkg.com`, `cdn.jsdelivr.net` and `cdnjs.cloudflare.com`. Images
|
|
49
|
+
and media must be inside the file (`data:` or `blob:`).
|
|
50
|
+
|
|
51
|
+
PDF decks are served inline with `nosniff` and shown by the browser's own viewer.
|
|
52
|
+
|
|
53
|
+
## Making the file
|
|
54
|
+
|
|
55
|
+
- **Slidev:** `slidev export` for a PDF, or any tool that bundles the deck into one HTML file. A multi-file `dist/` folder
|
|
56
|
+
is not supported yet.
|
|
57
|
+
- **PowerPoint, Keynote, Google Slides:** export as PDF.
|
|
58
|
+
- Files are limited to 25 MB.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../markdown"
|
|
4
|
+
require_relative "../pdf/typst"
|
|
5
|
+
require_relative "../pdf/markdown"
|
|
4
6
|
require_relative "../diagram"
|
|
5
7
|
|
|
6
8
|
module Archsight
|
|
@@ -10,20 +12,18 @@ module Archsight
|
|
|
10
12
|
# All text is emitted as Typst string literals (`#"..."`) and structure as
|
|
11
13
|
# function calls (`#strong[...]`), so no content can be mistaken for markup.
|
|
12
14
|
class TypstRenderer
|
|
15
|
+
include Archsight::Pdf::Typst
|
|
16
|
+
|
|
13
17
|
ROW_LIMIT = 10
|
|
14
18
|
HEADING_OFFSET = 2 # section level 0 becomes a level-2 heading, the analysis name is level 1
|
|
15
|
-
LANGUAGE = /\A[A-Za-z0-9+#-]+\z/
|
|
16
19
|
MESSAGE_FILL = { error: "rgb(\"#fde8e8\")", warning: "rgb(\"#fff3cc\")", info: "rgb(\"#ddeeff\")" }.freeze
|
|
17
|
-
SYMBOLS = {
|
|
18
|
-
ndash: "–", mdash: "—", hellip: "…", laquo: "«", raquo: "»", laquo_space: "« ", raquo_space: " »",
|
|
19
|
-
lsquo: "‘", rsquo: "’", ldquo: "“", rdquo: "”"
|
|
20
|
-
}.freeze
|
|
21
20
|
|
|
22
21
|
PREAMBLE = <<~TYPST
|
|
23
22
|
#set document(title: "Archsight analysis")
|
|
24
23
|
#set page(paper: "a4", margin: 2cm, numbering: "1")
|
|
25
24
|
#set text(size: 10pt)
|
|
26
25
|
#show raw.where(block: true): it => block(fill: luma(245), inset: 8pt, radius: 3pt, width: 100%, it)
|
|
26
|
+
#set table(stroke: (x, y) => if y == 0 { (bottom: 0.7pt + luma(150)) } else { (bottom: 0.4pt + luma(220)) }, inset: (x, y) => (left: if x == 0 { 0pt } else { 6pt }, right: 6pt, y: 6pt))
|
|
27
27
|
TYPST
|
|
28
28
|
|
|
29
29
|
# @param results [Array<Archsight::Analysis::Result>]
|
|
@@ -31,10 +31,12 @@ module Archsight
|
|
|
31
31
|
# @param template [String, nil] Typst file to import instead of the built-in layout. It must define
|
|
32
32
|
# `archsight-report` (a show rule for the document) and `analysis-result` (one call per analysis,
|
|
33
33
|
# with the data sections as a dictionary and the other sections as body).
|
|
34
|
-
|
|
34
|
+
# @param full [Boolean] show every table row and list item, without the error backtrace of `verbose`
|
|
35
|
+
def initialize(results, verbose: false, template: nil, full: false)
|
|
35
36
|
@results = results
|
|
36
37
|
@verbose = verbose
|
|
37
38
|
@template = template
|
|
39
|
+
@full = full
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
# @return [String] Typst source
|
|
@@ -44,6 +46,17 @@ module Archsight
|
|
|
44
46
|
[PREAMBLE, title, summary, *@results.map { |result| render_result(result) }].join("\n")
|
|
45
47
|
end
|
|
46
48
|
|
|
49
|
+
# One section of a result as Typst markup (nil for data that only templates use)
|
|
50
|
+
# @param heading_offset [Integer] added to the level of a heading section
|
|
51
|
+
def section(section, heading_offset: HEADING_OFFSET)
|
|
52
|
+
render_section(section, heading_offset)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# The error of a failed result as Typst markup
|
|
56
|
+
def error(result)
|
|
57
|
+
error_block(result)
|
|
58
|
+
end
|
|
59
|
+
|
|
47
60
|
private
|
|
48
61
|
|
|
49
62
|
def title
|
|
@@ -120,9 +133,9 @@ module Archsight
|
|
|
120
133
|
lines.join("\n\n")
|
|
121
134
|
end
|
|
122
135
|
|
|
123
|
-
def render_section(section)
|
|
136
|
+
def render_section(section, heading_offset = HEADING_OFFSET)
|
|
124
137
|
case section[:type]
|
|
125
|
-
when :heading then "#heading(level: #{[section[:level] +
|
|
138
|
+
when :heading then "#heading(level: #{[section[:level] + heading_offset, 6].min})[#{str(section[:text])}]"
|
|
126
139
|
when :text then markdown(section[:content])
|
|
127
140
|
when :table then table(section[:headers], section[:rows])
|
|
128
141
|
when :list then list(section[:items])
|
|
@@ -139,15 +152,14 @@ module Archsight
|
|
|
139
152
|
|
|
140
153
|
# A template produces a document to hand out, so it gets every row
|
|
141
154
|
def full?
|
|
142
|
-
@verbose || !@template.nil?
|
|
155
|
+
@verbose || @full || !@template.nil?
|
|
143
156
|
end
|
|
144
157
|
|
|
145
158
|
def table(headers, rows)
|
|
146
159
|
shown = full? ? rows : rows.first(ROW_LIMIT)
|
|
147
|
-
head = headers.map { |header| "[#
|
|
160
|
+
head = headers.map { |header| "[#text(weight: \"semibold\")[#{str(header)}]]" }
|
|
148
161
|
cells = shown.flat_map { |row| headers.each_index.map { |i| "[#{str(row[i])}]" } }
|
|
149
|
-
out = "#table(columns: #{headers.size},
|
|
150
|
-
"table.header(#{head.join(", ")}), #{cells.join(", ")})"
|
|
162
|
+
out = "#table(columns: #{headers.size}, table.header(#{head.join(", ")}), #{cells.join(", ")})"
|
|
151
163
|
out += "\n\n#emph[#{str("...and #{rows.size - ROW_LIMIT} more rows")}]" if shown.size < rows.size
|
|
152
164
|
out
|
|
153
165
|
end
|
|
@@ -172,73 +184,8 @@ module Archsight
|
|
|
172
184
|
[message_block(:error, "Diagram could not be rendered: #{e.message}"), raw(source, "asd")].join("\n\n")
|
|
173
185
|
end
|
|
174
186
|
|
|
175
|
-
def raw(source, lang)
|
|
176
|
-
lang_arg = lang.to_s.match?(LANGUAGE) ? ", lang: #{lit(lang)}" : ""
|
|
177
|
-
"#raw(#{lit(source.to_s.chomp)}, block: true#{lang_arg})"
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# A Typst string literal, for use as a function argument
|
|
181
|
-
def lit(text)
|
|
182
|
-
escaped = text.to_s.delete("\r").gsub(/[\\"]/) { "\\#{Regexp.last_match(0)}" }.gsub("\n", "\\n")
|
|
183
|
-
"\"#{escaped}\""
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# A Typst string literal as markup, for use inside content
|
|
187
|
-
def str(text)
|
|
188
|
-
"##{lit(text)}"
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# ---- markdown -> Typst
|
|
192
|
-
|
|
193
187
|
def markdown(source, inline: false)
|
|
194
|
-
|
|
195
|
-
out = blocks(root.children)
|
|
196
|
-
inline ? out.gsub(/\n\n+/, " #linebreak() ") : out
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def blocks(elements)
|
|
200
|
-
elements.filter_map { |node| block(node) }.join("\n\n")
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
def block(node)
|
|
204
|
-
case node.type
|
|
205
|
-
when :p then inlines(node.children)
|
|
206
|
-
when :header then "#heading(level: #{[node.options[:level] + 1, 6].min})[#{inlines(node.children)}]"
|
|
207
|
-
when :codeblock then raw(node.value, node.options[:lang])
|
|
208
|
-
when :blockquote then "#quote(block: true)[#{blocks(node.children)}]"
|
|
209
|
-
when :ul then "#list(#{node.children.map { |li| "[#{blocks(li.children)}]" }.join(", ")})"
|
|
210
|
-
when :ol then "#enum(#{node.children.map { |li| "[#{blocks(li.children)}]" }.join(", ")})"
|
|
211
|
-
when :hr then "#line(length: 100%)"
|
|
212
|
-
when :table then markdown_table(node)
|
|
213
|
-
when :blank, :html_element, :xml_comment then nil
|
|
214
|
-
else inlines(node.children) unless node.children.empty?
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
def markdown_table(node)
|
|
219
|
-
rows = node.children.flat_map(&:children)
|
|
220
|
-
cells = rows.map { |tr| tr.children.map { |td| "[#{inlines(td.children)}]" } }
|
|
221
|
-
width = cells.map(&:size).max || 1
|
|
222
|
-
"#table(columns: #{width}, inset: 5pt, stroke: 0.5pt + luma(200), #{cells.flatten.join(", ")})"
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def inlines(elements)
|
|
226
|
-
elements.map { |node| inline(node) }.join
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def inline(node)
|
|
230
|
-
case node.type
|
|
231
|
-
when :text then str(node.value)
|
|
232
|
-
when :em then "#emph[#{inlines(node.children)}]"
|
|
233
|
-
when :strong then "#strong[#{inlines(node.children)}]"
|
|
234
|
-
when :codespan then "#raw(#{lit(node.value)})"
|
|
235
|
-
when :a then "#link(#{lit(node.attr["href"])})[#{inlines(node.children)}]"
|
|
236
|
-
when :br then "#linebreak()"
|
|
237
|
-
when :entity then str(node.value.char)
|
|
238
|
-
when :smart_quote, :typographic_sym then str(SYMBOLS.fetch(node.value, node.value.to_s))
|
|
239
|
-
when :html_element then inlines(node.children)
|
|
240
|
-
else inlines(node.children)
|
|
241
|
-
end
|
|
188
|
+
Archsight::Pdf::Markdown.new(heading_offset: 1, diagram: method(:diagram)).render(source, inline: inline)
|
|
242
189
|
end
|
|
243
190
|
end
|
|
244
191
|
end
|
data/lib/archsight/assets.rb
CHANGED
|
@@ -34,6 +34,13 @@ module Archsight
|
|
|
34
34
|
".drawio" => "application/xml",
|
|
35
35
|
".asd" => "image/svg+xml" # served rendered, see the assets route
|
|
36
36
|
}.freeze
|
|
37
|
+
# Finished slide decks (see `page/slides`): a PDF, or one self-contained HTML page. They are served by their own door
|
|
38
|
+
# (`/api/v1/decks/<path>`), never as an image, because an HTML deck runs script (it is sandboxed when served).
|
|
39
|
+
DECK_TYPES = {
|
|
40
|
+
".pdf" => "application/pdf",
|
|
41
|
+
".html" => "text/html; charset=utf-8"
|
|
42
|
+
}.freeze
|
|
43
|
+
DECKS_PREFIX = "/api/v1/decks/"
|
|
37
44
|
DRAWIO = ".drawio"
|
|
38
45
|
ASD = ".asd"
|
|
39
46
|
|
|
@@ -105,8 +112,24 @@ module Archsight
|
|
|
105
112
|
# @param path [String] relative to the resources directory, as received (it is normalized here, so callers cannot forget to)
|
|
106
113
|
# @return [String, nil] absolute path, nil if there is no such servable asset
|
|
107
114
|
def file_for(path, resources_dir:)
|
|
115
|
+
servable(path, TYPES, resources_dir)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Like #file_for for a slide deck (PDF or HTML)
|
|
119
|
+
def deck_file_for(path, resources_dir:)
|
|
120
|
+
servable(path, DECK_TYPES, resources_dir)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Why a normalized path is not served as a deck: :type or :missing; nil if it is served
|
|
124
|
+
def deck_problem(path, resources_dir:)
|
|
125
|
+
return :type unless DECK_TYPES.key?(File.extname(path).downcase)
|
|
126
|
+
|
|
127
|
+
deck_file_for(path, resources_dir: resources_dir) ? nil : :missing
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def servable(path, types, resources_dir)
|
|
108
131
|
normalized = normalize(path)
|
|
109
|
-
return nil unless normalized &&
|
|
132
|
+
return nil unless normalized && types.key?(File.extname(normalized).downcase)
|
|
110
133
|
|
|
111
134
|
root = File.realpath(resources_dir)
|
|
112
135
|
real = File.realpath(File.join(root, normalized))
|
|
@@ -119,6 +142,19 @@ module Archsight
|
|
|
119
142
|
TYPES.fetch(File.extname(path).downcase)
|
|
120
143
|
end
|
|
121
144
|
|
|
145
|
+
def deck_content_type(path)
|
|
146
|
+
DECK_TYPES.fetch(File.extname(path).downcase)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def html_deck?(path)
|
|
150
|
+
File.extname(path).casecmp?(".html")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# URL under which the API serves a normalized deck path
|
|
154
|
+
def deck_url_for(path)
|
|
155
|
+
DECKS_PREFIX + path.split("/").map { |segment| ERB::Util.url_encode(segment) }.join("/")
|
|
156
|
+
end
|
|
157
|
+
|
|
122
158
|
def drawio?(path)
|
|
123
159
|
File.extname(path).casecmp?(DRAWIO)
|
|
124
160
|
end
|
data/lib/archsight/cli.rb
CHANGED
|
@@ -356,6 +356,43 @@ module Archsight
|
|
|
356
356
|
exit 1
|
|
357
357
|
end
|
|
358
358
|
|
|
359
|
+
desc "pdf TARGET", "Export a page or resource as PDF (needs typst)"
|
|
360
|
+
long_desc <<~DESC
|
|
361
|
+
Typesets a page (TARGET is its name) or any other resource (TARGET is Kind/Name) as a PDF with Typst, the same
|
|
362
|
+
document the PDF button of the web UI downloads. The look comes from the Config of type pdf named default (or --template),
|
|
363
|
+
the tags pdf:cover, pdf:toc, pdf:landscape, pdf:draft and pdf:template:<name> steer the layout. The typst command
|
|
364
|
+
is taken from the PATH, or from ARCHSIGHT_PDF_TYPST / `pdf.typst` in ~/.config/archsight/archsight.yaml.
|
|
365
|
+
See the PDF Export page of the documentation.
|
|
366
|
+
DESC
|
|
367
|
+
option :output, aliases: "-o", type: :string, desc: "Output file (default: <name>.pdf in the current directory)"
|
|
368
|
+
option :template, type: :string, desc: "Name of the pdf Config to use (default: the tag or `default`)"
|
|
369
|
+
option :draft, type: :boolean, default: false, desc: "Add the draft watermark"
|
|
370
|
+
def pdf(target)
|
|
371
|
+
configure_resources
|
|
372
|
+
require "archsight/database"
|
|
373
|
+
require "archsight/pdf"
|
|
374
|
+
|
|
375
|
+
db = Archsight::Database.new(Archsight.resources_dir, compute_annotations: false)
|
|
376
|
+
begin
|
|
377
|
+
db.reload!
|
|
378
|
+
rescue Archsight::ResourceError => e
|
|
379
|
+
display_error_with_context(e.to_s)
|
|
380
|
+
exit 1
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
kind, name = target.include?("/") ? target.split("/", 2) : ["Page", target]
|
|
384
|
+
resource = Archsight::Resources[kind] && (db.instance_by_kind(kind, name) || db.instance_by_alias(kind, name))
|
|
385
|
+
abort "Error: #{kind} '#{name}' not found" unless resource
|
|
386
|
+
|
|
387
|
+
document = Archsight::Pdf.document(db, resource, template: options[:template], draft: options[:draft])
|
|
388
|
+
file = options[:output] || document.filename
|
|
389
|
+
File.binwrite(file, Archsight::Pdf.compile(document))
|
|
390
|
+
puts "Wrote #{file}"
|
|
391
|
+
rescue Archsight::Pdf::Error => e
|
|
392
|
+
warn "Error: #{e.message}"
|
|
393
|
+
exit 1
|
|
394
|
+
end
|
|
395
|
+
|
|
359
396
|
desc "module SUBCOMMAND", "Module analysis commands (e.g. module graph PATH)"
|
|
360
397
|
subcommand "module", ModuleCLI
|
|
361
398
|
|
|
@@ -27,13 +27,14 @@ module Archsight
|
|
|
27
27
|
NODE = %w[label tint link resource extend].freeze
|
|
28
28
|
LEAF_KINDS = %i[component application api database queue actor file].freeze
|
|
29
29
|
LEAF = (NODE + %w[shape]).freeze
|
|
30
|
-
CONTAINER = (NODE + %w[gap ranks columns]).freeze
|
|
30
|
+
CONTAINER = (NODE + %w[gap ranks columns anchor]).freeze
|
|
31
31
|
EDGE = %w[label style relation tint].freeze
|
|
32
32
|
DATAFLOW = %w[label color].freeze
|
|
33
33
|
|
|
34
34
|
EDGE_STYLES = %w[straight orthogonal].freeze
|
|
35
35
|
LEAF_EXTEND = %w[true false].freeze
|
|
36
36
|
CONTAINER_EXTEND = %w[true false height].freeze
|
|
37
|
+
ANCHORS = %w[top bottom left right center].freeze
|
|
37
38
|
|
|
38
39
|
# `40` (pixels), `150%` (of the default), `+20%`/`-50%` (relative);
|
|
39
40
|
# see `GapSpec`.
|
|
@@ -116,6 +117,7 @@ module Archsight
|
|
|
116
117
|
when "tint" then check_value!(key, value, Tints.names, where, line)
|
|
117
118
|
when "ranks" then check_value!(key, value, ranks_modes, where, line)
|
|
118
119
|
when "extend" then check_value!(key, value, leaf?(block) ? LEAF_EXTEND : CONTAINER_EXTEND, where, line)
|
|
120
|
+
when "anchor" then check_value!(key, value, ANCHORS, where, line)
|
|
119
121
|
when "gap" then check_format!(key, value, GAP_FORMAT, "a pixel count (40), a percentage (150%) or a signed one (+20%, -50%)", where, line)
|
|
120
122
|
when "link" then check_link!(value, where, line)
|
|
121
123
|
when "resource" then check_resource!(value, block, where, line)
|
|
@@ -130,11 +130,28 @@ module Archsight
|
|
|
130
130
|
# `extend "height"` on a direct child of a `layer` grows that
|
|
131
131
|
# child's box to its tallest sibling's height, leaving its own
|
|
132
132
|
# content top-aligned where it already sits. Never inherited --
|
|
133
|
-
# only the node carrying the attr is affected.
|
|
133
|
+
# only the node carrying the attr is affected. In a `stack` inside such a
|
|
134
|
+
# grown box it absorbs the extra height instead (see
|
|
135
|
+
# `Expander#grow_height`).
|
|
134
136
|
def extend_height?
|
|
135
137
|
attrs["extend"] == "height"
|
|
136
138
|
end
|
|
137
139
|
|
|
140
|
+
# Where this container's content sits when its box grows by `extra`
|
|
141
|
+
# along `axis`: the `anchor` attr (`top`/`bottom` for height,
|
|
142
|
+
# `left`/`right` for width, `center`), else `default`. Returns how
|
|
143
|
+
# far to shift the children (0 = leading edge, `extra` = trailing).
|
|
144
|
+
# Never inherited; a value for the other axis is ignored.
|
|
145
|
+
def anchor_shift(axis, extra, default:)
|
|
146
|
+
value = attrs["anchor"]
|
|
147
|
+
value = default.to_s unless (axis == Axis::HEIGHT ? %w[top bottom center] : %w[left right center]).include?(value)
|
|
148
|
+
case value
|
|
149
|
+
when "top", "left" then 0.0
|
|
150
|
+
when "bottom", "right" then extra.to_f
|
|
151
|
+
else extra / 2.0
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
138
155
|
def link
|
|
139
156
|
attrs["link"]
|
|
140
157
|
end
|