Skip to content

Add span tracking to allow emitting diagnostics everywhere #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2025
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
113 changes: 111 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/mdbook-goals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ regex = "1.11.1"
rust-project-goals = { version = "0.1.0", path = "../rust-project-goals" }
semver = "1.0.23"
serde_json = "1.0.133"
spanned = "0.4.0"
15 changes: 8 additions & 7 deletions crates/mdbook-goals/src/mdbook_preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rust_project_goals::{
goal::{self, GoalDocument, Status, TeamAsk},
re, team,
};
use spanned::Spanned;

const LINKS: &str = "links";
const LINKIFIERS: &str = "linkifiers";
Expand Down Expand Up @@ -293,18 +294,18 @@ impl<'c> GoalPreprocessorWithContext<'c> {
}
let config = Configuration::get();
let rows = std::iter::once(vec![
"Ask".to_string(),
"aka".to_string(),
"Description".to_string(),
Spanned::here("Ask".to_string()),
Spanned::here("aka".to_string()),
Spanned::here("Description".to_string()),
])
.chain(config.team_asks.iter().map(|(name, details)| {
vec![
format!("{name:?}"),
details.short.to_string(),
details.about.to_string(),
Spanned::here(format!("{name:?}")),
Spanned::here(details.short.to_string()),
Spanned::here(details.about.to_string()),
]
}))
.collect::<Vec<Vec<String>>>();
.collect::<Vec<Vec<Spanned<String>>>>();
let table = util::format_table(&rows);
let new_content = re::VALID_TEAM_ASKS.replace_all(&chapter.content, table);
chapter.content = new_content.to_string();
Expand Down
1 change: 1 addition & 0 deletions crates/rust-project-goals-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ clap = { version = "4.5.23", features = ["derive"] }
rust-project-goals-json = { version = "0.1.0", path = "../rust-project-goals-json" }
handlebars = { version = "6.2.0", features = ["dir_source"] }
comrak = "0.31.0"
spanned = "0.4.0"
2 changes: 1 addition & 1 deletion crates/rust-project-goals-cli/src/rfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ fn task_items(goal_plan: &GoalPlan) -> anyhow::Result<Vec<String>> {
let mut tasks = vec![];

if let Some(title) = &goal_plan.subgoal {
tasks.push(format!("### {title}"));
tasks.push(format!("### {}", **title));
}

for plan_item in &goal_plan.plan_items {
Expand Down
7 changes: 6 additions & 1 deletion crates/rust-project-goals-cli/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rust_project_goals::markwaydown;
use rust_project_goals::re::{HELP_WANTED, TLDR};
use rust_project_goals::util::comma;
use rust_project_goals_json::GithubIssueState;
use spanned::{Span, Spanned};
use std::io::Write;
use std::path::Path;
use std::process::{Command, Stdio};
Expand Down Expand Up @@ -229,7 +230,11 @@ fn help_wanted(
}

fn why_this_goal(issue_id: &IssueId, issue: &ExistingGithubIssue) -> anyhow::Result<String> {
let sections = markwaydown::parse_text(issue_id.url(), &issue.body)?;
let span = Span {
file: issue_id.url().into(),
bytes: 0..0,
};
let sections = markwaydown::parse_text(Spanned::new(&issue.body, span))?;
for section in sections {
if section.title == "Why this goal?" {
return Ok(section.text.trim().to_string());
Expand Down
1 change: 1 addition & 0 deletions crates/rust-project-goals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ rust_team_data = { git = "https://github.com/rust-lang/team" }
rust-project-goals-json = { version = "0.1.0", path = "../rust-project-goals-json" }
toml = "0.8.19"
indexmap = "2.7.1"
spanned = "0.4.0"
13 changes: 8 additions & 5 deletions crates/rust-project-goals/src/format_team_ask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::{
path::PathBuf,
};

use spanned::Spanned;

use crate::{
config::Configuration,
goal::TeamAsk,
Expand Down Expand Up @@ -117,19 +119,20 @@ pub fn format_team_asks(asks_of_any_team: &[&TeamAsk]) -> anyhow::Result<String>

// Create the table itself.
let table = {
let headings = std::iter::once("Goal".to_string())
let headings = std::iter::once(Spanned::here("Goal".to_string()))
.chain(ask_headings.iter().map(|&ask_kind| {
format!(
Spanned::here(format!(
"[{team_ask_short}][valid_team_asks]", // HACK: This should not be hardcoded in the code.
team_ask_short = config.team_asks[ask_kind].short,
)
))
})) // e.g. "discussion and moral support"
.collect::<Vec<String>>();
.collect::<Vec<Spanned<String>>>();

let rows = goal_rows.into_iter().map(|(goal_data, goal_columns)| {
std::iter::once(goal_data.goal_title())
.chain(goal_columns)
.collect::<Vec<String>>()
.map(Spanned::here)
.collect::<Vec<Spanned<String>>>()
});

std::iter::once(headings).chain(rows).collect::<Vec<_>>()
Expand Down
Loading