Skip to content

Commit 532ba38

Browse files
authored
Merge pull request #200 from nikomatsakis/poc
require a single point-of-contact
2 parents 926d600 + ca2d265 commit 532ba38

File tree

92 files changed

+668
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+668
-383
lines changed

book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ level = 0
4242
"/2024h2/accepted.html" = "goals.html"
4343
"/2024h2/flagship.html" = "goals.html"
4444
"/introduction.html" = "index.html"
45+
"/about/provisional_goals.html" = "about/invited_goals.html"
4546

4647
[output.markdown]

crates/mdbook-goals/src/mdbook_preprocessor.rs

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl Preprocessor for GoalPreprocessor {
3737

3838
pub struct GoalPreprocessorWithContext<'c> {
3939
team_asks: &'static Regex,
40-
goal_list: &'static Regex,
4140
goal_count: &'static Regex,
4241
username: &'static Regex,
4342
ctx: &'c PreprocessorContext,
@@ -116,7 +115,6 @@ impl<'c> GoalPreprocessorWithContext<'c> {
116115
Ok(GoalPreprocessorWithContext {
117116
ctx,
118117
team_asks: &re::TEAM_ASKS,
119-
goal_list: &re::GOAL_LIST,
120118
goal_count: &re::GOAL_COUNT,
121119
username: &re::USERNAME,
122120
links,
@@ -163,7 +161,7 @@ impl<'c> GoalPreprocessorWithContext<'c> {
163161

164162
let count = goals
165163
.iter()
166-
.filter(|g| g.metadata.status != Status::NotAccepted)
164+
.filter(|g| g.metadata.status.is_not_not_accepted())
167165
.count();
168166

169167
chapter.content = self
@@ -175,54 +173,54 @@ impl<'c> GoalPreprocessorWithContext<'c> {
175173
}
176174

177175
fn replace_goal_lists(&mut self, chapter: &mut Chapter) -> anyhow::Result<()> {
178-
let Some(m) = self.goal_list.captures(&chapter.content) else {
179-
return Ok(());
180-
};
181-
let range = m.get(0).unwrap().range();
182-
let statuses = m[1]
183-
.split(',')
184-
.map(|s| s.trim())
185-
.map(Status::try_from)
186-
.collect::<anyhow::Result<Vec<Status>>>()?;
187-
188-
let Some(chapter_path) = &chapter.path else {
189-
anyhow::bail!("found `<!-- GOALS -->` but chapter has no path")
190-
};
191-
192-
// Extract out the list of goals with the given status.
193-
let goals = self.goal_documents(chapter_path)?;
194-
let mut goals_with_status: Vec<&GoalDocument> = statuses
195-
.iter()
196-
.flat_map(|&status| goals.iter().filter(move |g| g.metadata.status == status))
197-
.collect();
198-
199-
goals_with_status.sort_by_key(|g| &g.metadata.title);
200-
201-
// Format the list of goals and replace the `<!-- -->` comment with that.
202-
let output = goal::format_goal_table(&goals_with_status)?;
203-
chapter.content.replace_range(range, &output);
204-
205-
// Populate with children if this is not README
206-
if chapter_path.file_stem() != Some("README".as_ref()) {
207-
let mut parent_names = chapter.parent_names.clone();
208-
parent_names.push(chapter.name.clone());
209-
for (goal, index) in goals_with_status.iter().zip(0..) {
210-
let content = std::fs::read_to_string(&goal.path)
211-
.with_context(|| format!("reading `{}`", goal.path.display()))?;
212-
let path = goal.path.strip_prefix(&self.ctx.config.book.src).unwrap();
213-
let mut new_chapter =
214-
Chapter::new(&goal.metadata.title, content, path, parent_names.clone());
215-
216-
if let Some(mut number) = chapter.number.clone() {
217-
number.0.push(index + 1);
218-
new_chapter.number = Some(number);
176+
self.replace_goal_lists_helper(chapter, &re::FLAGSHIP_GOAL_LIST, |status| status.is_flagship && status.is_not_not_accepted())?;
177+
self.replace_goal_lists_helper(chapter, &re::OTHER_GOAL_LIST, |status| !status.is_flagship && status.is_not_not_accepted())?;
178+
self.replace_goal_lists_helper(chapter, &re::GOAL_LIST, |status| status.is_not_not_accepted())?;
179+
self.replace_goal_lists_helper(chapter, &re::GOAL_NOT_ACCEPTED_LIST, |status| !status.is_not_not_accepted())?;
180+
Ok(())
181+
}
182+
183+
fn replace_goal_lists_helper(&mut self, chapter: &mut Chapter, regex: &Regex, filter: impl Fn(Status) -> bool) -> anyhow::Result<()> {
184+
loop {
185+
let Some(m) = regex.find(&chapter.content) else {
186+
return Ok(());
187+
};
188+
let range = m.range();
189+
190+
let Some(chapter_path) = &chapter.path else {
191+
anyhow::bail!("found `{regex}` but chapter has no path")
192+
};
193+
194+
// Extract out the list of goals with the given status.
195+
let goals = self.goal_documents(chapter_path)?;
196+
let mut goals_with_status: Vec<&GoalDocument> = goals.iter().filter(|g| filter(g.metadata.status)).collect();
197+
198+
goals_with_status.sort_by_key(|g| &g.metadata.title);
199+
200+
// Format the list of goals and replace the `<!-- -->` comment with that.
201+
let output = goal::format_goal_table(&goals_with_status)?;
202+
chapter.content.replace_range(range, &output);
203+
204+
// Populate with children if this is not README
205+
if chapter_path.file_stem() != Some("README".as_ref()) {
206+
let mut parent_names = chapter.parent_names.clone();
207+
parent_names.push(chapter.name.clone());
208+
for (goal, index) in goals_with_status.iter().zip(0..) {
209+
let content = std::fs::read_to_string(&goal.path)
210+
.with_context(|| format!("reading `{}`", goal.path.display()))?;
211+
let path = goal.path.strip_prefix(&self.ctx.config.book.src).unwrap();
212+
let mut new_chapter =
213+
Chapter::new(&goal.metadata.title, content, path, parent_names.clone());
214+
215+
if let Some(mut number) = chapter.number.clone() {
216+
number.0.push(index + 1);
217+
new_chapter.number = Some(number);
218+
}
219+
220+
chapter.sub_items.push(BookItem::Chapter(new_chapter));
219221
}
220-
221-
chapter.sub_items.push(BookItem::Chapter(new_chapter));
222222
}
223223
}
224-
225-
self.replace_goal_lists(chapter)
226224
}
227225

228226
/// Look for `<!-- TEAM ASKS -->` in the chapter content and replace it with the team asks.
@@ -239,7 +237,7 @@ impl<'c> GoalPreprocessorWithContext<'c> {
239237
let goals = self.goal_documents(path)?;
240238
let asks_of_any_team: Vec<&TeamAsk> = goals
241239
.iter()
242-
.filter(|g| g.metadata.status != Status::NotAccepted)
240+
.filter(|g| g.metadata.status.is_not_not_accepted())
243241
.flat_map(|g| &g.team_asks)
244242
.collect();
245243
let format_team_asks = format_team_asks(&asks_of_any_team)?;

crates/rust-project-goals-cli/src/rfc.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rust_project_goals::{
1818
},
1919
labels::GhLabel,
2020
},
21-
goal::{self, GoalDocument, GoalPlan, ParsedOwners, Status},
21+
goal::{self, GoalDocument, GoalPlan, ParsedOwners},
2222
team::{get_person_data, TeamName},
2323
};
2424

@@ -305,7 +305,7 @@ fn issue<'doc>(timeframe: &str, document: &'doc GoalDocument) -> anyhow::Result<
305305
}
306306

307307
let mut labels = vec!["C-tracking-issue".to_string()];
308-
if let Status::Flagship = document.metadata.status {
308+
if document.metadata.status.is_flagship {
309309
labels.push("Flagship Goal".to_string());
310310
}
311311
for team in document.teams_with_asks() {
@@ -338,11 +338,11 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
338338

339339
Ok(format!(
340340
r##"
341-
| Metadata | |
342-
| -------- | --- |
343-
| Owner(s) | {owners} |
344-
| Team(s) | {teams} |
345-
| Goal document | [{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html) |
341+
| Metadata | |
342+
| -------- | --- |
343+
| Point of contact | {poc} |
344+
| Team(s) | {teams} |
345+
| Goal document | [{timeframe}/{goal_file}](https://rust-lang.github.io/rust-project-goals/{timeframe}/{goal_file}.html) |
346346
347347
## Summary
348348
@@ -354,7 +354,7 @@ fn issue_text(timeframe: &str, document: &GoalDocument) -> anyhow::Result<String
354354
355355
[Team]: https://img.shields.io/badge/Team%20ask-red
356356
"##,
357-
owners = &document.metadata.owner_usernames().join(", "),
357+
poc = &document.metadata.owner_usernames().join(", "),
358358
teams = teams.join(", "),
359359
summary = document.summary,
360360
tasks = tasks.join("\n"),

0 commit comments

Comments
 (0)