Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct Feature {
pub tracking_issue: Option<NonZeroU32>,
pub file: PathBuf,
pub line: usize,
pub description: Option<String>,
}
impl Feature {
fn tracking_issue_display(&self) -> impl fmt::Display {
Expand Down Expand Up @@ -296,6 +297,7 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
let mut prev_names = vec![];

let lines = contents.lines().zip(1..);
let mut doc_comments: Vec<String> = Vec::new();
for (line, line_number) in lines {
let line = line.trim();

Expand Down Expand Up @@ -332,6 +334,13 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
continue;
}

if in_feature_group {
if let Some(doc_comment) = line.strip_prefix("///") {
doc_comments.push(doc_comment.trim().to_string());
continue;
}
}

let mut parts = line.split(',');
let level = match parts.next().map(|l| l.trim().trim_start_matches('(')) {
Some("unstable") => Status::Unstable,
Expand Down Expand Up @@ -438,9 +447,15 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
tracking_issue,
file: path.to_path_buf(),
line: line_number,
description: if doc_comments.is_empty() {
None
} else {
Some(doc_comments.join(" "))
},
});
}
}
doc_comments.clear();
}
}

Expand Down Expand Up @@ -564,6 +579,7 @@ fn map_lib_features(
tracking_issue: find_attr_val(line, "issue").and_then(handle_issue_none),
file: file.to_path_buf(),
line: i + 1,
description: None,
};
mf(Ok((feature_name, feature)), file, i + 1);
continue;
Expand Down Expand Up @@ -600,6 +616,7 @@ fn map_lib_features(
tracking_issue,
file: file.to_path_buf(),
line: i + 1,
description: None,
};
if line.contains(']') {
mf(Ok((feature_name, feature)), file, i + 1);
Expand Down
23 changes: 17 additions & 6 deletions src/tools/unstable-book-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ use tidy::unstable_book::{
collect_unstable_feature_names,
};

fn generate_stub_issue(path: &Path, name: &str, issue: u32) {
let content = format!(include_str!("stub-issue.md"), name = name, issue = issue);
fn generate_stub_issue(path: &Path, name: &str, issue: u32, description: &str) {
let content = format!(
include_str!("stub-issue.md"),
name = name,
issue = issue,
description = description
);
t!(write(path, content), path);
}

fn generate_stub_no_issue(path: &Path, name: &str) {
let content = format!(include_str!("stub-no-issue.md"), name = name);
fn generate_stub_no_issue(path: &Path, name: &str, description: &str) {
let content = format!(include_str!("stub-no-issue.md"), name = name, description = description);
t!(write(path, content), path);
}

Expand Down Expand Up @@ -58,11 +63,17 @@ fn generate_unstable_book_files(src: &Path, out: &Path, features: &Features) {
let file_name = format!("{feature_name}.md");
let out_file_path = out.join(&file_name);
let feature = &features[&feature_name_underscore];
let description = feature.description.as_deref().unwrap_or_default();

if let Some(issue) = feature.tracking_issue {
generate_stub_issue(&out_file_path, &feature_name_underscore, issue.get());
generate_stub_issue(
&out_file_path,
&feature_name_underscore,
issue.get(),
&description,
);
} else {
generate_stub_no_issue(&out_file_path, &feature_name_underscore);
generate_stub_no_issue(&out_file_path, &feature_name_underscore, &description);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/unstable-book-gen/src/stub-issue.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# `{name}`

{description}

The tracking issue for this feature is: [#{issue}]

[#{issue}]: https://github.com/rust-lang/rust/issues/{issue}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/unstable-book-gen/src/stub-no-issue.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# `{name}`

{description}

This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.

------------------------
Loading