-
Notifications
You must be signed in to change notification settings - Fork 127
Refactor Container
class and children
#2206
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
Conversation
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.
@jcollins-g There are a lot of additions under testing/test_package_custom_templates/templates
. That directory really only exists to check that running with the --templates-dir
option works; IMO those templates don't need to exercise all the features or access all the template-able members, and I didn't intially intend for them to do that since since other tests will. Is there a reason you feel those additions are necessary?
Will do another pass on the rest a bit later.
I didn't want to hand-edit all the templates so I just copied the whole directory across for the templates-dir test, modifying only the index so it's possible to tell the difference by examining the output (and therefore verifying that dartdoc is using the right template dir). There is probably a better way to do this, open to better ideas. |
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.
Renaming and reorganization looks good.
Full disclosure I did not thoroughly review HTML / markdown templates; just scanned.
lib/src/model/class.dart
Outdated
Iterable<Method> get declaredMethods => | ||
_declaredMethods ??= element.methods.map((e) { | ||
return ModelElement.from(e, library, packageGraph) as Method; | ||
}).toList(growable: false); |
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.
Hmm, does the toList
here add anything important?
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 don't think so. Removed.
bool get isExtension => element is ExtensionElement; | ||
|
||
List<Method> get methods => []; | ||
@mustCallSuper | ||
Iterable<ModelElement> get allModelElements => quiver.concat([ |
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.
Hmm, should we just use spread here? Does quiver.concat buy us something in a getter?
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.
quiver.concat allows for lazy evaluation. Perhaps that is unimportant compared to the clarity of the spread operator, though....
Checking the index afterward for a specific string seems reasonable. I did sort of like that the template directories were quite different as it ensures that we don't inadvertently rely on specific filenames or directory structure (aside from what's documented in the help string). Not sure how strongly I feel about it, though. |
@jdkoren I hear you on not wanting to throw out any coverage we might have been getting there. However, code coverage results suggests we didn't lose much by changing to a simpler construction, though. Yes, we probably should be testing edge cases in custom templating more effectively. Maybe at some point we can do that with more deliberate intention. |
* intermediate * tests pass, ship it * Fix a missing variable static fields change in mixin template * Fix some remaining templating bugs * Review comments * Update markdown templates per #2206
Rename and change semantics for many getters on the
Container
class.This makes Dartdoc's use of terminology for class members more closely aligned with Dart and Analyzer internals, and improves separation between the generation layer and Dartdoc internals.
Fields
internally outside of the templates themselves.Class
class out ofContainer
.Container
s out ofClass
and intoContainer
and eliminate some duplication.sorted
for getters where ordering matters. Don't store and sort lists of items over and over for non-documented ModelElements.staticFields
now includes constant static fields,variableStaticFields
has the old behavior.instanceMethods
andinstanceFields
for non-statics, rather thanmethods
excluding statics by default.hasPublicInheritedFields
andpublicConstantFields
rather than using so many abbreviations, so templates are clearer.Note: this completely breaks markdown generation until the templates are updated. Will add a smoke test for markdown and update those templates in a followup.