mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
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 https://github.com/rust-analyzer/rust-analyzer.github.io/pull/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>
This commit is contained in:
parent
6e4c29f7ce
commit
deda58e8f1
70 changed files with 2836 additions and 2686 deletions
|
|
@ -76,113 +76,118 @@ pub struct HighlightConfig {
|
|||
// We also give special modifier for `mut` and `&mut` local variables.
|
||||
//
|
||||
//
|
||||
// .Token Tags
|
||||
// #### Token Tags
|
||||
//
|
||||
// Rust-analyzer currently emits the following token tags:
|
||||
//
|
||||
// - For items:
|
||||
// +
|
||||
// [horizontal]
|
||||
// attribute:: Emitted for attribute macros.
|
||||
// enum:: Emitted for enums.
|
||||
// function:: Emitted for free-standing functions.
|
||||
// derive:: Emitted for derive macros.
|
||||
// macro:: Emitted for function-like macros.
|
||||
// method:: Emitted for associated functions, also knowns as methods.
|
||||
// namespace:: Emitted for modules.
|
||||
// struct:: Emitted for structs.
|
||||
// trait:: Emitted for traits.
|
||||
// typeAlias:: Emitted for type aliases and `Self` in `impl`s.
|
||||
// union:: Emitted for unions.
|
||||
//
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// | attribute | Emitted for attribute macros. |
|
||||
// |enum| Emitted for enums. |
|
||||
// |function| Emitted for free-standing functions. |
|
||||
// |derive| Emitted for derive macros. |
|
||||
// |macro| Emitted for function-like macros. |
|
||||
// |method| Emitted for associated functions, also knowns as methods. |
|
||||
// |namespace| Emitted for modules. |
|
||||
// |struct| Emitted for structs.|
|
||||
// |trait| Emitted for traits.|
|
||||
// |typeAlias| Emitted for type aliases and `Self` in `impl`s.|
|
||||
// |union| Emitted for unions.|
|
||||
//
|
||||
// - For literals:
|
||||
// +
|
||||
// [horizontal]
|
||||
// boolean:: Emitted for the boolean literals `true` and `false`.
|
||||
// character:: Emitted for character literals.
|
||||
// number:: Emitted for numeric literals.
|
||||
// string:: Emitted for string literals.
|
||||
// escapeSequence:: Emitted for escaped sequences inside strings like `\n`.
|
||||
// formatSpecifier:: Emitted for format specifiers `{:?}` in `format!`-like macros.
|
||||
//
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// | boolean| Emitted for the boolean literals `true` and `false`.|
|
||||
// | character| Emitted for character literals.|
|
||||
// | number| Emitted for numeric literals.|
|
||||
// | string| Emitted for string literals.|
|
||||
// | escapeSequence| Emitted for escaped sequences inside strings like `\n`.|
|
||||
// | formatSpecifier| Emitted for format specifiers `{:?}` in `format!`-like macros.|
|
||||
//
|
||||
// - For operators:
|
||||
// +
|
||||
// [horizontal]
|
||||
// operator:: Emitted for general operators.
|
||||
// arithmetic:: Emitted for the arithmetic operators `+`, `-`, `*`, `/`, `+=`, `-=`, `*=`, `/=`.
|
||||
// bitwise:: Emitted for the bitwise operators `|`, `&`, `!`, `^`, `|=`, `&=`, `^=`.
|
||||
// comparison:: Emitted for the comparison operators `>`, `<`, `==`, `>=`, `<=`, `!=`.
|
||||
// logical:: Emitted for the logical operators `||`, `&&`, `!`.
|
||||
//
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// |operator| Emitted for general operators.|
|
||||
// |arithmetic| Emitted for the arithmetic operators `+`, `-`, `*`, `/`, `+=`, `-=`, `*=`, `/=`.|
|
||||
// |bitwise| Emitted for the bitwise operators `|`, `&`, `!`, `^`, `|=`, `&=`, `^=`.|
|
||||
// |comparison| Emitted for the comparison oerators `>`, `<`, `==`, `>=`, `<=`, `!=`.|
|
||||
// |logical| Emitted for the logical operatos `||`, `&&`, `!`.|
|
||||
//
|
||||
// - For punctuation:
|
||||
// +
|
||||
// [horizontal]
|
||||
// punctuation:: Emitted for general punctuation.
|
||||
// attributeBracket:: Emitted for attribute invocation brackets, that is the `#[` and `]` tokens.
|
||||
// angle:: Emitted for `<>` angle brackets.
|
||||
// brace:: Emitted for `{}` braces.
|
||||
// bracket:: Emitted for `[]` brackets.
|
||||
// parenthesis:: Emitted for `()` parentheses.
|
||||
// colon:: Emitted for the `:` token.
|
||||
// comma:: Emitted for the `,` token.
|
||||
// dot:: Emitted for the `.` token.
|
||||
// semi:: Emitted for the `;` token.
|
||||
// macroBang:: Emitted for the `!` token in macro calls.
|
||||
//
|
||||
// //-
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// |punctuation| Emitted for general punctuation.|
|
||||
// |attributeBracket| Emitted for attribute invocation brackets, that is the `#[` and `]` tokens.|
|
||||
// |angle| Emitted for `<>` angle brackets.|
|
||||
// |brace| Emitted for `{}` braces.|
|
||||
// |bracket| Emitted for `[]` brackets.|
|
||||
// |parenthesis| Emitted for `()` parentheses.|
|
||||
// |colon| Emitted for the `:` token.|
|
||||
// |comma| Emitted for the `,` token.|
|
||||
// |dot| Emitted for the `.` token.|
|
||||
// |semi| Emitted for the `;` token.|
|
||||
// |macroBang| Emitted for the `!` token in macro calls.|
|
||||
//
|
||||
// [horizontal]
|
||||
// builtinAttribute:: Emitted for names to builtin attributes in attribute path, the `repr` in `#[repr(u8)]` for example.
|
||||
// builtinType:: Emitted for builtin types like `u32`, `str` and `f32`.
|
||||
// comment:: Emitted for comments.
|
||||
// constParameter:: Emitted for const parameters.
|
||||
// deriveHelper:: Emitted for derive helper attributes.
|
||||
// enumMember:: Emitted for enum variants.
|
||||
// generic:: Emitted for generic tokens that have no mapping.
|
||||
// keyword:: Emitted for keywords.
|
||||
// label:: Emitted for labels.
|
||||
// lifetime:: Emitted for lifetimes.
|
||||
// parameter:: Emitted for non-self function parameters.
|
||||
// property:: Emitted for struct and union fields.
|
||||
// selfKeyword:: Emitted for the self function parameter and self path-specifier.
|
||||
// selfTypeKeyword:: Emitted for the Self type parameter.
|
||||
// toolModule:: Emitted for tool modules.
|
||||
// typeParameter:: Emitted for type parameters.
|
||||
// unresolvedReference:: Emitted for unresolved references, names that rust-analyzer can't find the definition of.
|
||||
// variable:: Emitted for locals, constants and statics.
|
||||
//-
|
||||
//
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// |builtinAttribute| Emitted for names to builtin attributes in attribute path, the `repr` in `#[repr(u8)]` for example.|
|
||||
// |builtinType| Emitted for builtin types like `u32`, `str` and `f32`.|
|
||||
// |comment| Emitted for comments.|
|
||||
// |constParameter| Emitted for const parameters.|
|
||||
// |deriveHelper| Emitted for derive helper attributes.|
|
||||
// |enumMember| Emitted for enum variants.|
|
||||
// |generic| Emitted for generic tokens that have no mapping.|
|
||||
// |keyword| Emitted for keywords.|
|
||||
// |label| Emitted for labels.|
|
||||
// |lifetime| Emitted for lifetimes.|
|
||||
// |parameter| Emitted for non-self function parameters.|
|
||||
// |property| Emitted for struct and union fields.|
|
||||
// |selfKeyword| Emitted for the self function parameter and self path-specifier.|
|
||||
// |selfTypeKeyword| Emitted for the Self type parameter.|
|
||||
// |toolModule| Emitted for tool modules.|
|
||||
// |typeParameter| Emitted for type parameters.|
|
||||
// |unresolvedReference| Emitted for unresolved references, names that rust-analyzer can't find the definition of.|
|
||||
// |variable| Emitted for locals, constants and statics.|
|
||||
//
|
||||
//
|
||||
// .Token Modifiers
|
||||
// #### Token Modifiers
|
||||
//
|
||||
// Token modifiers allow to style some elements in the source code more precisely.
|
||||
//
|
||||
// Rust-analyzer currently emits the following token modifiers:
|
||||
//
|
||||
// [horizontal]
|
||||
// async:: Emitted for async functions and the `async` and `await` keywords.
|
||||
// attribute:: Emitted for tokens inside attributes.
|
||||
// callable:: Emitted for locals whose types implements one of the `Fn*` traits.
|
||||
// constant:: Emitted for consts.
|
||||
// consuming:: Emitted for locals that are being consumed when use in a function call.
|
||||
// controlFlow:: Emitted for control-flow related tokens, this includes the `?` operator.
|
||||
// crateRoot:: Emitted for crate names, like `serde` and `crate`.
|
||||
// declaration:: Emitted for names of definitions, like `foo` in `fn foo() {}`.
|
||||
// defaultLibrary:: Emitted for items from built-in crates (std, core, alloc, test and proc_macro).
|
||||
// documentation:: Emitted for documentation comments.
|
||||
// injected:: Emitted for doc-string injected highlighting like rust source blocks in documentation.
|
||||
// intraDocLink:: Emitted for intra doc links in doc-strings.
|
||||
// library:: Emitted for items that are defined outside of the current crate.
|
||||
// macro:: Emitted for tokens inside macro calls.
|
||||
// mutable:: Emitted for mutable locals and statics as well as functions taking `&mut self`.
|
||||
// public:: Emitted for items that are from the current crate and are `pub`.
|
||||
// reference:: Emitted for locals behind a reference and functions taking `self` by reference.
|
||||
// static:: Emitted for "static" functions, also known as functions that do not take a `self` param, as well as statics and consts.
|
||||
// trait:: Emitted for associated trait items.
|
||||
// unsafe:: Emitted for unsafe operations, like unsafe function calls, as well as the `unsafe` token.
|
||||
// | | |
|
||||
// |-----------|--------------------------------|
|
||||
// |async| Emitted for async functions and the `async` and `await` keywords.|
|
||||
// |attribute| Emitted for tokens inside attributes.|
|
||||
// |callable| Emitted for locals whose types implements one of the `Fn*` traits.|
|
||||
// |constant| Emitted for const.|
|
||||
// |consuming| Emitted for locals that are being consumed when use in a function call.|
|
||||
// |controlFlow| Emitted for control-flow related tokens, this includes th `?` operator.|
|
||||
// |crateRoot| Emitted for crate names, like `serde` and `crate.|
|
||||
// |declaration| Emitted for names of definitions, like `foo` in `fn foo(){}`.|
|
||||
// |defaultLibrary| Emitted for items from built-in crates (std, core, allc, test and proc_macro).|
|
||||
// |documentation| Emitted for documentation comment.|
|
||||
// |injected| Emitted for doc-string injected highlighting like rust source blocks in documentation.|
|
||||
// |intraDocLink| Emitted for intra doc links in doc-string.|
|
||||
// |library| Emitted for items that are defined outside of the current crae.|
|
||||
// |macro| Emitted for tokens inside macro call.|
|
||||
// |mutable| Emitted for mutable locals and statics as well as functions taking `&mut self`.|
|
||||
// |public| Emitted for items that are from the current crate and are `pub.|
|
||||
// |reference| Emitted for locals behind a reference and functions taking self` by reference.|
|
||||
// |static| Emitted for "static" functions, also known as functions that d not take a `self` param, as well as statics and consts.|
|
||||
// |trait| Emitted for associated trait item.|
|
||||
// |unsafe| Emitted for unsafe operations, like unsafe function calls, as ell as the `unsafe` token.|
|
||||
//
|
||||
//
|
||||
// image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[]
|
||||
// image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[]
|
||||
// 
|
||||
// 
|
||||
pub(crate) fn highlight(
|
||||
db: &RootDatabase,
|
||||
config: HighlightConfig,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue