aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen/gen_feature_docs.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-31 14:03:55 +0100
committerGitHub <[email protected]>2020-05-31 14:03:55 +0100
commitd96f3368d649b487c7d1fb479d5fd7c52e56c8fc (patch)
treee6cef1de0ed116a2178cf5a30a97ecfee6e8725f /xtask/src/codegen/gen_feature_docs.rs
parent5579ba8af5a31591a16b8f0f43053f73d07fb8b8 (diff)
parent46292c7cecb0bd957aee48f72b5c1e931ce47b79 (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/gen_feature_docs.rs')
-rw-r--r--xtask/src/codegen/gen_feature_docs.rs22
1 files changed, 4 insertions, 18 deletions
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs
index dbe583e8e..731e7ecf2 100644
--- a/xtask/src/codegen/gen_feature_docs.rs
+++ b/xtask/src/codegen/gen_feature_docs.rs
@@ -3,7 +3,7 @@
3use std::{fmt, fs, path::PathBuf}; 3use std::{fmt, fs, path::PathBuf};
4 4
5use crate::{ 5use crate::{
6 codegen::{self, extract_comment_blocks_with_empty_lines, Mode}, 6 codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode},
7 project_root, rust_files, Result, 7 project_root, rust_files, Result,
8}; 8};
9 9
@@ -19,7 +19,7 @@ pub fn generate_feature_docs(mode: Mode) -> Result<()> {
19#[derive(Debug)] 19#[derive(Debug)]
20struct Feature { 20struct Feature {
21 id: String, 21 id: String,
22 path: PathBuf, 22 location: Location,
23 doc: String, 23 doc: String,
24} 24}
25 25
@@ -40,7 +40,7 @@ impl Feature {
40 let id = block.id; 40 let id = block.id;
41 assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id); 41 assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id);
42 let doc = block.contents.join("\n"); 42 let doc = block.contents.join("\n");
43 acc.push(Feature { id, path: path.clone(), doc }) 43 acc.push(Feature { id, location: Location::new(path.clone()), doc })
44 } 44 }
45 45
46 Ok(()) 46 Ok(())
@@ -69,20 +69,6 @@ fn is_valid_feature_name(feature: &str) -> bool {
69 69
70impl fmt::Display for Feature { 70impl fmt::Display for Feature {
71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72 writeln!(f, "=== {}", self.id)?; 72 writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
73 let path = self.path.strip_prefix(&project_root()).unwrap().display().to_string();
74 let path = path.replace('\\', "/");
75 let name = self.path.file_name().unwrap();
76
77 //FIXME: generate line number as well
78 writeln!(
79 f,
80 "**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/{}[{}]",
81 path,
82 name.to_str().unwrap(),
83 )?;
84
85 writeln!(f, "{}", self.doc)?;
86 Ok(())
87 } 73 }
88} 74}