Skip to content

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
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.


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.

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.


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.

3 participants