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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,18 @@ jobs:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]

# The flavour in `target/debug`, where the cache is: nothing else builds `app` in this job.
env:
DEVNOTES_E2E_BIN: ${{ github.workspace }}/target/debug/devnotes${{ matrix.os == 'windows-latest' && '.exe' || '' }}
DEVNOTES_E2E_OUTPUT: ${{ github.workspace }}/scenarios

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

# The flavour in `target/debug`, where the cache is: nothing else builds `app` in this job.
- name: Where the flavour is
run: |
binary="$(node scripts/names.mjs slug)${{ matrix.os == 'windows-latest' && '.exe' || '' }}"
echo "DEVNOTES_E2E_BIN=${{ github.workspace }}/target/debug/$binary" >> "$GITHUB_ENV"

- uses: ./.github/actions/setup-rust
with:
shared-key: e2e-${{ matrix.os }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Website

# devnotes.fr: the site built from `website/` and `docs/content/`, pushed as the whole content of
# one commit to the `main` of `vmillet-dev/devnotes-website`, whose webhook deploys it
# The site (`site` in the root Cargo.toml), built from `website/` and `docs/content/`, pushed as the
# whole content of one commit to the `main` of `<owner>/<slug>-website`, whose webhook deploys it
# (docs/architecture/project/website.md → "The website"). Two things change what it shows: a push to `main` that
# touches its sources, and a release, whose files the download page names. The second needs the
# run that follows `Release`: what that workflow pushes with its own token triggers nothing.
Expand Down Expand Up @@ -81,23 +81,25 @@ jobs:
DRY_RUN: ${{ inputs.dry_run }}
GH_TOKEN: ${{ github.token }}
run: |
target="$GITHUB_REPOSITORY_OWNER/$(node scripts/names.mjs slug)-website"
address=$(node scripts/names.mjs site)
if [ "$DRY_RUN" != true ] && [ -z "$DEPLOY_KEY" ]; then
echo "::error::the secret WEBSITE_DEPLOY_KEY is not set: no write access to devnotes-website"
echo "::error::the secret WEBSITE_DEPLOY_KEY is not set: no write access to $target"
exit 1
fi
source=$(git rev-parse --short=8 HEAD)
site="$RUNNER_TEMP/site"

if [ "$DRY_RUN" = true ]; then
# The clone is public: a dry run never holds the key.
git clone --quiet --depth 1 https://github.com/vmillet-dev/devnotes-website.git "$site"
git clone --quiet --depth 1 "https://github.com/$target.git" "$site"
else
umask 077
printf '%s\n' "$DEPLOY_KEY" > "$RUNNER_TEMP/deploy_key"
# GitHub's host keys, read over HTTPS: nothing is trusted on first use.
gh api meta --jq '.ssh_keys[] | "github.com " + .' > "$RUNNER_TEMP/known_hosts"
export GIT_SSH_COMMAND="ssh -i $RUNNER_TEMP/deploy_key -o IdentitiesOnly=yes -o UserKnownHostsFile=$RUNNER_TEMP/known_hosts"
git clone --quiet --depth 1 git@github.com:vmillet-dev/devnotes-website.git "$site"
git clone --quiet --depth 1 "git@github.com:$target.git" "$site"
umask 022
fi

Expand All @@ -119,7 +121,7 @@ jobs:

git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -q -m "Build devnotes.fr from devnotes-rs $source"
git commit -q -m "Build ${address#https://} from ${GITHUB_REPOSITORY#*/} $source"
# No force: a rejected push rebases once and tries again.
git push origin HEAD:main || { git pull --rebase origin main && git push origin HEAD:main; }

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Principles:
- ⚠️ **Request scripts run in the app relaunched as a script host** (`--script-host`, read in `main` before any window): QuickJS, one host per request, a phase at a time; `pm.sendRequest` is sent by the parent. What `require` finds is bundled by `crates/engine/sandbox/build.mjs` into the committed `sandbox/dist/`. → "Request scripts, in a process of their own".
- **JSON explorer/visualiser**: inputs only; Rust owns the model (`json::model::explore`, nesting capped at 256, node/row caps). → "Exploring a JSON snippet", "The JSON visualiser's model".
- `closed_enum!` declares enums once. **Imports degrade rather than fail**, in one transaction; an added variant does not bump `FORMAT_VERSION`. → "Import, export and copying out".
- ⚠️ **Every name of the application is `brand`'s** (D36): six values of the root `Cargo.toml`'s `[workspace.metadata]`; never type the name, the slug, the identifier, the extension or the site. Other metadata is read from `Cargo.toml` at compile time; the changelog is baked in (`include_str!`). → "The application's names".
- ⚠️ **Every name of the application is `brand`'s** (D36): six values of the root `Cargo.toml`'s `[workspace.metadata]`; never type the name, the slug, the identifier, the extension or the site (a page of `docs/content` writes `{{app}}`, `{{slug}}`…, `docs/content/README.md`). Other metadata is read from `Cargo.toml` at compile time; the changelog is baked in (`include_str!`). → "The application's names".

### Interface (egui)

Expand Down
34 changes: 32 additions & 2 deletions crates/engine/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ pub fn docs_index() -> &'static Index {
/// A page in a language, by its name in the index.
pub fn docs_page(language: &str, id: &str) -> Option<&'static Page> {
let at = SOURCES.iter().position(|source| source.0 == language && source.1 == id)?;
PAGES[at].get_or_init(|| model::read(id, SOURCES[at].2).ok()).as_ref()
PAGES[at].get_or_init(|| model::read(id, &named(SOURCES[at].2)).ok()).as_ref()
}

/// The application's names and its repository, which a page writes as placeholders (D36): filled
/// before it is read, as `website/scripts/docs.mjs` fills them before the site is built.
const NAMES: [(&str, &str); 6] = [
("{{app}}", brand::NAME),
("{{slug}}", brand::SLUG),
("{{identifier}}", brand::IDENTIFIER),
("{{extension}}", brand::EXTENSION),
("{{site}}", brand::SITE),
("{{repository}}", env!("CARGO_PKG_REPOSITORY")),
];

fn named(markdown: &str) -> String {
NAMES
.iter()
.fold(markdown.to_owned(), |text, (placeholder, value)| text.replace(placeholder, value))
}

#[cfg(test)]
Expand Down Expand Up @@ -55,12 +72,25 @@ mod tests {
#[test]
fn every_file_is_read() {
for (language, id, markdown) in SOURCES {
if let Err(refusal) = model::read(id, markdown) {
if let Err(refusal) = model::read(id, &named(markdown)) {
panic!("docs/content/{language}/{id}.md:{refusal}");
}
}
}

#[test]
fn a_page_says_the_application_s_names_and_no_placeholder_of_them() {
let start = docs_page("en", "start").expect("the page");
let said = format!("{}{}", start.title, start.summary);
assert!(said.contains(brand::NAME), "{said}");
for (language, id, _) in SOURCES {
let page = format!("{:?}", docs_page(language, id).expect("the page"));
for (placeholder, _) in NAMES {
assert!(!page.contains(placeholder), "{language}/{id} still says {placeholder}");
}
}
}

#[test]
fn the_files_are_the_pages_of_the_index_in_every_language() {
let mut named = ids();
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ in the code.
| D33 | Workspace manifest | Each dependency declared once, version and common features, in the root `[workspace.dependencies]`; a crate takes `workspace = true` and adds only its own features. |
| D34 | Title bar | The application's own on every system: no decorations from the system, minimise, maximise and close at the bar's right end; macOS keeps its three buttons, at the left end. Moving and resizing are the system's (`StartDrag`, `BeginResize`). No way back to the system's bar. |
| D35 | Logs | Terminal: our crates from `debug` in a debug build, from `info` in a release. File: `warn` and `error`, after our last 200 lines. The e2e flavour files from `debug`, its terminal errors alone. Other crates at `warn`. A line says names, codes, ids, durations, never content (D18). `DEVNOTES_LOG` replaces the levels for one run. |
| D36 | Names | Six values of the root `Cargo.toml`'s `[workspace.metadata]`, read by `crates/brand` alone: every name in the code, on the disk, in the packages and on the site follows them, save a few Cargo and files keep literal, held by a test. Renaming is the owner's choice, its cost accepted, not migrated (→ "The application's names"). |
| D36 | Names | Six values of the root `Cargo.toml`'s `[workspace.metadata]`, read by `crates/brand` and `scripts/names.mjs` alone: every name of the code, the disk, the packages, the docs and the site follows them, save a few Cargo and files keep literal, held by a test. Renaming is the owner's call (→ "The application's names"). |
6 changes: 6 additions & 0 deletions docs/architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ beside the version (D27):
rename edits them by hand; `crates/app/tests/names.rs` fails while one differs from the values.
- The names nobody outside the process reads carry none: `--script-host`, `__prelude`, the `network`
thread. The `DEVNOTES_` prefix of the environment variables stays, the owner's choice.
- **The documentation and the site read them too**: a page of `docs/content` writes `{{app}}`,
`{{slug}}`, `{{identifier}}`, `{{extension}}`, `{{site}}` and `{{repository}}`, filled by `engine::docs` and by
`website/scripts/docs.mjs`, which also writes the site's `core/generated/names.ts` (the name, the
slug, the address, the repository). Prose has no variable: the README, `CONTRIBUTING.md`, these
pages, `CLAUDE.md`, `.claude/` and `website/package.json` are edited by hand at a rename;
`CHANGELOG.md` is history, never rewritten.

**What a rename costs**, accepted and not migrated: an archive under the previous extension is no
longer offered by the import's filter; a request history holding the previous User-Agent shows it as
Expand Down
6 changes: 3 additions & 3 deletions docs/architecture/project/website.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ specs, `npm run lint` ESLint, `npm run test:scripts` the Node tests of the token
`core/release.ts` names the files as `release.yml` writes them. The post-build check asks
GitHub for every download link and stops on anything but a 200: a name that drifts from the
packaging fails the build rather than the visitor.
- **The address is one build setting**, `SITE_URL` (`define` in `angular.json`,
`https://devnotes.fr`; `--define` overrides it): the canonical links and the social tags are
built from it. `scripts/finish-build.mjs` runs after the build, reads the address back from the
- **The address is the root `Cargo.toml`'s `site`** (→ "The application's names"), with the name,
the slug and the repository: `scripts/docs.mjs` writes them to `core/generated/names.ts`, and the
canonical links, the social tags, the titles and the release's file names are built from it. `scripts/finish-build.mjs` runs after the build, reads the address back from the
home page's canonical link, checks every page (one `h1`, a title, a canonical, no local
address, download links that answer, languages that name each other, structured data that
parses, a social image of 1200 × 630), and writes `sitemap.xml`, with each page's languages,
Expand Down
17 changes: 15 additions & 2 deletions docs/content/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The documentation

The pages devnotes.fr shows, and the application reads offline. One Markdown file per page and per language: `fr/start.md` and `en/start.md` are the same page. Nothing is generated beside them; to change a page, edit its two files.
The pages the website shows, and the application reads offline. One Markdown file per page and per language: `fr/start.md` and `en/start.md` are the same page. Nothing is generated beside them; to change a page, edit its two files.

## Writing a page

Expand All @@ -9,7 +9,7 @@ A page begins with its title and one paragraph, its summary:
```md
# Prise en main

Installer DevNotes et faire le tour des notes d’exemple.
Installer {{app}} et faire le tour des notes d’exemple.

## Installer
```
Expand All @@ -27,6 +27,19 @@ Installer DevNotes et faire le tour des notes d’exemple.

A value inside a label is an ellipsis: `*Définir dans …*`.

The application's names and its repository are never spelled: a page writes their placeholder, and the application and the site put the value of the root `Cargo.toml` in its place (D36).

| Placeholder | Value |
| ---------------- | ---------------------------------------- |
| `{{app}}` | `display-name` of `[workspace.metadata]` |
| `{{slug}}` | `slug` |
| `{{identifier}}` | `identifier` |
| `{{extension}}` | `file-extension` |
| `{{site}}` | `site` |
| `{{repository}}` | `repository` of `[workspace.package]` |

A link to the site is written `[the download page]({{site}}/en/download)`.

A table and a code block have their title in bold, alone on its line just above:

```md
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Each request opens in a tab. <kbd>Ctrl Enter</kbd> sends it (or connects the Web

### The parts of a request

- **Parameters** and **Headers**: key / value tables, each row can be switched off. Those DevNotes adds by itself are shown apart.
- **Parameters** and **Headers**: key / value tables, each row can be switched off. Those {{app}} adds by itself are shown apart.
- **Auth**: *Inherited*, *None*, *Basic*, *Bearer* or *API key*, sent in a header or in the query.
- **Body**: JSON, text, form, multipart or file. A file is read when the request is sent, its bytes are never kept.
- **Settings**: the timeout, redirects, TLS certificate verification and cookies.
Expand Down
Loading
Loading