Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
# the generated diagrams are committed: one that is stale against its
# generator, or links to a heading a page no longer has, fails here
# (ci.yml runs the same test when schemas/ — the vocabulary — changes)
- run: pnpm --filter @codegraph/website test
# builds the viz bundle into static/city/ (the live city at /city/), then hugo
- run: pnpm --filter @codegraph/website build
- uses: actions/upload-artifact@v4
Expand Down
8 changes: 8 additions & 0 deletions METAMODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ Traits marked *(marker)* contribute **no attributes**: they declare a
capability whose data lives in `edges[]` (edges are stored once, outgoing
direction only — see §4).

![The nineteen traits around the entity that composes them, by family; a dashed box is a marker trait](website/assets/diagrams/traits-metamodel.svg)

The whole vocabulary on one sheet: an entity composes at most one of each
trait, a dashed box is a marker, and the three red dots are the composition of
§3.7. Generated by `website/scripts/traits-diagram.mjs` and pinned to
`schemas/` by its test; on the documentation site the same file is a map, each
box a link to its section.

### 3.1 Base

| Trait | Attributes contributed | Notes |
Expand Down
36 changes: 36 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ one deployment.
| `layouts/_partials/landing/` | the landing's four partials, namespaced |
| `assets/css/colors_and_type.css` | the design system's token layer, copied from the Defsquare Design System project |
| `assets/css/landing.css` | layout only — every colour, size and space is a token |
| `assets/css/custom.css` | the documentation's additions to Hextra (the theme's own hook); the landing never loads it |
| `assets/diagrams/` | the generated metamodel diagrams, inlined by the `metamodel-diagram` shortcode |
| `layouts/_shortcodes/` | the documentation's own shortcodes |
| `static/fonts/` | IBM Plex Sans Condensed, self-hosted. EB Garamond and Fira Code come from Google Fonts, as the design system specifies |
| `static/city/` | the live cities: one laid-out `<corpus>-city.json` per corpus (committed) beside the `@codegraph/viz` bundle `pnpm run viz` copies in (gitignored). `/city/?src=<corpus>-city.json` opens one; the landing's corpora tabs embed them in iframes |
| `static/img/` | the codegraph logo (four variants), the generated city, the Defsquare logo, the favicon |
Expand Down Expand Up @@ -113,6 +116,39 @@ node scripts/city-svg.mjs city.json > static/img/gson-city.svg # counts on std
Then update the caption and the `alt` text in `content/_index.md` with the
counts the script prints.

## The metamodel diagrams are generated, and inlined

`assets/diagrams/traits-metamodel.svg` is the trait vocabulary of
`METAMODEL.md` §3, drawn by `scripts/traits-diagram.mjs` in the style of the
Specy metamodel diagrams: the entity in the middle, the seven trait families
around it, one box per trait saying what it contributes, a dashed box for a
marker. To regenerate it after the vocabulary or a label changes:

```bash
node scripts/traits-diagram.mjs > assets/diagrams/traits-metamodel.svg
pnpm --filter @codegraph/website test # node --test scripts/traits-diagram.test.mjs
```

The test is what keeps a committed drawing honest. It fails when the file is
not the script's output, when the boxes are not exactly the traits and trait
keys of `schemas/` (the committed contract `core` generates), and when a box
links to a heading its page no longer has.

A page embeds it with `{{< metamodel-diagram "traits-metamodel" >}}`, which
**inlines** the SVG rather than pointing an `<img>` at it: every box is a link
to its section, and the hover and focus states are rules in the SVG's own
stylesheet — neither exists inside an `<img>`. The figure opts out of Hextra's
prose typography with `not-prose`, and its card is styled in
`assets/css/custom.css`, the hook Hextra concatenates after its own sheet.

The same file is the image of `METAMODEL.md` on GitHub, where it *is* an
`<img>` and no webfont loads. So it follows the logo's rule, above: every label
carries `textLength`, the width the script measured in the real face (it reads
the advance widths from `static/fonts/*.ttf` itself, no dependency), which is a
no-op where IBM Plex Sans Condensed loads and fits the fallback's glyphs to the
same boxes where it does not. A character the face has no glyph for stops the
script, as does a label wider than its box.

## Links between the two halves

Landing → documentation goes through `params.docsBase` in `hugo.yaml`
Expand Down
46 changes: 46 additions & 0 deletions website/assets/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* The documentation's additions to Hextra, through the theme's own hook: Hextra
concatenates this file after its stylesheet. The landing page never loads it. */

/* A generated metamodel diagram, inlined by the metamodel-diagram shortcode.
The card stays light in the dark theme: the drawing carries its own ground,
as a printed figure does, and its inks are chosen against that ground. The
hover and focus states of the boxes are in the SVG's own stylesheet, so the
file behaves the same when it is opened alone. */
.mm-figure {
margin: 1.5rem 0 2rem;
padding: 0.35rem;
border-radius: 12px;
background: #ebebeb;
box-shadow:
0 0 0 1px rgb(0 0 0 / 0.06),
0 10px 28px rgb(0 0 0 / 0.12);
}
/* Below the width at which its labels stop being readable the drawing keeps
its size and the card scrolls, rather than shrinking into a thumbnail. */
.mm-figure__canvas {
overflow-x: auto;
border-radius: 9px;
}
.mm-figure .mm-diagram {
display: block;
width: 100%;
min-width: 38rem;
height: auto;
}
.mm-figure figcaption {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 0.25rem 1.5rem;
padding: 0.5rem 0.75rem 0.35rem;
font-size: 0.8rem;
color: #4a5967;
}
.mm-figure figcaption a {
color: inherit;
text-decoration: underline;
text-underline-offset: 2px;
}
.mm-figure figcaption a:hover {
color: #c2413f;
}
Loading
Loading