Skip to content
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

Move manual to mdbook #13330

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 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
generated_assists.adoc
generated_features.adoc
generated_diagnostic.adoc
generated_assists.md
generated_features.md
generated_diagnostics.md
generated_config.md
.DS_Store
/out/
/dump.lsif
.envrc
docs/manual/book/
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
10 changes: 6 additions & 4 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("docs/manual/src/generated_assists.md");
fs::write(dst, contents).unwrap();
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ impl fmt::Display for Assist {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let _ = writeln!(
f,
"[discrete]\n=== `{}`
"## `{}`\n\n
**Source:** {}",
self.id, self.location,
);
Expand All @@ -155,11 +155,13 @@ impl fmt::Display for Assist {
"
{}

.Before
### Before

```rust
{}```

.After
### After

```rust
{}```",
section.doc,
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
12 changes: 6 additions & 6 deletions crates/ide-completion/src/completions/postfix/format_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// * `panic` -> `panic!(...)`
// * `println` -> `println!(...)`
// * `log`:
// ** `logd` -> `log::debug!(...)`
// ** `logt` -> `log::trace!(...)`
// ** `logi` -> `log::info!(...)`
// ** `logw` -> `log::warn!(...)`
// ** `loge` -> `log::error!(...)`
// * `logd` -> `log::debug!(...)`
// * `logt` -> `log::trace!(...)`
// * `logi` -> `log::info!(...)`
// * `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
8 changes: 5 additions & 3 deletions crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ 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 +95,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
15 changes: 7 additions & 8 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 All @@ -43,8 +42,8 @@
// the items aren't yet in scope.
//
// * `scope` is an optional filter for when the snippet should be applicable. Possible values are:
// ** for Snippet-Scopes: `expr`, `item` (default: `item`)
// ** for Postfix-Snippet-Scopes: `expr`, `type` (default: `expr`)
// * for Snippet-Scopes: `expr`, `item` (default: `item`)
// * for Postfix-Snippet-Scopes: `expr`, `type` (default: `expr`)
//
// The `body` field also has access to placeholders as visible in the example as `$0`.
// These placeholders take the form of `$number` or `${number:placeholder_text}` which can be traversed as tabstop in ascending order starting from 1,
Expand All @@ -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("docs/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
10 changes: 4 additions & 6 deletions crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ pub struct ExpandedMacro {
//
// Shows the full macro expansion of the macro at current cursor.
//
// |===
// | Editor | Action Name
// | Editor | Action Name |
// |--------|-------------|
// | VS Code | **rust-analyzer: Expand macro recursively** |
//
// | 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+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(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+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();
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[]
// ![Go 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+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
Loading