Feature: File Statistics Toggle & File Size fix#332
Conversation
Introduces a \showFileStats\ boolean (default: true) on Document. Can be set per-document or globally via \settings.showFileStats\; per-document always wins. Implemented across the domain model, YAML parser, JSON schema, and Markdown front-matter transformer. Includes full test coverage and docs.
Rewrites addFileStatistics() to compute byte count and line count directly from the in-memory content string via strlen/substr_count, removing all disk I/O. Stats are now accurate on the very first run. Also drops the redundant post-write files->size() call from the success log.
|
Hi @butschster, I checked the CI error and it is unrelated to my changes. I had my agent look at the issue, here's a summary explaining what's going on - hoping it helps. Issue Report for
|
Hi, I've looking for a way to turn off the file statistics section in the generated documents, and thought to contribute this when I saw that there was none.
This PR adds a
showFileStatsboolean flag (default: true) that controls whether the auto-generated File Statistics section is appended to compiled documents. Can be set per-document or globally viasettings.showFileStats. The per-document value always takes precedence.Additionally, a discrepancy was fixed where file statistics were silently omitted on the first
ctx generate'run becauseaddFileStatistics()attempted to read stats from the output file before witing it to disk. This also had the effect to always count the previous file size, not the size of the new file being written. Stats are now computed directly from the in-memory content, making them accurate on every run.