build: generate docs with internal links (#1831)

* build: generate docs with internal links

* build: detect link kind
This commit is contained in:
Myriad-Dreamin 2025-06-22 15:28:27 +08:00 committed by GitHub
parent 4658fe7218
commit 483de6f00d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 62 additions and 39 deletions

View file

@ -5,11 +5,11 @@ Tinymist \[ˈtaɪni mɪst\] is an integrated language service for [Typst](https:
It contains:
- an analyzing library for Typst, see [tinymist-query](https://github.com/Myriad-Dreamin/tinymist/tree/main/crates/tinymist-query).
- a CLI for Typst, see [tinymist](https://github.com/Myriad-Dreamin/tinymist/tree/main/crates/tinymist/).
- an analyzing library for Typst, see [tinymist-query](/crates/tinymist-query/).
- a CLI for Typst, see [tinymist](/crates/tinymist/).
- which provides a language server for Typst, see [Language Features](https://myriad-dreamin.github.io/tinymist/feature/language.html).
- which provides a preview server for Typst, see [Preview Feature](https://myriad-dreamin.github.io/tinymist/feature/preview.html).
- a VSCode extension for Typst, see [Tinymist VSCode Extension](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode/).
- a VSCode extension for Typst, see [Tinymist VSCode Extension](/editors/vscode/).
## Features
@ -67,7 +67,7 @@ Extra features:
- Provides test, benchmark, coverage collecting on documents and modules. Check [Docs: Testing Features](https://myriad-dreamin.github.io/tinymist/feature/testing.html).
- Provides builtin linting. Check [Docs: Linting Features](https://myriad-dreamin.github.io/tinymist/feature/linting.html).
- Provides a status bar item to show the current document's compilation status and words count.
- [Editor tools](https://github.com/Myriad-Dreamin/tinymist/tree/main/tools/editor-tools):
- [Editor tools](/tools/editor-tools/):
- View a list of templates in template gallery. (`tinymist.showTemplateGallery`)
- Click a button in template gallery to initialize a new project with a template. (`tinymist.initTemplate` and `tinymist.initTemplateInPlace`)
- Trace execution in current document (`tinymist.profileCurrentFile`).
@ -168,11 +168,11 @@ Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for contribution guideli
## Sponsoring
Tinymist thrives on community love and remains proudly independent. While we don't accept direct project funding, we warmly welcome support for our maintainers' personal efforts. Please go to [Maintainers Page](https://github.com/Myriad-Dreamin/tinymist/blob/main/MAINTAINERS.md) and [Contributors Page](https://github.com/Myriad-Dreamin/tinymist/graphs/contributors) and find their personal pages for more information. It is also welcomed to directly ask questions about sponsoring on the [GitHub Issues](https://github.com/Myriad-Dreamin/tinymist/issues/new).
Tinymist thrives on community love and remains proudly independent. While we don't accept direct project funding, we warmly welcome support for our maintainers' personal efforts. Please go to [Maintainers Page](/MAINTAINERS.md) and [Contributors Page](https://github.com/Myriad-Dreamin/tinymist/graphs/contributors) and find their personal pages for more information. It is also welcomed to directly ask questions about sponsoring on the [GitHub Issues](https://github.com/Myriad-Dreamin/tinymist/issues/new).
## Acknowledgements
- Partially code is inherited from [typst-lsp](https://github.com/nvarner/typst-lsp)
- The [integrating](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#symbol-view) **offline** handwritten-stroke recognizer is powered by [Detypify](https://detypify.quarticcat.com/).
- The [integrating](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#preview-command) preview service is powered by [typst-preview](https://github.com/Enter-tainer/typst-preview).
- The [integrating](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#managing-local-packages) local package management functions are adopted from [vscode-typst-sync](https://github.com/OrangeX4/vscode-typst-sync).
- The [integrating](/editors/vscode#symbol-view) **offline** handwritten-stroke recognizer is powered by [Detypify](https://detypify.quarticcat.com/).
- The [integrating](/editors/vscode#preview-command) preview service is powered by [typst-preview](https://github.com/Enter-tainer/typst-preview).
- The [integrating](/editors/vscode#managing-local-packages) local package management functions are adopted from [vscode-typst-sync](https://github.com/OrangeX4/vscode-typst-sync).

View file

@ -42,7 +42,7 @@ siphasher.workspace = true
strum.workspace = true
toml.workspace = true
ttf-parser.workspace = true
typlite.workspace = true
typlite = { workspace = true, default-features = false }
tinymist-world = { workspace = true }
tinymist-project = { workspace = true, features = ["lsp"] }
tinymist-analysis.workspace = true

View file

@ -65,7 +65,7 @@ tokio = { workspace = true, features = ["rt-multi-thread", "io-std"] }
tokio-util.workspace = true
toml.workspace = true
ttf-parser.workspace = true
typlite.workspace = true
typlite = { workspace = true, default-features = false }
typst.workspace = true
typst-svg.workspace = true
typst-pdf.workspace = true
@ -120,6 +120,7 @@ no-content-hint = [
"tinymist-task/no-content-hint",
"tinymist-project/no-content-hint",
"tinymist-preview/no-content-hint",
"typlite/no-content-hint",
"reflexo-typst/no-content-hint",
"reflexo-vec2svg/no-content-hint",
]

View file

@ -46,7 +46,7 @@ regex.workspace = true
tinymist-tests.workspace = true
[features]
default = ["no-content-hint"]
default = ["no-content-hint", "cli"]
clap = ["dep:clap"]
# Note: this is the feature for typlite as a CLI, not for others.
# `docx` is enabled in CLI mode, but not in library mode.

View file

@ -47,7 +47,7 @@ This requires the following configuration in your `tasks.json` file:
}
```
See the #github-link("/editors/vscode/e2e-workspaces/print-state")[Sample Workspace: print-state] for more details.
See the #github-link("/editors/vscode/e2e-workspaces/print-state/")[Sample Workspace: print-state] for more details.
== IEEE Example (VSCode Tasks)
@ -57,7 +57,7 @@ This workspace gives an example to create and prepare IEEE papers using Typst, w
It uses #typst-func("export") to export the document to LaTeX.
See the #github-link("/editors/vscode/e2e-workspaces/ieee-paper")[Sample Workspace: IEEE Paper] for more details.
See the #github-link("/editors/vscode/e2e-workspaces/ieee-paper/")[Sample Workspace: IEEE Paper] for more details.
== Pdfpc Example (VSCode Tasks)

View file

@ -56,7 +56,7 @@ Extra features:
- Provides test, benchmark, coverage collecting on documents and modules. Check #cross-link("/feature/testing.typ")[Docs: Testing Features].
- Provides builtin linting. Check #cross-link("/feature/linting.typ")[Docs: Linting Features].
- Provides a status bar item to show the current document's compilation status and words count.
- #github-link("/tools/editor-tools")[Editor tools]:
- #github-link("/tools/editor-tools/")[Editor tools]:
- View a list of templates in template gallery. (`tinymist.showTemplateGallery`)
- Click a button in template gallery to initialize a new project with a template. (`tinymist.initTemplate` and `tinymist.initTemplateInPlace`)
- Trace execution in current document (`tinymist.profileCurrentFile`).

View file

@ -51,7 +51,7 @@ Running test(panic-on-panic)
Since it requires some heavy framework to run benchmarks, a standalone tool is provided to run benchmarks.
Check #github-link("/crates/crityp")[crityp] for more information.
Check #github-link("/crates/crityp/")[crityp] for more information.
= Visualizing Coverage

View file

@ -6,7 +6,7 @@
This feature is currently in early development.
]
#github-link("/crates/typlite")[typlite] is a pure Rust library for converting Typst documents to other markup formats.
#github-link("/crates/typlite/")[typlite] is a pure Rust library for converting Typst documents to other markup formats.
typlite's goal is to convert docstrings in typst packages to LSP docs (Markdown Format). To achieve this, it runs HTML export and extract semantic information from the HTML document for markup conversion.

View file

@ -34,7 +34,7 @@ language-servers = ["tinymist"]
== Working with Multiple-File Projects
There is a way in #github-link("/editors/neovim/README.md#multiple-file-project-support")[Neovim];, but you cannot invoke related commands with arguments by #link("https://docs.helix-editor.com/commands.html")[:lsp-workspace-command] in helix. As a candidate solution, assuming your having following directory layout:
There is a way in #github-link("/editors/neovim/README.md#working-with-multiple-file-projects")[Neovim];, but you cannot invoke related commands with arguments by #link("https://docs.helix-editor.com/commands.html")[:lsp-workspace-command] in helix. As a candidate solution, assuming your having following directory layout:
```plain
├── .helix

View file

@ -2,7 +2,7 @@
#show: book-page.with(title: [Editor Frontends])
Leveraging the interface of LSP, tinymist provides frontends to each editor, located in the #github-link("/tree/main/editors")[editor folders]. They are minimal, meaning that LSP should finish its main LSP features as many as possible without help of editor frontends. The editor frontends just enhances your code experience. For example, the vscode frontend takes responsibility on providing some nice editor tools. It is recommended to install these editors frontend for your editors.
Leveraging the interface of LSP, tinymist provides frontends to each editor, located in the #github-link("/editors/")[editor folders]. They are minimal, meaning that LSP should finish its main LSP features as many as possible without help of editor frontends. The editor frontends just enhances your code experience. For example, the vscode frontend takes responsibility on providing some nice editor tools. It is recommended to install these editors frontend for your editors.
Check the following chapters for uses:
- #cross-link("/frontend/vscode.typ")[VS Cod(e,ium)]

View file

@ -66,7 +66,7 @@ Run and configure `tinymist` in Neovim with support for all major distros and pa
}
```
For a full list of available settings see #github-link("/tree/main/editors/neovim/Configuration.md")[Tinymist Server Configuration].
For a full list of available settings see #github-link("/editors/neovim/Configuration.md")[Tinymist Server Configuration].
= Formatting

View file

@ -7,7 +7,7 @@
Tinymist [ˈtaɪni mɪst] is an integrated language service for #link("https://typst.app/")[Typst] [taɪpst]. You can also call it "微霭" [wēi ǎi] in Chinese.
It contains:
- an analyzing library for Typst, see #github-link("/crates/tinymist-query")[tinymist-query].
- an analyzing library for Typst, see #github-link("/crates/tinymist-query/")[tinymist-query].
- a CLI for Typst, see #github-link("/crates/tinymist/")[tinymist].
- which provides a language server for Typst, see #cross-link("/feature/language.typ")[Language Features].
- which provides a preview server for Typst, see #cross-link("/feature/preview.typ")[Preview Feature].

View file

@ -6,7 +6,7 @@ Four principles are followed.
= Multiple Actors
The main component, #github-link("/crates/tinymist")[tinymist], starts as a thread or process, obeying the #link("https://microsoft.github.io/language-server-protocol/")[Language Server Protocol]. tinymist will bootstrap multiple actors, each of which provides some typst feature.
The main component, #github-link("/crates/tinymist/")[tinymist], starts as a thread or process, obeying the #link("https://microsoft.github.io/language-server-protocol/")[Language Server Protocol]. tinymist will bootstrap multiple actors, each of which provides some typst feature.
The each actor holds and maintains some resources exclusively. For example, the compile server actor holds the well known ```rs trait World``` resource.
@ -45,7 +45,7 @@ The `RenderActor`s don't do compilations, but own project-specific rendering cac
= Multi-level Analysis
he most critical features are lsp functions, built on the #github-link("/crates/tinymist-query")[tinymist-query] crate. To achieve higher concurrency, functions are classified into different levels of analysis.
he most critical features are lsp functions, built on the #github-link("/crates/tinymist-query/")[tinymist-query] crate. To achieve higher concurrency, functions are classified into different levels of analysis.
+ `query_source` `SyntaxRequest` locks and accesses a single source unit.
+ `query_world` `SemanticRequest` locks and accesses multiple source units.
+ `query_state` `StatefulRequest` acquires to accesses a specific version of compile results.
@ -103,4 +103,4 @@ All non-LSP features in tinymist are *optional*. They are optional, as they can
= Minimal Editor Frontends
Leveraging the interface of LSP, tinymist provides frontends to each editor, located in the #github-link("/editors")[editor folders]. They are minimal, meaning that LSP should finish its main LSP features as many as possible without help of editor frontends. The editor frontends just enhances your code experience. For example, the vscode frontend takes responsibility on providing some nice editor tools. It is recommended to install these editors frontend for your editors.
Leveraging the interface of LSP, tinymist provides frontends to each editor, located in the #github-link("/editors/")[editor folders]. They are minimal, meaning that LSP should finish its main LSP features as many as possible without help of editor frontends. The editor frontends just enhances your code experience. For example, the vscode frontend takes responsibility on providing some nice editor tools. It is recommended to install these editors frontend for your editors.

View file

@ -13,7 +13,8 @@ To enable LSP, you must install `tinymist`. You can find `tinymist` by:
- Night versions available at [GitHub Actions](https://github.com/Myriad-Dreamin/tinymist/actions).
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).\
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).
\
If you are using the latest version of [typst-ts-mode](https://codeberg.org/meow_king/typst-ts-mode), then you can use command `typst-ts-lsp-download-binary` to download the latest stable binary of `tinymist` at `typst-ts-lsp-download-path`.
- Build from source by cargo. You can also compile and install **latest** `tinymist` by [Cargo](https://www.rust-lang.org/tools/install).
@ -52,7 +53,7 @@ For example, if you want to export PDF on save:
You can also have configuration per directory. Be sure to look at the documentation of `eglot-workspace-configuration` by [`describe-symbol`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Name-Help.html)..
See [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md) for references.
See [Tinymist Server Configuration](/editors/neovim/Configuration.md) for references.
#### Launch Arguments

View file

@ -13,7 +13,8 @@ To enable LSP, you must install `tinymist`. You can find `tinymist` by:
- Night versions available at [GitHub Actions](https://github.com/Myriad-Dreamin/tinymist/actions).
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).\
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).
\
If you are using the latest version of [typst-ts-mode](https://codeberg.org/meow_king/typst-ts-mode), then you can use command `typst-ts-lsp-download-binary` to download the latest stable binary of `tinymist` at `typst-ts-lsp-download-path`.
- Build from source by cargo. You can also compile and install **latest** `tinymist` by [Cargo](https://www.rust-lang.org/tools/install).
@ -42,7 +43,7 @@ language-servers = ["tinymist"]
### Working with Multiple-File Projects
There is a way in [Neovim](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/README.md#multiple-file-project-support), but you cannot invoke related commands with arguments by [:lsp-workspace-command](https://docs.helix-editor.com/commands.html) in helix. As a candidate solution, assuming your having following directory layout:
There is a way in [Neovim](/editors/neovim/README.md#working-with-multiple-file-projects), but you cannot invoke related commands with arguments by [:lsp-workspace-command](https://docs.helix-editor.com/commands.html) in helix. As a candidate solution, assuming your having following directory layout:
```plain
├── .helix
@ -63,7 +64,7 @@ Note: With that configuration, if youre seeing a file that is not reachable b
## Extra Settings
To configure language server, you can edit the `language-server.tinymist` section. For example, if you want to export PDF on typing and output files in `$root_dir/target` directory:
To configure the language server, edit the `language-server.tinymist` section. For example, if you want to export PDF on typing and output files in `$root_dir/target` directory:
```toml
[language-server.tinymist]
@ -71,4 +72,12 @@ command = "tinymist"
config = { exportPdf = "onType", outputPath = "$root/target/$dir/$name" }
```
See [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md) for references.
To enable a live preview you can use the `preview.background`:
```toml
[language-server.tinymist]
command = "tinymist"
config = { preview.background.enabled = true", preview.background.args = ["--data-plane-host=127.0.0.1:23635", "--invert-colors=never", "--open"] }
```
See [Tinymist Server Configuration](/editors/neovim/Configuration.md) for references.

View file

@ -29,7 +29,8 @@ Run and configure `tinymist` in Neovim with support for all major distros and pa
- Or manually:
To enable LSP, you must install `tinymist`. You can find `tinymist` by:
- Night versions available at [GitHub Actions](https://github.com/Myriad-Dreamin/tinymist/actions).
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).\
- Stable versions available at [GitHub Releases](https://github.com/Myriad-Dreamin/tinymist/releases).
\
If you are using the latest version of [typst-ts-mode](https://codeberg.org/meow_king/typst-ts-mode), then you can use command `typst-ts-lsp-download-binary` to download the latest stable binary of `tinymist` at `typst-ts-lsp-download-path`.
- Build from source by cargo. You can also compile and install **latest** `tinymist` by [Cargo](https://www.rust-lang.org/tools/install).
```bash
@ -72,7 +73,7 @@ Run and configure `tinymist` in Neovim with support for all major distros and pa
}
```
For a full list of available settings see [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/neovim/Configuration.md).
For a full list of available settings see [Tinymist Server Configuration](/editors/neovim/Configuration.md).
## Formatting

View file

@ -1,4 +1,6 @@
#import "target.typ": sys-is-html-target, is-md-target
#let git-head = read("/.git/HEAD").trim()
#let git-head-branch = if git-head.starts-with("ref: refs/heads/") {
git-head.slice("ref: refs/heads/".len())
@ -14,8 +16,14 @@
// todo: read it from somewhere
#let remote = "https://github.com/Myriad-Dreamin/tinymist"
#let github-link(path, body, kind: "tree", permalink: true) = link(
{
#let github-link(path, body, kind: none, permalink: true) = {
if kind == none {
kind = if path.ends-with("/") { "tree" } else { "blob" }
}
let dest = if is-md-target {
path
} else {
remote
"/"
kind
@ -31,6 +39,7 @@
} else {
path
}
},
body,
)
}
link(dest, body)
}

4
typ/templates/target.typ Normal file
View file

@ -0,0 +1,4 @@
#import "@preview/shiroa:0.2.3": book-sys
#let is-md-target = book-sys.target == "md"
#let sys-is-html-target = book-sys.sys-is-html-target

View file

@ -1,8 +1,6 @@
#import "@preview/shiroa:0.2.3": templates, book-sys
#import templates: *
#let is-md-target = book-sys.target == "md"
#let sys-is-html-target = book-sys.sys-is-html-target
#import "target.typ": sys-is-html-target, is-md-target
// Theme (Colors)
#let dark-theme = book-theme-from(toml("theme-style.toml"), xml: it => xml(it), target: "web-ayu")