Skip to content

Remove Templates.fromContext and as a result, make code more synchronous #4060

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

srawlins
Copy link
Member

Since "runtime template" support was removed, we could remove the forceRuntimeTemplates parameter from Templates.fromContext. However, the result of this is that calling Templates.fromContext would not need the DartdocGeneratorOptionContext parameter either, and is then just an alias for the HtmlAotTemplates constructor. So we can remove the function altogether.

Since we no longer need to await the result of calling this function (which is now a constructor call), we can make more and more functions synchronous (see
https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/): bin/dartdoc.dart's main, Dartdoc.fromContext (which can new be a factory constructor), initHtmlGenerator, buildDartdoc, generatorContextFromArgv, createPackageBuilder.

We can also remove some more code that becomes dead: RuntimeTemplates._create, ResourceProvider utilities, and some trivial buildDartdoc test helpers.

…ous.

Since "runtime template" support was removed, we could remove the
`forceRuntimeTemplates` parameter from `Templates.fromContext`. However, the
result of this is that calling `Templates.fromContext` would not need the
`DartdocGeneratorOptionContext` parameter either, and is then just an alias for
the `HtmlAotTemplates` constructor. So we can remove the function altogether.

Since we no longer need to `await` the result of calling this function (which
is now a constructor call), we can make more and more functions synchronous
(see
https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/):
`bin/dartdoc.dart`'s `main`, `Dartdoc.fromContext` (which can new be a factory
constructor), `initHtmlGenerator`, `buildDartdoc`, `generatorContextFromArgv`,
`createPackageBuilder`.

We can also remove some more code that becomes dead:
`RuntimeTemplates._create`, ResourceProvider utilities, and some trivial
`buildDartdoc` test helpers.
@srawlins srawlins force-pushed the rm-force-runtime-templates branch from caa8b08 to 6156d2e Compare May 28, 2025 04:31
Copy link
Contributor

@szakarias szakarias left a comment

Choose a reason for hiding this comment

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

Cool with all these cleanups! Thanks.

@srawlins srawlins merged commit 668f7a1 into dart-lang:main May 28, 2025
11 checks passed
@srawlins srawlins deleted the rm-force-runtime-templates branch May 28, 2025 16:11
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