Skip to content

Commit eadcd96

Browse files
author
Niko Matsakis
committed
use templates and revise output dramatically
1 parent d6bbe74 commit eadcd96

File tree

10 files changed

+202
-67
lines changed

10 files changed

+202
-67
lines changed

mdbook-goals/src/gh/issues.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ pub fn sync_assignees(
231231
}
232232
}
233233

234+
pub const FLAGSHIP_LABEL: &str = "Flagship Goal";
235+
234236
const LOCK_TEXT: &str = "This issue is intended for status updates only.\n\nFor general questions or comments, please contact the owner(s) directly.";
235237

236238
impl ExistingGithubIssue {
@@ -247,7 +249,7 @@ impl ExistingGithubIssue {
247249

248250
/// True if the issue has the label for a flagship goal.
249251
pub fn has_flagship_label(&self) -> bool {
250-
self.has_label("flagship")
252+
self.has_label(FLAGSHIP_LABEL)
251253
}
252254
}
253255

mdbook-goals/src/json.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use std::{path::PathBuf, str::FromStr};
1010

11-
use serde::Serialize;
11+
use serde::{Deserialize, Serialize};
1212

1313
use crate::{
1414
gh::{
@@ -92,15 +92,15 @@ struct TrackingIssue {
9292
state: ExistingIssueState,
9393
}
9494

95-
#[derive(Serialize, Debug)]
95+
#[derive(Serialize, Deserialize, Debug)]
9696
pub enum Progress {
97-
/// We could not find any checkboxes or other deatils on the tracking issue.
97+
/// We could not find any checkboxes or other details on the tracking issue.
9898
/// So all we have is "open" or "closed".
9999
Binary {
100100
is_closed: bool,
101101
},
102102

103-
/// We found checkboxes or issue listing.
103+
/// We found checkboxes or issue listing.
104104
Tracked {
105105
completed: u32,
106106
total: u32,

mdbook-goals/src/main.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ enum Command {
9191
/// Milestone for which we generate tracking issue data (e.g., `2024h2`).
9292
milestone: String,
9393

94-
/// File in which to generate the update summary.
95-
/// The default is to generate a file named after the
96-
/// milestone, e.g., `2024h2.md`).
94+
/// Quick mode does not use an LLM to generate a summary.
95+
#[structopt(long)]
96+
quick: bool,
97+
98+
/// Quick mode does not use an LLM to generate a summary.
99+
#[structopt(long)]
100+
vscode: bool,
101+
102+
/// If specified, write the output into the given file.
97103
#[structopt(long)]
98104
output_file: Option<PathBuf>,
99105

@@ -159,13 +165,17 @@ async fn main() -> anyhow::Result<()> {
159165
output_file,
160166
start_date,
161167
end_date,
168+
quick,
169+
vscode,
162170
} => {
163171
updates::updates(
164172
&opt.repository,
165173
milestone,
166174
output_file.as_deref(),
167175
start_date,
168176
end_date,
177+
*quick,
178+
*vscode,
169179
)
170180
.await?;
171181
}

mdbook-goals/src/rfc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use regex::Regex;
1212
use crate::{
1313
gh::{
1414
issue_id::{IssueId, Repository},
15-
issues::{create_issue, list_issue_titles_in_milestone, lock_issue, sync_assignees},
15+
issues::{create_issue, list_issue_titles_in_milestone, lock_issue, sync_assignees, FLAGSHIP_LABEL},
1616
labels::GhLabel,
1717
},
1818
goal::{self, GoalDocument, ParsedOwners, PlanItem, Status},
@@ -218,7 +218,7 @@ fn initialize_labels(
218218
});
219219

220220
desired_labels.insert(GhLabel {
221-
name: "Flagship Goal".to_string(),
221+
name: FLAGSHIP_LABEL.to_string(),
222222
color: "5319E7".to_string(),
223223
});
224224

mdbook-goals/src/templates.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,27 @@ impl<'h> Templates<'h> {
2525
assert!(reg.get_template("updates").is_some());
2626

2727
reg.register_helper("markdown_to_html", Box::new(markdown_to_html));
28+
reg.register_helper("is_complete", Box::new(is_complete));
2829

2930
Ok(Templates { reg })
3031
}
3132
}
3233

3334
handlebars::handlebars_helper!(markdown_to_html: |md: String| comrak::markdown_to_html(&md, &Default::default()));
3435

36+
handlebars::handlebars_helper!(is_complete: |p: Progress| match p {
37+
Progress::Binary { is_closed } => is_closed,
38+
Progress::Tracked { completed, total } => completed == total,
39+
Progress::Error { .. } => false,
40+
});
41+
3542
/// The parameters expected by the `updates.md` template.
3643
#[derive(Serialize, Debug)]
3744
pub struct Updates {
3845
pub milestone: String,
3946
pub flagship_goals: Vec<UpdatesFlagshipGoal>,
40-
pub other_goals: Vec<UpdatesOtherGoal>,
47+
pub other_goals_with_updates: Vec<UpdatesOtherGoal>,
48+
pub other_goals_without_updates: Vec<UpdatesOtherGoal>,
4149
}
4250

4351
impl Updates {
@@ -47,6 +55,7 @@ impl Updates {
4755
}
4856
}
4957

58+
/// Part of the parameters expected by the `updates.md` template.
5059
#[derive(Serialize, Debug)]
5160
pub struct UpdatesFlagshipGoal {
5261
/// Title of the tracking issue
@@ -61,13 +70,17 @@ pub struct UpdatesFlagshipGoal {
6170
/// URL of the tracking issue
6271
pub issue_url: String,
6372

73+
/// True if the issue is closed.
74+
pub is_closed: bool,
75+
6476
/// Progress towards the goal
6577
pub progress: Progress,
6678

6779
/// Updates provided towards the goal
6880
pub updates: Vec<UpdatesFlagshipGoalUpdate>,
6981
}
7082

83+
/// Part of the parameters expected by the `updates.md` template.
7184
#[derive(Serialize, Debug)]
7285
pub struct UpdatesFlagshipGoalUpdate {
7386
/// Username of the person who wrote the update
@@ -83,6 +96,7 @@ pub struct UpdatesFlagshipGoalUpdate {
8396
pub url: String,
8497
}
8598

99+
/// Part of the parameters expected by the `updates.md` template.
86100
#[derive(Serialize, Debug)]
87101
pub struct UpdatesOtherGoal {
88102
/// Title of the tracking issue
@@ -97,6 +111,9 @@ pub struct UpdatesOtherGoal {
97111
/// URL of the tracking issue
98112
pub issue_url: String,
99113

114+
/// True if the issue is closed.
115+
pub is_closed: bool,
116+
100117
/// Markdown with update text (bullet list)
101118
pub updates_markdown: String,
102119

0 commit comments

Comments
 (0)