Skip to content

Conversation

@zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Jan 23, 2026

Add script to generate a doc/config-schema.md that describes config schema based off internal/config/config.go and other referenced configs. Ordered to list Structs from config.go at the top, and others alphabetically.

This tool must be package main to provide the entry point for the Go compile, as it's purpose is to be "run" (either manually or via go generate).

Manual verification:
The documentation can be regenerated using the standard Go generate tool:
go generate ./internal/config/...

Alternatively, for manual runs from the root:
go run -tags configdocgen cmd/config_doc_generate.go

Fix #3681

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a script to automatically generate documentation for the librarian.yaml configuration schema, which is a great addition for maintainability. The script parses the Go structs in internal/config and produces a markdown file.

My review focuses on improving the robustness and performance of the new generator script, in line with the TODO to clean up the logic. I've suggested two main changes:

  • Making the logic for identifying internal structs more reliable by using the parsed struct map instead of a name-based heuristic.
  • Improving performance by pre-compiling a regular expression.

These changes will make the generator more accurate and efficient. The generated documentation itself looks good and will be a valuable resource.

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.78%. Comparing base (241bbc3) to head (419f09d).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3721      +/-   ##
==========================================
+ Coverage   82.43%   82.78%   +0.35%     
==========================================
  Files         138      138              
  Lines       12758    13038     +280     
==========================================
+ Hits        10517    10794     +277     
- Misses       1747     1751       +4     
+ Partials      494      493       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhumin8
Copy link
Contributor Author

zhumin8 commented Jan 26, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable script to automatically generate configuration schema documentation from Go source files, which will help keep documentation synchronized with the code. The implementation is solid and includes a good set of unit tests. My review includes a high-severity fix for a bug in markdown link generation for embedded structs, along with a medium-severity suggestion to improve error handling.

@zhumin8 zhumin8 marked this pull request as ready for review January 26, 2026 21:48
@zhumin8 zhumin8 requested a review from a team as a code owner January 26, 2026 21:48
@miguelvelezsa
Copy link

Also would be great if you can create several files to split the logic you are adding 😃

@zhumin8
Copy link
Contributor Author

zhumin8 commented Jan 27, 2026

Thanks @miguelvelezsa for your reviews!

Also would be great if you can create several files to split the logic you are adding 😃

I'd prefer to keep this code in one file, at least for now: 1)this is an internal tool for generating one specific doc file, it is more self-contained, and less likely for its code to be reused in other parts of the project. 2) it is relatively a small tool not too hard to read (I hope) at the moment.

@zhumin8 zhumin8 merged commit 01d5ae9 into main Jan 29, 2026
15 checks passed
@zhumin8 zhumin8 deleted the gen-config-doc branch January 29, 2026 15:23
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.

config: generate document from package comments for librarian.yaml

3 participants