Skip to content

Commit

Permalink
Next gen docs for 1.9 (#6766)
Browse files Browse the repository at this point in the history

Co-authored-by: Aurindam Jana <[email protected]>
Co-authored-by: Tobias Hunger <[email protected]>
Co-authored-by: Simon Hausmann <[email protected]>
  • Loading branch information
4 people authored Nov 14, 2024
1 parent 5b3ea5c commit 08d90a5
Show file tree
Hide file tree
Showing 209 changed files with 12,825 additions and 3,250 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-linux-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ runs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libudev-dev libinput-dev ${{ inputs.extra-packages }}
sudo apt-get install libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libudev-dev libinput-dev libfontconfig-dev ${{ inputs.extra-packages }}
shell: bash
- name: Install Linux dependencies
if: ${{ runner.os == 'Linux' && (inputs.old-ubuntu != 'true')}}
Expand Down
40 changes: 18 additions & 22 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# Allow deprecated warning because we are using nightly and some things might be deprecated in nightly
# for which the stable alternative is not yet available.
RUSTFLAGS: -D warnings -W deprecated
RUSTDOCFLAGS: --html-in-header=/home/runner/work/slint/slint/docs/resources/slint-docs-highlight.html -D warnings -W deprecated
RUSTDOCFLAGS: --html-in-header=/home/runner/work/slint/slint/docs/src/utils/slint-docs-highlight.html -D warnings -W deprecated
SLINT_NO_QT: 1
CARGO_INCREMENTAL: false
RELEASE_INPUT: ${{ inputs.release }}
Expand Down Expand Up @@ -81,27 +81,23 @@ jobs:
cp -r target/aarch64-linux-android/doc/i_slint_backend_android_activity/ target/doc/
cp -r target/aarch64-linux-android/doc/i_slint_backend_winit/ target/doc/
cp -r target/aarch64-linux-android/doc/i_slint_backend_testing/ target/doc/
- name: "Generate Screenshots for Example Snippets"
run: cargo run -p slint-docsnapper -- docs/src/content --overwrite
- name: "Install Node dependencies for Slint and Node docs"
run: pnpm install --frozen-lockfile
- name: "Slint Language Documentation"
run: |
searchbox_html=docs/reference/_templates/searchbox.html
sed -i "s/\$TYPESENSE_SEARCH_API_KEY/${{ secrets.TYPESENSE_SEARCH_API_KEY }}/g" $searchbox_html
sed -i "s/\$TYPESENSE_SERVER_PROTOCOL/https/g" "$searchbox_html"
if [ "$RELEASE_INPUT" == "true" ]; then
version=$(sed -n 's/^version = "\(.*\)"/\1/p' docs/reference/conf.py)
sed -i "s/\$TYPESENSE_INDEX_NAME/$version/g" "$searchbox_html"
sed -i 's/sitemap_url_scheme = "master\/docs\/slint\/{link}"/sitemap_url_scheme = "{version}docs\/slint\/{link}"/' docs/reference/conf.py
sed -i "s/snapshots.slint.dev\/master/releases.slint.dev\/$version/" docs/editor/codemirror.js docs/editor/rollup.config.js
else
sed -i "s/\$TYPESENSE_INDEX_NAME/master/g" "$searchbox_html"
fi
sed -i "s/\$TYPESENSE_SERVER_PORT/443/g" "$searchbox_html"
sed -i "s/\$TYPESENSE_SERVER_URL/typesense.slint.dev/g" "$searchbox_html"
cargo xtask slintdocs --show-warnings
- name: "Node docs"
run: cargo xtask slintdocs
# Test docs
- name: Run Playwright tests
working-directory: docs
run: pnpm exec playwright test
- name: Publish Test Summary Results
working-directory: docs
run: npx github-actions-ctrf playwright-report/ctrf-report.json

run: |
pnpm install --frozen-lockfile
pnpm run docs
- name: "Node docs"
run: pnpm run docs
working-directory: api/node

- name: Generate a token
Expand Down Expand Up @@ -143,12 +139,12 @@ jobs:
path: |
target/doc
target/cppdocs/html
target/slintdocs/html
docs/dist
api/node/docs
docs/site
- name: "Check for docs warnings in internal crates"
run: cargo doc --workspace --no-deps --all-features --exclude slint-node --exclude pyslint --exclude mcu-board-support --exclude printerdemo_mcu --exclude carousel --exclude test-* --exclude plotter --exclude uefi-demo --exclude ffmpeg --exclude gstreamer-player --exclude slint-cpp --exclude slint-python
- name: Clean cache # Don't cache docs to avoid them including removed classes being published
run: |
rm -rf target/doc target/cppdocs target/slintdocs api/node/docs
rm -rf target/doc target/cppdocs api/node/docs
2 changes: 1 addition & 1 deletion .github/workflows/nightly_snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ jobs:
mkdir -p $output_path/docs/node
cp -a ../api/node/docs/* $output_path/docs/node/
mkdir -p $output_path/docs/slint
cp -a ../target/slintdocs/html/* $output_path/docs/slint/
cp -a ../docs/dist/* $output_path/docs/slint/
- name: Adjust redirections
if: github.event.inputs.release == 'true'
Expand Down
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ Cargo.lock
tsconfig.tsbuildinfo
/target
node_modules
tools/figma_import/target
tools/figma_import/figma_output
/tools/figma_import/target
/tools/figma_import/figma_output
*.code-workspace
/build
/_deps
.DS_Store
Pipfile.lock
docs/reference/src/language/builtins/enums.md
docs/reference/src/language/builtins/structs.md
/docs/src/content/collections/enums/
/docs/src/content/collections/structs/
/playwright-report

# Ignore all package-lock.json files
**/package-lock.json
Expand Down
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Files: docs/_templates/*.md
Copyright: Copyright © SixtyFPS GmbH <[email protected]>
License: MIT

Files: docs/src/assets/*.svg docs/src/assets/*.webp docs/src/assets/getting-started/*.webp docs/playwright.config.ts docs/*.mjs docs/*.json docs/public/*.svg docs/src/misc/*.json docs/src/misc/*.jsonc
Copyright: Copyright © SixtyFPS GmbH <[email protected]>
License: MIT

Files: api/*/*.json
Copyright: Copyright © SixtyFPS GmbH <[email protected]>
License: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(SLINT_BUILD_EXAMPLES)
add_subdirectory(demos)
endif()
if(SLINT_BUILD_TESTING AND (SLINT_FEATURE_COMPILER OR SLINT_COMPILER))
add_subdirectory(docs/reference/src/quickstart/)
add_subdirectory(docs/src/content/code/)
endif()

feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ members = [
'api/rs/slint',
'api/python',
'api/wasm-interpreter',
'docs/reference/src/quickstart',
'examples/7guis',
'examples/gallery',
'examples/imagefilter/rust',
Expand Down Expand Up @@ -59,6 +58,7 @@ members = [
'tests/screenshots',
'tests/manual/windowattributes',
'tools/compiler',
'tools/docsnapper',
'tools/figma_import',
'tools/lsp',
'tools/updater',
Expand Down
4 changes: 2 additions & 2 deletions api/cpp/docs/_templates/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "!base.html" %}
{% block scripts %}
{{ super() }}
{% include "../../../../docs/resources/slint-docs-preview.html" %}
{% include "../../../../docs/resources/slint-docs-highlight.html" %}
{% include "../../../../docs/src/utils/slint-docs-preview.html" %}
{% include "../../../../docs/src/utils/slint-docs-highlight.html" %}
{% endblock %}
4 changes: 3 additions & 1 deletion api/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"module": "CommonJS",
"target": "esnext",
"declaration": true,
"outDir": "dist"
"outDir": "dist",
"skipLibCheck": true
},
"include": [
"typescript/"
],
"exclude": ["**/node_modules/**"]
}
4 changes: 2 additions & 2 deletions api/rs/slint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ i-slint-backend-qt = { workspace = true, features = [ "enable" ], optional = tru
[package.metadata.docs.rs]
rustdoc-args = [
# "--html-in-header",
# "docs/resources/slint-docs-preview.html",
# "docs/src/utils/slint-docs-preview.html",
"--html-in-header",
"docs/resources/slint-docs-highlight.html",
"docs/src/utils/slint-docs-highlight.html",
]
features = ["document-features", "log", "gettext", "renderer-software", "renderer-femtovg", "raw-window-handle-06"]
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
"./node_modules",
"**/.vscode/**",
"*.json",
"**/dist/**",
"!biome.json",
"editors/vscode/out/**"
]
},
"organizeImports": { "enabled": false },
"linter": {
"enabled": true,
"ignore": ["api/node/docs/assets/**"],
"ignore": ["api/node/docs/assets/**", "**/dist/**"],
"rules": {
"recommended": false,
"complexity": {
Expand Down
11 changes: 11 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"languageId": "rust",
"words": [
"ARGB",
"astrojs",
"bbox",
"bindgen",
"builtins",
Expand Down Expand Up @@ -71,23 +72,28 @@
],
"words": [
"aarch",
"astrojs",
"accesskit",
"antialiasing",
"armv",
"Bezier",
"Bézier",
"cbindgen",
"cmake",
"colspan",
"combobox",
"cdylib",
"datastructures",
"dealloc",
"flickable",
"focusable",
"frameless",
"fullscreen",
"gles",
"Goffart",
"gradians",
"grayscale",
"gridlayout",
"groupbox",
"Hausmann",
"Helvetica",
Expand All @@ -111,12 +117,17 @@
"riscv",
"rowspan",
"rustc",
"rustdoc",
"rustdocs",
"rvalue",
"seti",
"scrollview",
"SDK",
"sixtyfps",
"skia",
"slint",
"slintdoc",
"slintdocs",
"slintpad",
"spdx",
"spinbox",
Expand Down
29 changes: 29 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# More to ignore
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/src/assets/generated/

94 changes: 94 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!-- Copyright © SixtyFPS GmbH <[email protected]> ; SPDX-License-Identifier: MIT -->
# Slint Documentation


## Prerequisites
- Rust
- Node.js
- pnpm


## 🚀 Project Structure
The documentation site is built with [Astro Starlight](https://starlight.astro.build/) and reuses it's
project structure.

```
docs/
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ ├── docs/
│ │ └── config.ts
│ └── env.d.ts
├── tests/
├── astro.config.mjs
├── package.json
├── tsconfig.json
└──
```

Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.

Images can be added to `src/assets/` and embedded in Markdown with a relative link. They will be optimized
for download size and also their width and height will be extracted so the framework can render them without
ugly content shifts.

Static assets, like favicons, can be placed in the `public/` directory. Note that images in this folder will
not be processed and optimized by Starlight.

## Building the docs

The docs use a lot of autogenerated content. First create all the screenshots which will be placed at `src/assets/generated/`.

```bash
cargo run -p slint-docsnapper -- docs/src/content --overwrite
```

Then generate the slint auto generated content.

```bash
cargo xtask slintdocs
```

This xtask also installs the npm dependencies and builds the docs. The equivalent of:

```bash
pnpm i --ignore-scripts
pnpm run build
```

`--ignore-scripts` is needed because this is a monorepo and `pnpm i` will install the dependencies of all
the projects as well as run any install scripts. Currently the `api/node` project will attemtpt to compile

This will build the site and place it in `dist/`.

## Live edit the docs
To run the live hot reloading dev server run:

```bash
pnpm start
```

This will start the dev server at `localhost:4321`.



## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `pnpm i --ignore-scripts` | Installs dependencies |
| `pnpm start` | Starts local dev server at `localhost:4321` |
| `pnpm build` | Build your production site to `./dist/` |
| `pnpm preview` | Preview your build locally, before deploying |
| `pnpm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |



## 👀 Want to learn more about Astro and Starlight?

Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
Loading

0 comments on commit 08d90a5

Please sign in to comment.