Skip to content
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

Move renderer access behind a renderer factory #2086

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

jdkoren
Copy link
Contributor

@jdkoren jdkoren commented Dec 4, 2019

Renderers are now accessed from a RendererFactory held by the package
graph. This allows for changing renderers based on the configuration
of DartDoc without models having to know anything about that.

Renderers are now accessed from a RendererFactory held by the package
graph. This allows for changing renderers based on the configuration
of DartDoc without models having to know anything about that.
@googlebot googlebot added the cla: yes Google CLA check succeeded. label Dec 4, 2019
@@ -85,8 +85,8 @@ class CallableElementTypeRendererHtml
StringBuffer buf = StringBuffer();
buf.write(elementType.nameWithGenerics);
buf.write('(');
buf.write(ParameterRendererHtml(showNames: false)
.renderLinkedParams(elementType.element.parameters)
buf.write(ParameterRendererHtml()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This instantiation is inside another renderer for HTML, and there isn't a way to get to the renderer factory from here. I think this is probably ok, but alternatively we could make CallableElementTypeRendererHtml take a ParameterRenderer as a constructor arg.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think HTML renderers calling/constructing each other is fine for now and could even be fine long term.

@@ -51,9 +43,6 @@ class ParameterRendererHtml extends ParameterRenderer {
}

abstract class ParameterRenderer {
bool get showMetadata;
bool get showNames;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking here was that it will be easier to instantiate a singleton of this renderer (and others) if it doesn't have any constructor args, should that become a performance concern. It is a tad cumbersome to pass these around in method args, but the public renderLinkedParams() uses named params, so the call sites stay pretty clean.

Happy to revert this and let the renderer factory deal with instantiating with args if that's preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine. If you're concerned about construction performance, the factory can always cache them and create pseudo-singletons.

@@ -85,8 +85,8 @@ class CallableElementTypeRendererHtml
StringBuffer buf = StringBuffer();
buf.write(elementType.nameWithGenerics);
buf.write('(');
buf.write(ParameterRendererHtml(showNames: false)
.renderLinkedParams(elementType.element.parameters)
buf.write(ParameterRendererHtml()
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think HTML renderers calling/constructing each other is fine for now and could even be fine long term.

@@ -51,9 +43,6 @@ class ParameterRendererHtml extends ParameterRenderer {
}

abstract class ParameterRenderer {
bool get showMetadata;
bool get showNames;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine. If you're concerned about construction performance, the factory can always cache them and create pseudo-singletons.

@jdkoren jdkoren merged commit debccd1 into dart-lang:master Dec 4, 2019
@jdkoren jdkoren deleted the renderer_factory branch January 7, 2020 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants