Skip to content

Update configdoc to support more shapes of TOML - #2381

Open
nolag wants to merge 1 commit into
mainfrom
rtinianov_flexible_config_doc
Open

Update configdoc to support more shapes of TOML#2381
nolag wants to merge 1 commit into
mainfrom
rtinianov_flexible_config_doc

Conversation

@nolag

@nolag nolag commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings September 11, 2026 15:46
@nolag
nolag requested a review from a team as a code owner September 11, 2026 15:46
@github-actions

Copy link
Copy Markdown
Contributor

👋 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!

@github-actions

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 generated is dropped at the next blank line. A legitimate note such as This value is generated at runtime can therefore disappear from the generated documentation. Match the canonical preamble markers (for example, generated together with DO 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 # Example marker, this continue runs before the [[...]] branch below, so skipUntil is 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.

Comment on lines +49 to 51
if strings.HasPrefix(trimmed, "[[") {
// skip fields until next empty line
skipUntil = func(line string) bool { return strings.TrimSpace(line) == "" }
Comment on lines +147 to +149
if i := strings.Index(line, " "); i > -1 {
name = line[:i]
}
Comment on lines +218 to +220
if len(desc) == 0 && currentTable != &globalTable && len(currentTable.desc) > 0 {
desc = currentTable.desc
inherited = true
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.

2 participants