Skip to content

Commit

Permalink
Merge pull request #19015 from Wilfred/mdbook
Browse files Browse the repository at this point in the history
manual: Convert to mdbook
  • Loading branch information
Veykril authored Jan 28, 2025
2 parents 8ecb754 + 1f45995 commit a355626
Show file tree
Hide file tree
Showing 70 changed files with 2,836 additions and 2,686 deletions.
7 changes: 4 additions & 3 deletions src/tools/rust-analyzer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ target/
*.log
*.iml
.vscode/settings.json
generated_assists.adoc
generated_features.adoc
generated_diagnostic.adoc
.DS_Store
/out/
/dump.lsif
.envrc
docs/book/book
docs/book/src/assists_generated.md
docs/book/src/diagnostics_generated.md
docs/book/src/features_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin

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

// Assist: apply_demorgan_iterator
//
// Apply https://en.wikipedia.org/wiki/De_Morgan%27s_laws[De Morgan's law] to
// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) to
// `Iterator::all` and `Iterator::any`.
//
// This transforms expressions of the form `!iter.any(|x| predicate(x))` into
Expand Down
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 @@ -54,7 +54,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 @@ -68,7 +68,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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Generated by `cargo codegen assists-doc-tests`, do not edit by hand.
//! Generated by `cargo xtask codegen assists-doc-tests`, do not edit by hand.
use super::check_doc_test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ use crate::{
// 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, Arg},
Expand Down
8 changes: 5 additions & 3 deletions src/tools/rust-analyzer/crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ impl CompletionFieldsToResolve {
//
// There also snippet completions:
//
// .Expressions
// #### Expressions
//
// - `pd` -> `eprintln!(" = {:?}", );`
// - `ppd` -> `eprintln!(" = {:#?}", );`
//
// .Items
// #### Items
//
// - `tfn` -> `#[test] fn feature(){}`
// - `tmod` ->
// ```rust
Expand All @@ -127,7 +129,7 @@ impl CompletionFieldsToResolve {
// 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
12 changes: 6 additions & 6 deletions src/tools/rust-analyzer/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 All @@ -39,6 +38,7 @@
// * `description` is an optional description of the snippet, if unset the snippet name will be used.
//
// * `requires` is an optional list of item paths that have to be resolvable in the current crate where the completion is rendered.

// On failure of resolution the snippet won't be applicable, otherwise the snippet will insert an import for the items on insertion if
// the items aren't yet in scope.
//
Expand All @@ -55,8 +55,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 +98,7 @@
// "scope": "expr"
// }
// }
// ----
// ````

use hir::{ModPath, Name, Symbol};
use ide_db::imports::import_assets::LocatedImport;
Expand Down
9 changes: 4 additions & 5 deletions src/tools/rust-analyzer/crates/ide-db/src/apply_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,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)**
// |===
// 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, usize)> {
let mut acc: Vec<(String, Bytes, usize)> = vec![];

Expand Down
8 changes: 3 additions & 5 deletions src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,9 @@ impl<DB> std::ops::Deref for Snap<DB> {
// `rust-analyzer.workspace.symbol.search.kind` settings. Symbols prefixed
// with `__` are hidden from the search results unless configured otherwise.
//
// |===
// | 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 = tracing::info_span!("world_symbols", query = ?query.query).entered();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{

// Diagnostic: incorrect-ident-case
//
// This diagnostic is triggered if an item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention].
// This diagnostic is triggered if an item name doesn't follow [Rust naming convention](https://doc.rust-lang.org/1.0.0/style/style/naming/README.html).
pub(crate) fn incorrect_case(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Diagnostic {
let code = match d.expected_case {
CaseType::LowerSnakeCase => DiagnosticCode::RustcLint("non_snake_case"),
Expand Down
18 changes: 7 additions & 11 deletions src/tools/rust-analyzer/crates/ide-ssr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,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 @@ -52,11 +50,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 src/tools/rust-analyzer/crates/ide/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod fn_references;
// 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, Hash, PartialEq, Eq)]
pub struct Annotation {
pub range: TextRange,
Expand Down
8 changes: 3 additions & 5 deletions src/tools/rust-analyzer/crates/ide/src/doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ pub(crate) fn remove_links(markdown: &str) -> String {
// The simplest way to use this feature is via the context menu. Right-click on
// the selected item. The context menu opens. Select **Open Docs**.
//
// |===
// | Editor | Action Name
//
// | VS Code | **rust-analyzer: Open Docs**
// |===
// | Editor | Action Name |
// |---------|-------------|
// | VS Code | **rust-analyzer: Open Docs** |
pub(crate) fn external_docs(
db: &RootDatabase,
FilePosition { file_id, offset }: FilePosition,
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ pub struct ExpandedMacro {
//
// Shows the full macro expansion of the macro at the current caret position.
//
// |===
// | Editor | Action Name
// | Editor | Action Name |
// |---------|-------------|
// | VS Code | **rust-analyzer: Expand macro recursively at caret** |
//
// | VS Code | **rust-analyzer: Expand macro recursively at caret**
// |===
//
// 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_guess_edition(position.file_id);
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/ide/src/extend_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ use crate::FileRange;
// Extends or shrinks the current selection to the encompassing syntactic construct
// (expression, statement, item, module, etc). It works with multiple cursors.
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Alt+Shift+→</kbd>, <kbd>Alt+Shift+←</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_guess_edition(frange.file_id);
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/ide/src/fetch_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ pub struct CrateInfo {
//
// Shows a view tree with all the dependencies of this project
//
// |===
// | Editor | Panel Name
// | Editor | Panel Name |
// |---------|------------|
// | VS Code | **Rust Dependencies** |
//
// | VS Code | **Rust Dependencies**
// |===
//
// image::https://user-images.githubusercontent.com/5748995/229394139-2625beab-f4c9-484b-84ed-ad5dee0b1e1a.png[]
// ![Show Dependency Tree](https://user-images.githubusercontent.com/5748995/229394139-2625beab-f4c9-484b-84ed-ad5dee0b1e1a.png)
pub(crate) fn fetch_crates(db: &RootDatabase) -> FxIndexSet<CrateInfo> {
let crate_graph = db.crate_graph();
crate_graph
Expand Down
11 changes: 4 additions & 7 deletions src/tools/rust-analyzer/crates/ide/src/file_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,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+Shift+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();
let mut stack = Vec::new();
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ use syntax::{
//
// 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[]
// ![Go to Definition](https://user-images.githubusercontent.com/48062697/113065563-025fbe00-91b1-11eb-83e4-a5a703610b23.gif)
pub(crate) fn goto_definition(
db: &RootDatabase,
FilePosition { file_id, offset }: FilePosition,
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/ide/src/goto_implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav};
//
// Navigates to the impl items of types.
//
// |===
// | Editor | Shortcut
// | Editor | Shortcut |
// |---------|----------|
// | VS Code | <kbd>Ctrl+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,
FilePosition { file_id, offset }: FilePosition,
Expand Down
Loading

0 comments on commit a355626

Please sign in to comment.