Skip to content

Move rust-analyzer manual to mdbook #10791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
af041aa
add base book
joshrotenberg Nov 18, 2021
9d582ac
fix titles
joshrotenberg Nov 18, 2021
a1feb63
change title
joshrotenberg Nov 18, 2021
31fba14
add quickstart
joshrotenberg Nov 18, 2021
044ab03
enable fold
joshrotenberg Nov 19, 2021
e89af93
Merge branch 'master' into rust_analyzer_manual_redo
joshrotenberg Dec 17, 2021
f8b6d82
Merge branch 'rust-lang:master' into rust_analyzer_manual_redo
joshrotenberg Jul 25, 2022
640457e
front page updates
joshrotenberg Jul 25, 2022
2d0d7db
Merge branch 'rust-lang:master' into rust_analyzer_manual_redo
joshrotenberg Jul 28, 2022
0c28481
add some installation parts
joshrotenberg Jul 28, 2022
a86be54
emacs
joshrotenberg Jul 28, 2022
43b340b
vim
joshrotenberg Jul 31, 2022
41fc09a
fix typo
joshrotenberg Jul 31, 2022
08339da
finish installation section
joshrotenberg Jul 31, 2022
d80c33c
Merge branch 'rust-lang:master' into rust_analyzer_manual_redo
joshrotenberg Jul 31, 2022
383c7e3
more sections
joshrotenberg Jul 31, 2022
13c03f4
more sections
joshrotenberg Aug 3, 2022
2af7046
add quickstart
joshrotenberg Aug 5, 2022
872a010
these will be generated
joshrotenberg Aug 5, 2022
c348c60
add this for demos
joshrotenberg Aug 6, 2022
311c974
fix branch
joshrotenberg Aug 6, 2022
1094140
yaml woes
joshrotenberg Aug 6, 2022
b12758a
yaml woes
joshrotenberg Aug 6, 2022
8c545a5
add book readme
joshrotenberg Aug 6, 2022
4218546
features adoc to markdown
joshrotenberg Aug 8, 2022
4b2e64b
Merge branch 'master' into rust_analyzer_manual_redo
joshrotenberg Aug 8, 2022
4a7babb
add workflow dispatch
joshrotenberg Aug 8, 2022
e5b3a13
trying to make this action manually runnable
joshrotenberg Aug 8, 2022
23afbcd
this isn't working, remove it for now
joshrotenberg Aug 8, 2022
4373cc0
add features title
joshrotenberg Aug 8, 2022
f954ca9
only show features in toc
joshrotenberg Aug 8, 2022
feb7b3a
add mdbook-toc to mdbook install
joshrotenberg Aug 8, 2022
11aad76
move to include
joshrotenberg Aug 9, 2022
a3dcf6d
updates for assists
joshrotenberg Aug 9, 2022
f4f3f46
ignore generated markdown
joshrotenberg Aug 9, 2022
d1aae7f
add diagnostics
joshrotenberg Aug 9, 2022
f1bfb6c
remove static diagnostics
joshrotenberg Aug 9, 2022
0ddaf4a
move over dev docs and minor linting
joshrotenberg Aug 10, 2022
114ff23
add logo
joshrotenberg Aug 10, 2022
5660ea3
lint
joshrotenberg Aug 10, 2022
dc70f5c
configuration
joshrotenberg Aug 10, 2022
31ce043
fix links
joshrotenberg Sep 1, 2022
d10f651
Merge branch 'master' into rust_analyzer_manual_redo
joshrotenberg Sep 24, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ crates/*/target
*.log
*.iml
.vscode/settings.json
manual/src/generated/*
generated_assists.adoc
generated_features.adoc
generated_diagnostic.adoc
.DS_Store
/out/
/dump.lsif
/manual/book
.envrc
6 changes: 3 additions & 3 deletions crates/ide-assists/src/handlers/auto_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
// use super::AssistContext;
// ```
//
// .Import Granularity
// ### Import Granularity
//
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
// It has the following configurations:
Expand All @@ -52,7 +52,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
//
// In `VS Code` the configuration for this is `rust-analyzer.imports.granularity.group`.
//
// .Import Prefix
// ### Import Prefix
//
// The style of imports in the same crate is configurable through the `imports.prefix` setting.
// It has the following configurations:
Expand All @@ -66,7 +66,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
//
// In `VS Code` the configuration for this is `rust-analyzer.imports.prefix`.
//
// image::https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif[]
// ![Auto Import](https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif)

// Assist: auto_import
//
Expand Down
17 changes: 10 additions & 7 deletions crates/ide-assists/src/tests/sourcegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ r#####"
"sourcegen_assists_docs",
assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"),
);
let dst = project_root().join("docs/user/generated_assists.adoc");
let dst = project_root().join("manual/src/generated/assists.md");
fs::write(dst, contents).unwrap();
}
}
Expand Down Expand Up @@ -142,8 +142,9 @@ impl fmt::Display for Assist {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let _ = writeln!(
f,
"[discrete]\n=== `{}`
**Source:** {}",
// "[discrete]\n=== `{}`
// **Source:** {}",
"## `{}`\n\n**Source:** {}",
self.id, self.location,
);

Expand All @@ -155,12 +156,14 @@ impl fmt::Display for Assist {
"
{}

.Before
```rust
#### Before

```rust,noplayground
{}```

.After
```rust
#### After

```rust,noplayground
{}```",
section.doc,
hide_hash_comments(&before),
Expand Down
8 changes: 4 additions & 4 deletions crates/ide-completion/src/completions/flyimport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,27 @@ use super::Completions;
// 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,
// no imports will be proposed.
//
// .Fuzzy search details
// ### Fuzzy search details
//
// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the names only
// (i.e. in `HashMap` in the `std::collections::HashMap` path).
// For the same reasons, avoids searching for any path imports for inputs with their length less than 2 symbols
// (but shows all associated items for any input length).
//
// .Import configuration
// ### Import configuration
//
// It is possible to configure how use-trees are merged with the `imports.granularity.group` setting.
// Mimics the corresponding behavior of the `Auto Import` feature.
//
// .LSP and performance implications
// ### LSP and performance implications
//
// The feature is enabled only if the LSP client supports LSP protocol version 3.16+ and reports the `additionalTextEdits`
// (case-sensitive) resolve client capability in its client capabilities.
// This way the server is able to defer the costly computations, doing them for a selected completion item only.
// For clients with no such support, all edits have to be calculated on the completion request, including the fuzzy search completion ones,
// which might be slow ergo the feature is automatically disabled.
//
// .Feature toggle
// ### Feature toggle
//
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.autoimport.enable` flag.
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corresponding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ** `logw` -> `log::warn!(...)`
// ** `loge` -> `log::error!(...)`
//
// image::https://user-images.githubusercontent.com/48062697/113020656-b560f500-917a-11eb-87de-02991f61beb8.gif[]
// ![Format String Completion](https://user-images.githubusercontent.com/48062697/113020656-b560f500-917a-11eb-87de-02991f61beb8.gif)

use ide_db::{
syntax_helpers::format_string_exprs::{parse_format_exprs, with_placeholders},
Expand Down
6 changes: 3 additions & 3 deletions crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ pub use crate::{
//
// There also snippet completions:
//
// .Expressions
// ### Expressions
// - `pd` -> `eprintln!(" = {:?}", );`
// - `ppd` -> `eprintln!(" = {:#?}", );`
//
// .Items
// ### Items
// - `tfn` -> `#[test] fn feature(){}`
// - `tmod` ->
// ```rust
Expand All @@ -93,7 +93,7 @@ pub use crate::{
// Those are the additional completion options with automatic `use` import and options from all project importable items,
// fuzzy matched against the completion input.
//
// image::https://user-images.githubusercontent.com/48062697/113020667-b72ab880-917a-11eb-8778-716cf26a0eb3.gif[]
// ![Magic Completions](https://user-images.githubusercontent.com/48062697/113020667-b72ab880-917a-11eb-8778-716cf26a0eb3.gif)

/// Main entry point for completion. We run completion as a two-phase process.
///
Expand Down
11 changes: 5 additions & 6 deletions crates/ide-completion/src/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
//
// A custom snippet can be defined by adding it to the `rust-analyzer.completion.snippets.custom` object respectively.
//
// [source,json]
// ----
// ```json
// {
// "rust-analyzer.completion.snippets.custom": {
// "thread spawn": {
Expand All @@ -25,7 +24,7 @@
// }
// }
// }
// ----
// ```
//
// In the example above:
//
Expand Down Expand Up @@ -55,8 +54,8 @@
//
// For the VSCode editor, rust-analyzer also ships with a small set of defaults which can be removed
// by overwriting the settings object mentioned above, the defaults are:
// [source,json]
// ----
//
// ```json
// {
// "Arc::new": {
// "postfix": "arc",
Expand Down Expand Up @@ -98,7 +97,7 @@
// "scope": "expr"
// }
// }
// ----
// ```

use ide_db::imports::import_assets::LocatedImport;
use itertools::Itertools;
Expand Down
9 changes: 4 additions & 5 deletions crates/ide-db/src/apply_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ impl RootDatabase {
//
// Clears rust-analyzer's internal database and prints memory usage statistics.
//
// |===
// | Editor | Action Name
// | Editor | Action Name |
// |---------|-------------|
// | VS Code | **rust-analyzer: Memory Usage (Clears Database)** |
//
// | VS Code | **rust-analyzer: Memory Usage (Clears Database)**
// |===
// image::https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif[]
// ![Memory Usage](https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif)
pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
let mut acc: Vec<(String, Bytes)> = vec![];
macro_rules! purge_each_query {
Expand Down
8 changes: 3 additions & 5 deletions crates/ide-db/src/symbol_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ impl<DB> std::ops::Deref for Snap<DB> {
// the filtering via the `rust-analyzer.workspace.symbol.search.scope` and
// `rust-analyzer.workspace.symbol.search.kind` settings.
//
// |===
// | Editor | Shortcut
//
// | VS Code | kbd:[Ctrl+T]
// |===
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Ctrl+T</kbd> |
pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
let _p = profile::span("world_symbols").detail(|| query.query.clone());

Expand Down
4 changes: 2 additions & 2 deletions crates/ide-diagnostics/src/tests/sourcegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn sourcegen_diagnostic_docs() {
let contents =
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
let contents = sourcegen::add_preamble("sourcegen_diagnostic_docs", contents);
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
let dst = project_root().join("manual/src/generated/diagnostics.md");
fs::write(&dst, &contents).unwrap();
}

Expand Down Expand Up @@ -68,6 +68,6 @@ fn is_valid_diagnostic_name(diagnostic: &str) -> Result<(), String> {

impl fmt::Display for Diagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
writeln!(f, "## {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
}
}
18 changes: 7 additions & 11 deletions crates/ide-ssr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
//
// Supported constraints:
//
// |===
// | Constraint | Restricts placeholder
//
// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`)
// | not(a) | Negates the constraint `a`
// |===
// | Constraint | Restricts placeholder |
// |---------------|-----------------------|
// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`) |
// | not(a) | Negates the constraint `a`|
//
// Available via the command `rust-analyzer.ssr`.
//
Expand All @@ -54,11 +52,9 @@
// String::from((y + 5).foo(z))
// ```
//
// |===
// | Editor | Action Name
//
// | VS Code | **rust-analyzer: Structural Search Replace**
// |===
// | Editor | Action Name |
// |---------------|-----------------------|
// | VS Code | **rust-analyzer: Structural Search Replace** |
//
// Also available as an assist, by writing a comment containing the structural
// search and replace rule. You will only see the assist if the comment can
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
// Provides user with annotations above items for looking up references or impl blocks
// and running/debugging binaries.
//
// image::https://user-images.githubusercontent.com/48062697/113020672-b7c34f00-917a-11eb-8f6e-858735660a0e.png[]
// ![Annotations](https://user-images.githubusercontent.com/48062697/113020672-b7c34f00-917a-11eb-8f6e-858735660a0e.png)
#[derive(Debug)]
pub struct Annotation {
pub range: TextRange,
Expand Down
9 changes: 4 additions & 5 deletions crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ pub struct ExpandedMacro {
//
// Shows the full macro expansion of the macro at current cursor.
//
// |===
// | Editor | Action Name
//
// | VS Code | **rust-analyzer: Expand macro recursively**
// |===
// | Editor | Action Name |
// | --------| ------------|
// | VS Code | **rust-analyzer: Expand macro recursively** |
//
// image::https://user-images.githubusercontent.com/48062697/113020648-b3973180-917a-11eb-84a9-ecb921293dc5.gif[]
// ![Expand Macro Recursively](https://user-images.githubusercontent.com/48062697/113020648-b3973180-917a-11eb-84a9-ecb921293dc5.gif)
pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> {
let sema = Semantics::new(db);
let file = sema.parse(position.file_id);
Expand Down
10 changes: 4 additions & 6 deletions crates/ide/src/extend_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ use crate::FileRange;
//
// This is a standard LSP feature and not a protocol extension.
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>→</kbd>, <kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>←</kbd> |
//
// | VS Code | kbd:[Alt+Shift+→], kbd:[Alt+Shift+←]
// |===
//
// image::https://user-images.githubusercontent.com/48062697/113020651-b42fc800-917a-11eb-8a4f-cf1a07859fac.gif[]
// ![Expand and Shrink Selection](https://user-images.githubusercontent.com/48062697/113020651-b42fc800-917a-11eb-8a4f-cf1a07859fac.gif)
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
let sema = Semantics::new(db);
let src = sema.parse(frange.file_id);
Expand Down
10 changes: 4 additions & 6 deletions crates/ide/src/file_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ pub enum StructureNodeKind {
// * draw breadcrumbs to describe the context around the cursor
// * draw outline of the file
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>O</kbd> |
//
// | VS Code | kbd:[Ctrl+Shift+O]
// |===
//
// image::https://user-images.githubusercontent.com/48062697/113020654-b42fc800-917a-11eb-8388-e7dc4d92b02e.gif[]
// ![File Structure](https://user-images.githubusercontent.com/48062697/113020654-b42fc800-917a-11eb-8388-e7dc4d92b02e.gif)

pub(crate) fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
let mut res = Vec::new();
Expand Down
10 changes: 4 additions & 6 deletions crates/ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ use syntax::{ast, AstNode, AstToken, SyntaxKind::*, SyntaxToken, TextRange, T};
//
// For outline modules, this will navigate to the source file of the module.
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>F12</kbd> |
//
// | VS Code | kbd:[F12]
// |===
//
// image::https://user-images.githubusercontent.com/48062697/113065563-025fbe00-91b1-11eb-83e4-a5a703610b23.gif[]
// ![Got to Definition](https://user-images.githubusercontent.com/48062697/113065563-025fbe00-91b1-11eb-83e4-a5a703610b23.gif)
pub(crate) fn goto_definition(
db: &RootDatabase,
position: FilePosition,
Expand Down
10 changes: 4 additions & 6 deletions crates/ide/src/goto_implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav};
//
// Navigates to the impl blocks of types.
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Ctrl</kbd>+<kbd>F12</kbd> |
//
// | VS Code | kbd:[Ctrl+F12]
// |===
//
// image::https://user-images.githubusercontent.com/48062697/113065566-02f85480-91b1-11eb-9288-aaad8abd8841.gif[]
// ![Go to Implementation](https://user-images.githubusercontent.com/48062697/113065566-02f85480-91b1-11eb-9288-aaad8abd8841.gif)
pub(crate) fn goto_implementation(
db: &RootDatabase,
position: FilePosition,
Expand Down
10 changes: 4 additions & 6 deletions crates/ide/src/goto_type_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav};
//
// Navigates to the type of an identifier.
//
// |===
// | Editor | Action Name
// | Editor | Action Name |
// |---------|-------------|
// | VS Code | **Go to Type Definition* |
//
// | VS Code | **Go to Type Definition*
// |===
//
// image::https://user-images.githubusercontent.com/48062697/113020657-b560f500-917a-11eb-9007-0f809733a338.gif[]
// ![Go to Type Definition](https://user-images.githubusercontent.com/48062697/113020657-b560f500-917a-11eb-9007-0f809733a338.gif)
pub(crate) fn goto_type_definition(
db: &RootDatabase,
position: FilePosition,
Expand Down
8 changes: 4 additions & 4 deletions crates/ide/src/highlight_related.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ pub struct HighlightRelatedConfig {
//
// Highlights constructs related to the thing under the cursor:
//
// . if on an identifier, highlights all references to that identifier in the current file
// . if on an `async` or `await token, highlights all yield points for that async context
// . if on a `return` or `fn` keyword, `?` character or `->` return type arrow, highlights all exit points for that context
// . if on a `break`, `loop`, `while` or `for` token, highlights all break points for that loop or block context
// 1. if on an identifier, highlights all references to that identifier in the current file
// 1. if on an `async` or `await token, highlights all yield points for that async context
// 1. if on a `return` or `fn` keyword, `?` character or `->` return type arrow, highlights all exit points for that context
// 1. if on a `break`, `loop`, `while` or `for` token, highlights all break points for that loop or block context
//
// Note: `?` and `->` do not currently trigger this behavior in the VSCode editor.
pub(crate) fn highlight_related(
Expand Down
Loading