-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added summary on warnings and errors (#2581) #2583
Conversation
…f there are any, fix: VERSION property is readonly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I have a couple concerns
src/lib/application.ts
Outdated
const { errorCount, warningCount } = this.logger; | ||
return `Found: ${errorCount} error${ | ||
errorCount === 1 ? "" : "s" | ||
}, ${warningCount} warning${warningCount === 1 ? "" : "s"}.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internationalizing this is going to be a massive pain... in TypeDoc 0.26 this needs to be a templated string with a placeholder. I think I'd rather just keep this simple here to make that migration easier:
return `Found ${errorCount} error(s), ${warningCount} warning(s).`
src/lib/application.ts
Outdated
@@ -525,6 +525,14 @@ export class Application extends ChildableComponent< | |||
const start = Date.now(); | |||
out = Path.resolve(out); | |||
await this.renderer.render(project, out); | |||
|
|||
// Generate a message summarizing the number of errors and warnings if there are any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong place to put this. TypeDoc has a --watch
option, which will result in generateDocs
and generateJson
being called many times. If a user has both options turned on, then with this implementation they may get two warnings/errors for each compilation.
I think the way I'd prefer to handle this is to add a public logRunSummary
(better name?) method on Application
which is called in cli.ts
in the appropriate places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also has the benefit of making the tests for this feature much less hacky - I've very intentionally avoided mocking pieces of TypeDoc in tests (almost) everywhere so far, they tend to lead to testing implementation details+easily broken tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong place to put this. TypeDoc has a
--watch
option, which will result ingenerateDocs
andgenerateJson
being called many times. If a user has both options turned on, then with this implementation they may get two warnings/errors for each compilation.I think the way I'd prefer to handle this is to add a public
logRunSummary
(better name?) method onApplication
which is called incli.ts
in the appropriate places
That seems reasonable. I'll take a look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the code again, and now I have some doubts. I think the best place for logging a summary is just before the line "Documentation generated at...". If I were to run TypeDoc in watch mode, I don't think I would mind seeing it every time I changed a file. On the contrary, it would be quite handy in some cases, for example, when I am working on reducing the number of warnings.
That said, do you still want me to move the summary? 😊
I moved |
Thanks! |
* feat: added a message summarizing the number of errors and warnings if there are any, fix: VERSION property is readonly * tests: added test for errors and warnings summary message * tests: added test for errors and warnings summary message (generateJson) * chore: added a comment * fix: typescript errors * fix: fixed warnings by prettier * refactor: moved logRunSummary to cli * fix: lint issues
😁
…On Tue, Jun 11, 2024, 6:54 PM Gerrit Birkeland ***@***.***> wrote:
Thanks!
—
Reply to this email directly, view it on GitHub
<#2583 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWMIKFJT5WUB7XC6KAC7UJ3ZG6E2LAVCNFSM6AAAAABIUI5Y62VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRG44TONBVGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Added a summary message about warnings and errors if any (see #2581) in the following functions:
Added tests.