Skip to content

Conversation

@jcollins-g
Copy link
Contributor

Fixes #1588. First part of a long awaited refactor to rationalize how we calculate links, but moved up to fix a regression.

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Jan 10, 2018
Copy link
Member

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

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

DBQ: no tests?

@jcollins-g
Copy link
Contributor Author

test added.

@kevmoo
Copy link
Member

kevmoo commented Jan 10, 2018

test added.

gracias

String get href {
if (canonicalLibrary == null) return null;
return '${canonicalLibrary.dirName}/$fileName';
if (!identical(canonicalModelElement, this))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: braces for the if statement body

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for clarity, if this element is not the canonical one, we generate a link to the canonical one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. While you could infer that from the code previously with all the "canonicalEnclosingElement" stuff, the modification here is intended to make that more clear and to make the object being linked to actually responsible for its own link generation.

Most of the broken link bugs I've seen either were attributable to bugs in how this worked, or were made harder to fix because of it (like this one). Now elements no longer point blindly into the filesystem hoping that the model really has a canonical element that matches, but we actually look up the element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've got a second change on deck to eliminate the copypasta of hrefs everywhere; if possible I'd prefer to fix the braces there.

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

if (canonicalLibrary == null) return null;
return '${canonicalLibrary.dirName}/${_constructor.enclosingElement.name}/$name.html';
if (!identical(canonicalModelElement, this))
return canonicalModelElement?.href;
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well, and below

expect(aStaticConstField.constantValue, '"A Constant Dog"');
});

test('privately constructed constants are unlinked', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jcollins-g jcollins-g merged commit 52d46a4 into master Jan 11, 2018
@jcollins-g jcollins-g deleted the fix-const-private-classes branch January 11, 2018 21:16
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.

dartdoc generates broken links to private classes in constant declarations

4 participants