-
Notifications
You must be signed in to change notification settings - Fork 124
In Flutter docs, classes are listed multiple times #1158
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
Comments
also adding @keertip |
As an example, the BoxDecoration class has four different URLs: https://docs.flutter.io/flutter/painting/BoxDecoration-class.html It's not obvious that these are the same class. If there was a canonical URL that all the re-exports linked to, that would make that much clearer. |
I will look at it. |
Hmm, how do we know what's the "canonical" library? I.e.
Yeah, we can do that, the question is - how do we know which one is canonical? Just the first one encountered during parsing? |
That isn't what's happening here. What's happening here is:
The issue is at step (6) above. Specifically, Foo shouldn't appear in the docs for C (or at least should be de-emphasized in some way) because Foo was exported from B and B already has docs. |
Aha, I see, thanks. |
From the example above, since C does export Foo, Foo will appear in the docs for C, and that's the way it should be, as Foo is now part of the public api for C. The issue here is that Foo is defined in B, so maybe we can we have some indication that Foo is from B, or as abarth@ mentioned, de-emphasize it in the UI. |
For Flutter, what we want is that Foo is hidden (or at least dramatically de-emphasised, including not appearing in the search and not having its own page) from the public API of C in the docs. It's fine if the docs for it in the context of B say that they're also exported from C. |
@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`.
@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`.
@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`.
* Deemphasize reexported symbols [#1158] @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`. * Add some docs
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 only list classes as coming from the package that they actually come from, and not mention them in packages that re-export them, if we are including that package in the docs.
See also:
cc @devoncarew
The text was updated successfully, but these errors were encountered: