Update configdoc to support more shapes of TOML - #2381
Conversation
|
👋 nolag, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
📊 API Diff Results
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved review findings affect TOML parsing, validation, and array-of-tables default handling.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates configdoc to support more TOML shapes, including indentation, nested/map tables, arrays, and generated preambles.
Changes:
- Normalizes indented TOML lines and table names.
- Adds dynamic map-key and generated-preamble handling.
- Expands parser and defaults tests.
File summaries
| File | Summary |
|---|---|
pkg/config/configdoc/defaults.go |
Updates indented default extraction. Moderate (line 44): example array headers are skipped before array handling. Critical (line 49): blank-line skipping can consume subsequent tables. |
pkg/config/configdoc/defaults_test.go |
Adds coverage for nested, map, and array defaults. |
pkg/config/configdoc/configdoc.go |
Extends TOML documentation parsing. Moderate (line 49): generated-comment detection is too broad. Moderate (line 147): key parsing does not handle valid TOML separators. Moderate (line 218): table descriptions can incorrectly satisfy undocumented fields. |
pkg/config/configdoc/configdoc_test.go |
Adds parser and generation coverage. |
Review details
Files not reviewed (1)
- pkg/config/configdoc/defaults_test.go: Generated file
Suppressed comments (2)
pkg/config/configdoc/configdoc.go:49
- This check is broader than a generated-file banner: any standalone comment block whose first line merely contains
generatedis dropped at the next blank line. A legitimate note such asThis value is generated at runtimecan therefore disappear from the generated documentation. Match the canonical preamble markers (for example,generatedtogether withDO NOT EDIT) instead of the substring alone.
return len(desc) > 0 && strings.Contains(strings.ToLower(desc[0]), "generated")
pkg/config/configdoc/defaults.go:48
- When an array-of-tables header carries the
# Examplemarker, thiscontinueruns before the[[...]]branch below, soskipUntilis never set. Any default-marked field inside that array is then emitted to the decoder at the wrong level instead of being ignored, which can cause strict decoding to fail. Detect[[before skipping example lines so the whole array is discarded.
if strings.HasPrefix(trimmed, "#") || strings.HasSuffix(trimmed, FieldExample) {
continue
}
// Skip arrays of tables
- Files reviewed: 3/4 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if strings.HasPrefix(trimmed, "[[") { | ||
| // skip fields until next empty line | ||
| skipUntil = func(line string) bool { return strings.TrimSpace(line) == "" } |
| if i := strings.Index(line, " "); i > -1 { | ||
| name = line[:i] | ||
| } |
| if len(desc) == 0 && currentTable != &globalTable && len(currentTable.desc) > 0 { | ||
| desc = currentTable.desc | ||
| inherited = true |
No description provided.