Skip to content

feat(rfc_tools): add RFC frontmatter and file markdown models - #8

Open
jtmcdole wants to merge 3 commits into
pr-2-taxonomy-clientfrom
pr-3-frontmatter-models
Open

feat(rfc_tools): add RFC frontmatter and file markdown models#8
jtmcdole wants to merge 3 commits into
pr-2-taxonomy-clientfrom
pr-3-frontmatter-models

Conversation

@jtmcdole

@jtmcdole jtmcdole commented Sep 4, 2026

Copy link
Copy Markdown
Member

PR 3 of 7 for testing and automation

RfcFile and RfcFrontmatter are the core models of parsing and validating.

  • rfc_file: extracting AAA.NNNN from files, markdown level 1 heading parser, and useful extensions to int.
  • rfc_frontmatter: yaml schema validation and error feedback

Stack created with GitHub Stacks CLIGive Feedback 💬

@jtmcdole
jtmcdole force-pushed the pr-3-frontmatter-models branch 2 times, most recently from 9781ddb to c5ac319 Compare September 4, 2026 17:13
@jtmcdole
jtmcdole marked this pull request as ready for review September 4, 2026 17:16
@jtmcdole
jtmcdole requested review from Piinks and zanderso September 4, 2026 17:26
@jtmcdole
jtmcdole force-pushed the pr-3-frontmatter-models branch from c5ac319 to f84b206 Compare September 4, 2026 19:33

@zanderso zanderso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure since the frontmatter isn't too long, but would it be helpful to include file line numbers in the error messages?

Comment thread lib/src/models/rfc_file.dart Outdated
Comment thread lib/src/models/rfc_file.dart Outdated
Comment thread lib/src/models/rfc_file.dart Outdated
Comment thread lib/src/models/rfc_file.dart Outdated
Comment thread lib/src/models/rfc_frontmatter.dart Outdated
@jtmcdole
jtmcdole force-pushed the pr-3-frontmatter-models branch from f84b206 to 1e8f7aa Compare September 4, 2026 22:35
@jtmcdole
jtmcdole requested a review from zanderso September 8, 2026 15:04
}
} catch (e) {
final err = switch (e) {
YamlException(:final span?, :final message) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional nit] This is a somewhat gratuitous use of pattern matching since you can already write on T catch(e) {} clauses to catch exceptions with specific types.

final bodyLines = <String>[];
bool headingReplaced = false;

for (final line in LineSplitter.split(body)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just RegExp.matchFirst and then String.replaceFirst?

);
case final rfcVal:
final rfcStr = '$rfcVal'.trim();
if (!RegExp(r'^\d{3}\.\d{4}$').hasMatch(rfcStr)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and similar RegExps are repeated a few times.

bool headingReplaced = false;

for (final line in LineSplitter.split(body)) {
if (!headingReplaced) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this silently fail on a malformed heading?

'Expected format: a list of non-empty category/topic strings (e.g. 000-meta).',
i,
);
break;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authors uses continue and reports every invalid entry, tags here is using break and stops at the first invalid item. Should this also be continue?

}) {
final errors = <String>[];

void addError(String key, String message, [int? itemIndex]) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line numbers are baked directly into the message strings ('Line 6: Frontmatter "status"...'). In later PRs like #9, callers receive a list of frontmatterErrors. Because structured line numbers are not preserved separately, RfcLinter will discard the exact line number calculated here.

})
_splitFrontmatter(String content) {
final lines = [...LineSplitter.split(content)];
if (lines.isEmpty || lines.first.trim() != '---') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to account for Windows evaluating to '\uFEFF---'?

Comment on lines +355 to +356
required Object newCategory,
required Object newIndex,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be more strictly typed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants