Skip to content

Commit 1f45995

Browse files
WilfredVeykriljoshrotenberg
committed
manual: Convert to mdbook
Split manual.adoc into markdown files, one for each chapter. For the parts of the manual that are generated from source code doc comments, update the comments to use markdown syntax and update the code generators to write to `generated.md` files. For the weekly release, stop copying the .adoc files to the `rust-analyzer/rust-analyzer.github.io` at release time. Instead, we'll sync the manual hourly from this repository. See rust-analyzer/rust-analyzer.github.io#226 for the sync. This PR should be merged first, and that PR needs to be merged before the next weekly release. This change is based on #15795, but rebased and updated. I've also manually checked each page for markdown syntax issues and fixed any I encountered. Co-authored-by: Lukas Wirth <lukastw97@gmail.com> Co-authored-by: Josh Rotenberg <joshrotenberg@gmail.com>
1 parent 8063b1e commit 1f45995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2836
-2686
lines changed

src/tools/rust-analyzer/.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ target/
66
*.log
77
*.iml
88
.vscode/settings.json
9-
generated_assists.adoc
10-
generated_features.adoc
11-
generated_diagnostic.adoc
129
.DS_Store
1310
/out/
1411
/dump.lsif
1512
.envrc
13+
docs/book/book
14+
docs/book/src/assists_generated.md
15+
docs/book/src/diagnostics_generated.md
16+
docs/book/src/features_generated.md

src/tools/rust-analyzer/crates/ide-assists/src/handlers/apply_demorgan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
1515

1616
// Assist: apply_demorgan
1717
//
18-
// Apply https://en.wikipedia.org/wiki/De_Morgan%27s_laws[De Morgan's law].
18+
// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws).
1919
// This transforms expressions of the form `!l || !r` into `!(l && r)`.
2020
// This also works with `&&`. This assist can only be applied with the cursor
2121
// on either `||` or `&&`.
@@ -131,7 +131,7 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti
131131

132132
// Assist: apply_demorgan_iterator
133133
//
134-
// Apply https://en.wikipedia.org/wiki/De_Morgan%27s_laws[De Morgan's law] to
134+
// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) to
135135
// `Iterator::all` and `Iterator::any`.
136136
//
137137
// This transforms expressions of the form `!iter.any(|x| predicate(x))` into

src/tools/rust-analyzer/crates/ide-assists/src/handlers/auto_import.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
3838
// use super::AssistContext;
3939
// ```
4040
//
41-
// .Import Granularity
41+
// #### Import Granularity
4242
//
4343
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
4444
// It has the following configurations:
@@ -54,7 +54,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
5454
//
5555
// In `VS Code` the configuration for this is `rust-analyzer.imports.granularity.group`.
5656
//
57-
// .Import Prefix
57+
// #### Import Prefix
5858
//
5959
// The style of imports in the same crate is configurable through the `imports.prefix` setting.
6060
// It has the following configurations:
@@ -68,7 +68,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
6868
//
6969
// In `VS Code` the configuration for this is `rust-analyzer.imports.prefix`.
7070
//
71-
// image::https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif[]
71+
// ![Auto Import](https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif)
7272

7373
// Assist: auto_import
7474
//

src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Generated by `cargo codegen assists-doc-tests`, do not edit by hand.
1+
//! Generated by `cargo xtask codegen assists-doc-tests`, do not edit by hand.
22
33
use super::check_doc_test;
44

src/tools/rust-analyzer/crates/ide-completion/src/completions/flyimport.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,27 @@ use crate::{
8383
// NOTE: currently, if an assoc item comes from a trait that's not currently imported, and it also has an unresolved and/or partially-qualified path,
8484
// no imports will be proposed.
8585
//
86-
// .Fuzzy search details
86+
// #### Fuzzy search details
8787
//
8888
// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the names only
8989
// (i.e. in `HashMap` in the `std::collections::HashMap` path).
9090
// For the same reasons, avoids searching for any path imports for inputs with their length less than 2 symbols
9191
// (but shows all associated items for any input length).
9292
//
93-
// .Import configuration
93+
// #### Import configuration
9494
//
9595
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
9696
// Mimics the corresponding behavior of the `Auto Import` feature.
9797
//
98-
// .LSP and performance implications
98+
// #### LSP and performance implications
9999
//
100100
// The feature is enabled only if the LSP client supports LSP protocol version 3.16+ and reports the `additionalTextEdits`
101101
// (case-sensitive) resolve client capability in its client capabilities.
102102
// This way the server is able to defer the costly computations, doing them for a selected completion item only.
103103
// For clients with no such support, all edits have to be calculated on the completion request, including the fuzzy search completion ones,
104104
// which might be slow ergo the feature is automatically disabled.
105105
//
106-
// .Feature toggle
106+
// #### Feature toggle
107107
//
108108
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.autoimport.enable` flag.
109109
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corresponding

src/tools/rust-analyzer/crates/ide-completion/src/completions/postfix/format_like.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ** `logw` -> `log::warn!(...)`
1515
// ** `loge` -> `log::error!(...)`
1616
//
17-
// image::https://user-images.githubusercontent.com/48062697/113020656-b560f500-917a-11eb-87de-02991f61beb8.gif[]
17+
// ![Format String Completion](https://user-images.githubusercontent.com/48062697/113020656-b560f500-917a-11eb-87de-02991f61beb8.gif)
1818

1919
use ide_db::{
2020
syntax_helpers::format_string_exprs::{parse_format_exprs, with_placeholders, Arg},

src/tools/rust-analyzer/crates/ide-completion/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ impl CompletionFieldsToResolve {
110110
//
111111
// There also snippet completions:
112112
//
113-
// .Expressions
113+
// #### Expressions
114+
//
114115
// - `pd` -> `eprintln!(" = {:?}", );`
115116
// - `ppd` -> `eprintln!(" = {:#?}", );`
116117
//
117-
// .Items
118+
// #### Items
119+
//
118120
// - `tfn` -> `#[test] fn feature(){}`
119121
// - `tmod` ->
120122
// ```rust
@@ -131,7 +133,7 @@ impl CompletionFieldsToResolve {
131133
// Those are the additional completion options with automatic `use` import and options from all project importable items,
132134
// fuzzy matched against the completion input.
133135
//
134-
// image::https://user-images.githubusercontent.com/48062697/113020667-b72ab880-917a-11eb-8778-716cf26a0eb3.gif[]
136+
// ![Magic Completions](https://user-images.githubusercontent.com/48062697/113020667-b72ab880-917a-11eb-8778-716cf26a0eb3.gif)
135137

136138
/// Main entry point for completion. We run completion as a two-phase process.
137139
///

src/tools/rust-analyzer/crates/ide-completion/src/snippet.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
//
99
// A custom snippet can be defined by adding it to the `rust-analyzer.completion.snippets.custom` object respectively.
1010
//
11-
// [source,json]
12-
// ----
11+
// ```json
1312
// {
1413
// "rust-analyzer.completion.snippets.custom": {
1514
// "thread spawn": {
@@ -25,7 +24,7 @@
2524
// }
2625
// }
2726
// }
28-
// ----
27+
// ```
2928
//
3029
// In the example above:
3130
//
@@ -39,6 +38,7 @@
3938
// * `description` is an optional description of the snippet, if unset the snippet name will be used.
4039
//
4140
// * `requires` is an optional list of item paths that have to be resolvable in the current crate where the completion is rendered.
41+
4242
// On failure of resolution the snippet won't be applicable, otherwise the snippet will insert an import for the items on insertion if
4343
// the items aren't yet in scope.
4444
//
@@ -55,8 +55,8 @@
5555
//
5656
// For the VSCode editor, rust-analyzer also ships with a small set of defaults which can be removed
5757
// by overwriting the settings object mentioned above, the defaults are:
58-
// [source,json]
59-
// ----
58+
//
59+
// ```json
6060
// {
6161
// "Arc::new": {
6262
// "postfix": "arc",
@@ -98,7 +98,7 @@
9898
// "scope": "expr"
9999
// }
100100
// }
101-
// ----
101+
// ````
102102

103103
use hir::{ModPath, Name, Symbol};
104104
use ide_db::imports::import_assets::LocatedImport;

src/tools/rust-analyzer/crates/ide-db/src/apply_change.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ impl RootDatabase {
4444
//
4545
// Clears rust-analyzer's internal database and prints memory usage statistics.
4646
//
47-
// |===
48-
// | Editor | Action Name
49-
//
47+
// | Editor | Action Name |
48+
// |---------|-------------|
5049
// | VS Code | **rust-analyzer: Memory Usage (Clears Database)**
51-
// |===
52-
// image::https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif[]
50+
51+
// ![Memory Usage](https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif)
5352
pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes, usize)> {
5453
let mut acc: Vec<(String, Bytes, usize)> = vec![];
5554

src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,9 @@ impl<DB> std::ops::Deref for Snap<DB> {
193193
// `rust-analyzer.workspace.symbol.search.kind` settings. Symbols prefixed
194194
// with `__` are hidden from the search results unless configured otherwise.
195195
//
196-
// |===
197-
// | Editor | Shortcut
198-
//
199-
// | VS Code | kbd:[Ctrl+T]
200-
// |===
196+
// | Editor | Shortcut |
197+
// |---------|-----------|
198+
// | VS Code | <kbd>Ctrl+T</kbd>
201199
pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
202200
let _p = tracing::info_span!("world_symbols", query = ?query.query).entered();
203201

0 commit comments

Comments
 (0)