about summary refs log tree commit diff
path: root/xtask/src/codegen.rs
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-05-31 15:02:12 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-05-31 15:02:12 +0200
commit46292c7cecb0bd957aee48f72b5c1e931ce47b79 (patch)
tree51355c749f7931101f5e79ce42814217da354cad /xtask/src/codegen.rs
parent5a2f4548e59981871fe4db2b9ee591b9bf39a46e (diff)
downloadrust-46292c7cecb0bd957aee48f72b5c1e931ce47b79.tar.gz
rust-46292c7cecb0bd957aee48f72b5c1e931ce47b79.zip
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 f47d54125f3..f3917a244aa 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -10,9 +10,12 @@ mod gen_parser_tests;
 mod gen_assists_docs;
 mod gen_feature_docs;
 
-use std::{mem, path::Path};
+use std::{
+    fmt, mem,
+    path::{Path, PathBuf},
+};
 
-use crate::{not_bash::fs2, Result};
+use crate::{not_bash::fs2, project_root, Result};
 
 pub use self::{
     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";
 
 const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers";
 const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs";
-const ASSISTS_DOCS: &str = "docs/user/assists.md";
 
 #[derive(Debug, PartialEq, Eq, Clone, Copy)]
 pub enum Mode {
@@ -107,3 +109,28 @@ fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) ->
     }
     res
 }
+
+#[derive(Debug)]
+struct Location {
+    file: PathBuf,
+}
+
+impl Location {
+    fn new(file: PathBuf) -> Self {
+        Self { file }
+    }
+}
+
+impl fmt::Display for Location {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        let path = self.file.strip_prefix(&project_root()).unwrap().display().to_string();
+        let path = path.replace('\\', "/");
+        let name = self.file.file_name().unwrap();
+        write!(
+            f,
+            "https://github.com/rust-analyzer/rust-analyzer/blob/master/{}[{}]",
+            path,
+            name.to_str().unwrap()
+        )
+    }
+}