Make Section Retro-planning (Scheduling) strict and update documentation #14

Closed
opened 2026-07-18 00:23:06 +02:00 by abiwab · 1 comment
abiwab commented 2026-07-18 00:23:06 +02:00 (Migrated from codeberg.org)

Description
Currently, the retro-planning syntax applied to section titles (e.g., ## Section ~{-2h}) is defined as free text in the PEG grammar (retroPlanning = "~{" (~"}" any)+ "}"). This means users can technically write ~{the day before} or any other non-standard time format.

To allow better programmatic usage of retro-planning data in the future (such as generating Gantt charts or calendar integrations), I think it would be better to enforce strict time units just like standard inline timers (min, h, d).

Tasks

  • Refactor grammar.ohm to use strict parsing for retroPlanning instead of free text (e.g. enforcing - sign and absoluteQuantity).
  • Update packages/parser/src/index.ts to return structured time data instead of a raw string.
  • Update packages/kitchen and the renderers (like HTML formatter) to display the parsed strict time value correctly.
  • Add specific tests for valid/invalid retro-planning strings.
  • Update document-structure.md to mention this syntax with a cross-reference to times.md.
  • Expand times.md to detail how retro-planning works, specifying that free text is not allowed and that it relies on standard ~timer units.

Expected Behavior
## Dough ~{-2h} should be correctly parsed and exposed.
## Dough ~{the day before} should result in a parser error.

**Description** Currently, the retro-planning syntax applied to section titles (e.g., `## Section ~{-2h}`) is defined as free text in the PEG grammar (`retroPlanning = "~{" (~"}" any)+ "}"`). This means users can technically write `~{the day before}` or any other non-standard time format. To allow better programmatic usage of retro-planning data in the future (such as generating Gantt charts or calendar integrations), I think it would be better to enforce strict time units just like standard inline timers (`min`, `h`, `d`). **Tasks** - [x] Refactor `grammar.ohm` to use strict parsing for `retroPlanning` instead of free text (e.g. enforcing `-` sign and `absoluteQuantity`). - [x] Update `packages/parser/src/index.ts` to return structured time data instead of a raw string. - [x] Update `packages/kitchen` and the renderers (like HTML formatter) to display the parsed strict time value correctly. - [x] Add specific tests for valid/invalid retro-planning strings. - [x] Update `document-structure.md` to mention this syntax with a cross-reference to `times.md`. - [x] Expand `times.md` to detail how retro-planning works, specifying that free text is not allowed and that it relies on standard `~timer` units. **Expected Behavior** `## Dough ~{-2h}` should be correctly parsed and exposed. `## Dough ~{the day before}` should result in a parser error.
abiwab commented 2026-07-18 12:18:14 +02:00 (Migrated from codeberg.org)

Quick update — this ended up working a bit differently than planned. Making the grammar itself strictly reject bad input turned out to cause more problems than it solved (in some cases it could silently break unrelated parts of a recipe), so the validation happens a bit later in the process instead, the same way timer units are already checked today.

While at it, made the rule a bit stricter too: retro-planning now has to be a real "before" duration, not zero or a positive number. Also fixed day units (d) not converting properly, and an unrelated crash I ran into on the way.

Docs and tests updated accordingly.

Quick update — this ended up working a bit differently than planned. Making the grammar itself strictly reject bad input turned out to cause more problems than it solved (in some cases it could silently break unrelated parts of a recipe), so the validation happens a bit later in the process instead, the same way timer units are already checked today. While at it, made the rule a bit stricter too: retro-planning now has to be a real "before" duration, not zero or a positive number. Also fixed day units (d) not converting properly, and an unrelated crash I ran into on the way. Docs and tests updated accordingly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#14
No description provided.