Generate features docs from source

This commit is contained in:
Aleksey Kladov 2020-05-31 01:54:54 +02:00
parent 383247a9ae
commit c8f27a4a88
15 changed files with 258 additions and 58 deletions

View file

@ -18,6 +18,19 @@ pub struct StructureNode {
pub deprecated: bool,
}
// Feature: File Structure
//
// Provides a tree of the symbols defined in the file. Can be used to
//
// * fuzzy search symbol in a file (super useful)
// * draw breadcrumbs to describe the context around the cursor
// * draw outline of the file
//
// |===
// | Editor | Shortcut
//
// | VS Code | kbd:[Ctrl+Shift+O]
// |===
pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
let mut res = Vec::new();
let mut stack = Vec::new();

View file

@ -14,6 +14,16 @@ use ra_syntax::{
use crate::FileRange;
// Feature: Extend Selection
//
// Extends the current selection to the encompassing syntactic construct
// (expression, statement, item, module, etc). It works with multiple cursors.
//
// |===
// | Editor | Shortcut
//
// | VS Code | kbd:[Ctrl+Shift+→]
// |===
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
let sema = Semantics::new(db);
let src = sema.parse(frange.file_id);

View file

@ -17,6 +17,15 @@ use crate::{
FilePosition, NavigationTarget, RangeInfo,
};
// Feature: Go To Definition
//
// Navigates to the definition of an identifier.
//
// |===
// | Editor | Shortcut
//
// | VS Code | kbd:[F12]
// |===
pub(crate) fn goto_definition(
db: &RootDatabase,
position: FilePosition,

View file

@ -6,6 +6,15 @@ use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
// Feature: Go To Implementation
//
// Navigates to the impl block of structs, enums or traits. Also implemented as a code lens.
//
// |===
// | Editor | Shortcut
//
// | VS Code | kbd:[Ctrl+F12]
// |===
pub(crate) fn goto_implementation(
db: &RootDatabase,
position: FilePosition,

View file

@ -5,6 +5,9 @@ use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffs
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
// Feature: Go To Type Definition
//
// Navigates to the type of an identifier.
pub(crate) fn goto_type_definition(
db: &RootDatabase,
position: FilePosition,

View file

@ -23,6 +23,7 @@ mod completion;
mod runnables;
mod goto_definition;
mod goto_type_definition;
mod goto_implementation;
mod extend_selection;
mod hover;
mod call_hierarchy;
@ -30,7 +31,6 @@ mod call_info;
mod syntax_highlighting;
mod parent_module;
mod references;
mod impls;
mod diagnostics;
mod syntax_tree;
mod folding_ranges;
@ -373,7 +373,7 @@ impl Analysis {
&self,
position: FilePosition,
) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> {
self.with_db(|db| impls::goto_implementation(db, position))
self.with_db(|db| goto_implementation::goto_implementation(db, position))
}
/// Returns the type definitions for the symbol at `position`.

View file

@ -32,6 +32,13 @@ pub(crate) use on_enter::on_enter;
pub(crate) const TRIGGER_CHARS: &str = ".=>";
// Feature: On Typing Assists
//
// Some features trigger on typing certain characters:
//
// - typing `let =` tries to smartly add `;` if `=` is followed by an existing expression
// - Enter inside comments automatically inserts `///`
// - typing `.` in a chain method call auto-indents
pub(crate) fn on_char_typed(
db: &RootDatabase,
position: FilePosition,