aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-31 14:02:12 +0100
committerAleksey Kladov <[email protected]>2020-05-31 14:02:12 +0100
commit46292c7cecb0bd957aee48f72b5c1e931ce47b79 (patch)
tree51355c749f7931101f5e79ce42814217da354cad /xtask/src/codegen.rs
parent5a2f4548e59981871fe4db2b9ee591b9bf39a46e (diff)
Move assists documentation into the manual
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r--xtask/src/codegen.rs33
1 files changed, 30 insertions, 3 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index f47d54125..f3917a244 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -10,9 +10,12 @@ mod gen_parser_tests;
10mod gen_assists_docs; 10mod gen_assists_docs;
11mod gen_feature_docs; 11mod gen_feature_docs;
12 12
13use std::{mem, path::Path}; 13use std::{
14 fmt, mem,
15 path::{Path, PathBuf},
16};
14 17
15use crate::{not_bash::fs2, Result}; 18use crate::{not_bash::fs2, project_root, Result};
16 19
17pub use self::{ 20pub use self::{
18 gen_assists_docs::generate_assists_docs, gen_feature_docs::generate_feature_docs, 21 gen_assists_docs::generate_assists_docs, gen_feature_docs::generate_feature_docs,
@@ -29,7 +32,6 @@ const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs";
29 32
30const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; 33const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers";
31const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; 34const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs";
32const ASSISTS_DOCS: &str = "docs/user/assists.md";
33 35
34#[derive(Debug, PartialEq, Eq, Clone, Copy)] 36#[derive(Debug, PartialEq, Eq, Clone, Copy)]
35pub enum Mode { 37pub enum Mode {
@@ -107,3 +109,28 @@ fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) ->
107 } 109 }
108 res 110 res
109} 111}
112
113#[derive(Debug)]
114struct Location {
115 file: PathBuf,
116}
117
118impl Location {
119 fn new(file: PathBuf) -> Self {
120 Self { file }
121 }
122}
123
124impl fmt::Display for Location {
125 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126 let path = self.file.strip_prefix(&project_root()).unwrap().display().to_string();
127 let path = path.replace('\\', "/");
128 let name = self.file.file_name().unwrap();
129 write!(
130 f,
131 "https://github.com/rust-analyzer/rust-analyzer/blob/master/{}[{}]",
132 path,
133 name.to_str().unwrap()
134 )
135 }
136}