Roadmap-Parser: Versionspakete, Leitplanken, Tageseinträge, veröffentlichte Version (#1035)
Dazu Zustand je Eintrag (erledigt, gebaut), Zustand je Paket und die Verweise von Todo auf Stand. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
333
src/roadmap.rs
333
src/roadmap.rs
@ -14,28 +14,6 @@ pub enum Section {
|
|||||||
Auftrag,
|
Auftrag,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Section {
|
|
||||||
pub const ALL: [Section; 6] = [
|
|
||||||
Section::Stand,
|
|
||||||
Section::Todo,
|
|
||||||
Section::Erledigt,
|
|
||||||
Section::Entscheidung,
|
|
||||||
Section::Risiko,
|
|
||||||
Section::Auftrag,
|
|
||||||
];
|
|
||||||
|
|
||||||
pub fn label(self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
Section::Stand => "Stand",
|
|
||||||
Section::Todo => "Todo",
|
|
||||||
Section::Erledigt => "Erledigt",
|
|
||||||
Section::Entscheidung => "Entscheidungen",
|
|
||||||
Section::Risiko => "Risiken",
|
|
||||||
Section::Auftrag => "Aufträge",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
@ -50,31 +28,94 @@ pub struct Item {
|
|||||||
pub refs: Vec<u32>,
|
pub refs: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Versionspaket aus „Versionspakete“: `**0.2.0 – Titel.** Text. #1032, #1035`.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct Version {
|
||||||
|
pub name: String,
|
||||||
|
pub title: String,
|
||||||
|
pub text: String,
|
||||||
|
pub ids: Vec<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Zeile „**Erledigt am 2026-11-01:** Stichworte“ im Todo-Abschnitt (ohne ID).
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct DoneDay {
|
||||||
|
pub title: String,
|
||||||
|
pub text: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
pub enum VersionState {
|
||||||
|
/// Im Kopf als veröffentlichte Version genannt oder alle Einträge erledigt.
|
||||||
|
Released,
|
||||||
|
/// Mindestens ein Eintrag erledigt oder gebaut.
|
||||||
|
InProgress,
|
||||||
|
Planned,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct Roadmap {
|
pub struct Roadmap {
|
||||||
/// Kopfzeile „Stand: …“ ohne das Wort „Stand:“.
|
/// Kopfzeile „Stand: …“ ohne das Wort „Stand:“.
|
||||||
pub stand: String,
|
pub stand: String,
|
||||||
pub next_id: Option<u32>,
|
pub next_id: Option<u32>,
|
||||||
|
/// Im Kopf genannte veröffentlichte Version („Release v0.1.0“), ohne „v“.
|
||||||
|
pub released: Option<String>,
|
||||||
pub items: Vec<Item>,
|
pub items: Vec<Item>,
|
||||||
|
pub versions: Vec<Version>,
|
||||||
|
/// Punkte der Leitplanken (Markdown-Text je Aufzählung).
|
||||||
|
pub rules: Vec<String>,
|
||||||
|
pub done_days: Vec<DoneDay>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Abschnitte ohne ID-Einträge, die trotzdem angezeigt werden.
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum Aux {
|
||||||
|
None,
|
||||||
|
Versions,
|
||||||
|
Rules,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Roadmap {
|
impl Roadmap {
|
||||||
pub fn parse(text: &str) -> Roadmap {
|
pub fn parse(text: &str) -> Roadmap {
|
||||||
let mut out = Roadmap::default();
|
let mut out = Roadmap::default();
|
||||||
let mut section: Option<Section> = None;
|
let mut section: Option<Section> = None;
|
||||||
|
let mut aux = Aux::None;
|
||||||
let mut group = String::new();
|
let mut group = String::new();
|
||||||
for line in text.lines() {
|
for line in text.lines() {
|
||||||
if let Some(rest) = line.strip_prefix("Stand:") {
|
if let Some(rest) = line.strip_prefix("Stand:") {
|
||||||
out.stand = rest.trim().to_string();
|
out.stand = rest.trim().to_string();
|
||||||
out.next_id = parse_next_id(rest);
|
out.next_id = parse_next_id(rest);
|
||||||
|
out.released = parse_released(rest);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(h) = line.strip_prefix("## ") {
|
if let Some(h) = line.strip_prefix("## ") {
|
||||||
section = section_of(h);
|
aux = aux_of(h);
|
||||||
|
section = if aux == Aux::None {
|
||||||
|
section_of(h)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
group.clear();
|
group.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
match aux {
|
||||||
|
Aux::Versions => {
|
||||||
|
out.versions.extend(parse_version(line));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Aux::Rules => {
|
||||||
|
if let Some(r) = line.trim().strip_prefix("- ") {
|
||||||
|
out.rules.push(r.trim().to_string());
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Aux::None => {}
|
||||||
|
}
|
||||||
let Some(sec) = section else { continue };
|
let Some(sec) = section else { continue };
|
||||||
|
if let Some(d) = parse_done_day(line) {
|
||||||
|
out.done_days.push(d);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(g) = bold_line(line) {
|
if let Some(g) = bold_line(line) {
|
||||||
// „**Erledigt (einzeln)**“ eröffnet den Block erledigter Einträge im Todo-Abschnitt;
|
// „**Erledigt (einzeln)**“ eröffnet den Block erledigter Einträge im Todo-Abschnitt;
|
||||||
// „**Erledigt am …:**“ ist eine Fließtext-Zeile ohne ID.
|
// „**Erledigt am …:**“ ist eine Fließtext-Zeile ohne ID.
|
||||||
@ -93,10 +134,6 @@ impl Roadmap {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self, s: Section) -> usize {
|
|
||||||
self.items.iter().filter(|i| i.section == s).count()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Anzahl der Stand-Zeilen mit dem gegebenen Status.
|
/// Anzahl der Stand-Zeilen mit dem gegebenen Status.
|
||||||
pub fn count_status(&self, status: char) -> usize {
|
pub fn count_status(&self, status: char) -> usize {
|
||||||
self.items
|
self.items
|
||||||
@ -108,6 +145,44 @@ impl Roadmap {
|
|||||||
pub fn find(&self, id: u32) -> Option<&Item> {
|
pub fn find(&self, id: u32) -> Option<&Item> {
|
||||||
self.items.iter().find(|i| i.id == id)
|
self.items.iter().find(|i| i.id == id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Erledigt: Stand-Zeile mit ✓ oder Eintrag im Block „Erledigt (einzeln)“.
|
||||||
|
pub fn is_done(&self, id: u32) -> bool {
|
||||||
|
self.find(id)
|
||||||
|
.is_some_and(|i| i.section == Section::Erledigt || i.status == Some('✓'))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gebaut, aber noch nicht geprüft: Stand ◐ oder ein Todo, dessen Text „Gebaut“ meldet.
|
||||||
|
pub fn is_built(&self, id: u32) -> bool {
|
||||||
|
self.find(id)
|
||||||
|
.is_some_and(|i| i.status == Some('◐') || i.detail.contains("Gebaut"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Todo-Einträge, die auf `id` verweisen („→ #…“), also die Funktion voranbringen.
|
||||||
|
pub fn todos_for(&self, id: u32) -> Vec<&Item> {
|
||||||
|
self.items
|
||||||
|
.iter()
|
||||||
|
.filter(|i| i.section == Section::Todo && i.refs.contains(&id))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn version_state(&self, v: &Version) -> VersionState {
|
||||||
|
let released = self.released.as_deref() == Some(v.name.as_str());
|
||||||
|
if released || (!v.ids.is_empty() && v.ids.iter().all(|&i| self.is_done(i))) {
|
||||||
|
VersionState::Released
|
||||||
|
} else if v.ids.iter().any(|&i| self.is_done(i) || self.is_built(i)) {
|
||||||
|
VersionState::InProgress
|
||||||
|
} else {
|
||||||
|
VersionState::Planned
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Entscheidung bereits getroffen: der Text nennt „entschieden“.
|
||||||
|
pub fn is_decided(item: &Item) -> bool {
|
||||||
|
format!("{} {}", item.title, item.detail)
|
||||||
|
.to_lowercase()
|
||||||
|
.contains("entschieden")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_next_id(s: &str) -> Option<u32> {
|
fn parse_next_id(s: &str) -> Option<u32> {
|
||||||
@ -140,6 +215,74 @@ fn section_of(heading: &str) -> Option<Section> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn aux_of(heading: &str) -> Aux {
|
||||||
|
if heading.contains("Versionspakete") {
|
||||||
|
Aux::Versions
|
||||||
|
} else if heading.contains("Leitplanken") {
|
||||||
|
Aux::Rules
|
||||||
|
} else {
|
||||||
|
Aux::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// „… Release v0.1.0 veröffentlicht …“ im Kopf → `0.1.0`.
|
||||||
|
fn parse_released(head: &str) -> Option<String> {
|
||||||
|
let mut rest = head;
|
||||||
|
while let Some(p) = rest.find("Release ") {
|
||||||
|
let after = rest[p + "Release ".len()..].trim_start_matches(['`', 'v']);
|
||||||
|
let v: String = after
|
||||||
|
.chars()
|
||||||
|
.take_while(|c| c.is_ascii_digit() || *c == '.')
|
||||||
|
.collect();
|
||||||
|
let v = v.trim_end_matches('.');
|
||||||
|
if v.chars().next().is_some_and(|c| c.is_ascii_digit()) {
|
||||||
|
return Some(v.to_string());
|
||||||
|
}
|
||||||
|
rest = &rest[p + "Release ".len()..];
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `**0.2.0 – Titel.** Text. #1032, #1035` → Paket mit Name, Titel, Text und IDs.
|
||||||
|
fn parse_version(line: &str) -> Option<Version> {
|
||||||
|
let t = line.trim();
|
||||||
|
let inner_and_rest = t.strip_prefix("**")?;
|
||||||
|
let (inner, text) = inner_and_rest.split_once("**")?;
|
||||||
|
let inner = inner.trim().trim_end_matches('.');
|
||||||
|
let (name, title) = inner.split_once(" – ").unwrap_or((inner, ""));
|
||||||
|
let mut ids = Vec::new();
|
||||||
|
let mut rest = text;
|
||||||
|
while let Some(p) = rest.find('#') {
|
||||||
|
let d: String = rest[p + 1..]
|
||||||
|
.chars()
|
||||||
|
.take_while(char::is_ascii_digit)
|
||||||
|
.collect();
|
||||||
|
if d.len() == 4
|
||||||
|
&& let Ok(n) = d.parse::<u32>()
|
||||||
|
&& !ids.contains(&n)
|
||||||
|
{
|
||||||
|
ids.push(n);
|
||||||
|
}
|
||||||
|
rest = &rest[p + 1..];
|
||||||
|
}
|
||||||
|
Some(Version {
|
||||||
|
name: name.trim().to_string(),
|
||||||
|
title: title.trim().to_string(),
|
||||||
|
text: text.trim().to_string(),
|
||||||
|
ids,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `**Erledigt am 2026-11-01:** Stichworte` → Tageseintrag.
|
||||||
|
fn parse_done_day(line: &str) -> Option<DoneDay> {
|
||||||
|
let r = line.trim().strip_prefix("**Erledigt am ")?;
|
||||||
|
let (date, text) = r.split_once("**")?;
|
||||||
|
Some(DoneDay {
|
||||||
|
title: format!("Erledigt am {}", date.trim().trim_end_matches(':').trim()),
|
||||||
|
text: text.trim().to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Zeile der Form `**Text**` (nur fett, sonst nichts).
|
/// Zeile der Form `**Text**` (nur fett, sonst nichts).
|
||||||
fn bold_line(line: &str) -> Option<&str> {
|
fn bold_line(line: &str) -> Option<&str> {
|
||||||
let t = line.trim();
|
let t = line.trim();
|
||||||
@ -306,7 +449,13 @@ Text ohne ID, #1001 hier zählt nicht.
|
|||||||
fn done_block_and_prose_lines() {
|
fn done_block_and_prose_lines() {
|
||||||
let r = Roadmap::parse(SAMPLE);
|
let r = Roadmap::parse(SAMPLE);
|
||||||
assert_eq!(r.find(1005).unwrap().section, Section::Erledigt);
|
assert_eq!(r.find(1005).unwrap().section, Section::Erledigt);
|
||||||
assert_eq!(r.count(Section::Erledigt), 1);
|
assert_eq!(
|
||||||
|
r.items
|
||||||
|
.iter()
|
||||||
|
.filter(|i| i.section == Section::Erledigt)
|
||||||
|
.count(),
|
||||||
|
1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -329,6 +478,123 @@ Text ohne ID, #1001 hier zählt nicht.
|
|||||||
assert_eq!(r.items.len(), 8);
|
assert_eq!(r.items.len(), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RELEASES: &str = "\
|
||||||
|
Stand: 2026-11-02, `main` @ abc. Release v0.1.0 veröffentlicht (2026-11-01). Nächste freie ID: #1020
|
||||||
|
|
||||||
|
## 1. Leitplanken (Entwurf)
|
||||||
|
- Pushen nur auf Wort des Nutzers.
|
||||||
|
- „Fertig“ heißt **geprüft**.
|
||||||
|
|
||||||
|
## 2. Stand
|
||||||
|
| ID | Was | Status | Notiz |
|
||||||
|
|---|---|---|---|
|
||||||
|
| #1001 | Audio | ✓ geprüft | ok |
|
||||||
|
| #1002 | Anzeige | ◐ gebaut | nur Simulation |
|
||||||
|
| #1003 | Import | ✗ offen | |
|
||||||
|
|
||||||
|
## 3. Todo
|
||||||
|
|
||||||
|
**P1 – Release**
|
||||||
|
- [#1004] **Paket installieren.** Nutzer: pacman. → #1002
|
||||||
|
- [#1005] **Ansicht bauen.** Gebaut am 2026-11-02, noch nicht geprüft.
|
||||||
|
|
||||||
|
**Erledigt (einzeln)**
|
||||||
|
- [#1006] **Probe.** Lauf grün.
|
||||||
|
|
||||||
|
**Erledigt am 2026-11-01:** Beispielsong, Lizenz.
|
||||||
|
|
||||||
|
## 4. Offene Entscheidungen
|
||||||
|
- [#1007] Lizenz: MIT, entschieden am 2026-11-01.
|
||||||
|
- [#1008] Bleibt das Repo öffentlich? Offen.
|
||||||
|
|
||||||
|
## 6. Versionspakete
|
||||||
|
|
||||||
|
**0.1.0 – Erstes Release (veröffentlicht 2026-11-01).** Paket und CI. #1001, #1006
|
||||||
|
**0.2.0 – Abnahme.** Ansicht und Tests. #1004, #1005, #1005
|
||||||
|
**0.3.0 – Später.** Import. #1003
|
||||||
|
";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reads_released_version_from_head() {
|
||||||
|
assert_eq!(Roadmap::parse(RELEASES).released.as_deref(), Some("0.1.0"));
|
||||||
|
assert_eq!(
|
||||||
|
parse_released("Release `v1.2` fertig").as_deref(),
|
||||||
|
Some("1.2")
|
||||||
|
);
|
||||||
|
assert_eq!(parse_released("Release-Workflow ohne Version"), None);
|
||||||
|
assert_eq!(Roadmap::parse(SAMPLE).released, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reads_versions_with_ids_and_state() {
|
||||||
|
let r = Roadmap::parse(RELEASES);
|
||||||
|
assert_eq!(r.versions.len(), 3);
|
||||||
|
assert_eq!(r.versions[0].name, "0.1.0");
|
||||||
|
assert_eq!(
|
||||||
|
r.versions[0].title,
|
||||||
|
"Erstes Release (veröffentlicht 2026-11-01)"
|
||||||
|
);
|
||||||
|
assert_eq!(r.versions[0].ids, vec![1001, 1006]);
|
||||||
|
assert_eq!(
|
||||||
|
r.versions[1].ids,
|
||||||
|
vec![1004, 1005],
|
||||||
|
"doppelte IDs nur einmal"
|
||||||
|
);
|
||||||
|
assert_eq!(r.version_state(&r.versions[0]), VersionState::Released);
|
||||||
|
// 0.2.0: #1005 meldet „Gebaut“, also in Arbeit; erledigt ist noch nichts.
|
||||||
|
assert_eq!(r.version_state(&r.versions[1]), VersionState::InProgress);
|
||||||
|
// 0.3.0: #1003 ist offen und nicht gebaut.
|
||||||
|
assert_eq!(r.version_state(&r.versions[2]), VersionState::Planned);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_version_with_all_ids_done_counts_as_released() {
|
||||||
|
let mut r = Roadmap::parse(RELEASES);
|
||||||
|
r.released = None;
|
||||||
|
// #1001 ✓ und #1006 im Block Erledigt: alles erledigt.
|
||||||
|
assert_eq!(r.version_state(&r.versions[0]), VersionState::Released);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reads_rules_and_done_days_and_ignores_them_as_items() {
|
||||||
|
let r = Roadmap::parse(RELEASES);
|
||||||
|
assert_eq!(
|
||||||
|
r.rules,
|
||||||
|
vec![
|
||||||
|
"Pushen nur auf Wort des Nutzers.",
|
||||||
|
"„Fertig“ heißt **geprüft**."
|
||||||
|
]
|
||||||
|
);
|
||||||
|
assert_eq!(r.done_days.len(), 1);
|
||||||
|
assert_eq!(r.done_days[0].title, "Erledigt am 2026-11-01");
|
||||||
|
assert_eq!(r.done_days[0].text, "Beispielsong, Lizenz.");
|
||||||
|
assert_eq!(
|
||||||
|
r.items.len(),
|
||||||
|
8,
|
||||||
|
"Leitplanken, Versionspakete und Tageseinträge sind keine Einträge"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn done_built_and_references() {
|
||||||
|
let r = Roadmap::parse(RELEASES);
|
||||||
|
assert!(r.is_done(1001) && r.is_done(1006));
|
||||||
|
assert!(!r.is_done(1002) && r.is_built(1002));
|
||||||
|
assert!(r.is_built(1005) && !r.is_done(1005));
|
||||||
|
assert!(!r.is_built(1003));
|
||||||
|
let t = r.todos_for(1002);
|
||||||
|
assert_eq!(t.len(), 1);
|
||||||
|
assert_eq!(t[0].id, 1004);
|
||||||
|
assert!(r.todos_for(1001).is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn decisions_are_open_or_decided() {
|
||||||
|
let r = Roadmap::parse(RELEASES);
|
||||||
|
assert!(is_decided(r.find(1007).unwrap()));
|
||||||
|
assert!(!is_decided(r.find(1008).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
/// Die echte `ROADMAP.md` muss vollständig lesbar sein: so viele Einträge, wie `check-roadmap.py` Definitionen zählt.
|
/// Die echte `ROADMAP.md` muss vollständig lesbar sein: so viele Einträge, wie `check-roadmap.py` Definitionen zählt.
|
||||||
#[test]
|
#[test]
|
||||||
fn real_roadmap_matches_definition_count() {
|
fn real_roadmap_matches_definition_count() {
|
||||||
@ -355,5 +621,16 @@ Text ohne ID, #1001 hier zählt nicht.
|
|||||||
.filter(|i| i.section == Section::Stand)
|
.filter(|i| i.section == Section::Stand)
|
||||||
.all(|i| i.status.is_some())
|
.all(|i| i.status.is_some())
|
||||||
);
|
);
|
||||||
|
assert!(!r.versions.is_empty(), "Versionspakete fehlen");
|
||||||
|
assert!(
|
||||||
|
r.versions
|
||||||
|
.iter()
|
||||||
|
.all(|v| !v.ids.is_empty() && v.ids.iter().all(|&i| r.find(i).is_some()))
|
||||||
|
);
|
||||||
|
assert!(!r.rules.is_empty(), "Leitplanken fehlen");
|
||||||
|
assert!(
|
||||||
|
r.released.is_some(),
|
||||||
|
"veröffentlichte Version im Kopf nicht erkannt"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user