diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-31 14:03:55 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-31 14:03:55 +0100 |
commit | d96f3368d649b487c7d1fb479d5fd7c52e56c8fc (patch) | |
tree | e6cef1de0ed116a2178cf5a30a97ecfee6e8725f /xtask/src/codegen.rs | |
parent | 5579ba8af5a31591a16b8f0f43053f73d07fb8b8 (diff) | |
parent | 46292c7cecb0bd957aee48f72b5c1e931ce47b79 (diff) |
Merge #4670
4670: Move assists documentation into the manual r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r-- | xtask/src/codegen.rs | 33 |
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; | |||
10 | mod gen_assists_docs; | 10 | mod gen_assists_docs; |
11 | mod gen_feature_docs; | 11 | mod gen_feature_docs; |
12 | 12 | ||
13 | use std::{mem, path::Path}; | 13 | use std::{ |
14 | fmt, mem, | ||
15 | path::{Path, PathBuf}, | ||
16 | }; | ||
14 | 17 | ||
15 | use crate::{not_bash::fs2, Result}; | 18 | use crate::{not_bash::fs2, project_root, Result}; |
16 | 19 | ||
17 | pub use self::{ | 20 | pub 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 | ||
30 | const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; | 33 | const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; |
31 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; | 34 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; |
32 | const ASSISTS_DOCS: &str = "docs/user/assists.md"; | ||
33 | 35 | ||
34 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 36 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
35 | pub enum Mode { | 37 | pub 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)] | ||
114 | struct Location { | ||
115 | file: PathBuf, | ||
116 | } | ||
117 | |||
118 | impl Location { | ||
119 | fn new(file: PathBuf) -> Self { | ||
120 | Self { file } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | impl 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 | } | ||