Skip to content

Deemphasize reexported symbols [#1158] #1319

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 2 commits into from
Jan 10, 2017

Conversation

astashov
Copy link
Contributor

@astashov astashov commented Jan 8, 2017

@Hixie noticed, that when a library exports another library, but both
libraries are being docced together, the result is that each class that
is exported by both libraries is listed twice.

We should still list classes and other symbols in the libraries that
reexport them (since they still part of public API of those libs), but
we only gonna show "canonical" symbols in Search, and also we won't
create duplicate HTML pages for reexported symbols.

We define the reexported symbols in the following way:

  1. A defines Foo.
  2. Foo doesn't appear in the docs for A because A is a private library,
    i.e., in lib/src/../a.dart
  3. B exports Foo from A.
  4. Foo appears in the docs for B.
  5. C exports Foo from B.
  6. Foo appears in the docs for C.

So, Foo of lib C shouldn't have its own page and also shouldn't appear
in Search, because Foo was exported from B and B already has docs. All
links to Foo from HTML docs of C should point to the Foo of B.

To solve that, we build directed "export graph", where we track what
libs export what libs. Then, to find the "canonical" lib, we go up the
graph until we find first documented lib - that's going to be the
canonical one.

Then, we filter out non-canonical libs when building the search index,
and also use canonical lib in .href getters, this way ensuring we
always link to symbols in canonical libs and don't create HTML files for
symbols from non-canonical libs.

Testing: Unit tests, also built test docs (testing/test_package_docs),
made sure we don't create files for non-canonical stuff (i.e. we create
fake/Cool files, but not ex/Cool). Also, built Flutter docs, ensured
we don't create material/BoxDecoration, rendering/BoxDecoration and
widgets/BoxDecoration, and only create painting/BoxDecoration files,
and all the links point to painting/BoxDecoration.

Fixes #1158

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Jan 8, 2017
@astashov astashov force-pushed the dedup-model-elements branch from 48e8ca5 to c9d11d6 Compare January 9, 2017 02:53
@Hixie noticed, that when a library exports another library, but both
libraries are being docced together, the result is that each class that
is exported by both libraries is listed twice.

We should still list classes and other symbols in the libraries that
reexport them (since they still part of public API of those libs), but
we only gonna show "canonical" symbols in Search, and also we won't
create duplicate HTML pages for reexported symbols.

We define the reexported symbols in the following way:

1. A defines Foo.
2. Foo doesn't appear in the docs for A because A is a private library,
   i.e., in lib/src/../a.dart
3. B exports Foo from A.
4. Foo appears in the docs for B.
5. C exports Foo from B.
6. Foo appears in the docs for C.

So, Foo of lib C shouldn't have its own page and also shouldn't appear
in Search, because Foo was exported from B and B already has docs. All
links to Foo from HTML docs of C should point to the Foo of B.

To solve that, we build directed "export graph", where we track what
libs export what libs. Then, to find the "canonical" lib, we go up the
graph until we find first documented lib - that's going to be the
canonical one.

Then, we filter out non-canonical libs when building the search index,
and also use canonical lib in `.href` getters, this way ensuring we
always link to symbols in canonical libs and don't create HTML files for
symbols from non-canonical libs.

Testing: Unit tests, also built test docs (`testing/test_package_docs`),
made sure we don't create files for non-canonical stuff (i.e. we create
`fake/Cool` files, but not `ex/Cool`). Also, built Flutter docs, ensured
we don't create `material/BoxDecoration`, `rendering/BoxDecoration` and
`widgets/BoxDecoration`, and only create `painting/BoxDecoration` files,
and all the links point to `painting/BoxDecoration`.
@astashov astashov force-pushed the dedup-model-elements branch from c9d11d6 to 00abeb1 Compare January 9, 2017 03:11
@devoncarew devoncarew requested a review from keertip January 9, 2017 04:16
@@ -0,0 +1,54 @@
import 'package:analyzer/dart/element/element.dart';

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add comments to methods to explain functionality.

@astashov
Copy link
Contributor Author

@keertip PTAL

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