-
Notifications
You must be signed in to change notification settings - Fork 700
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
Test all code excerpts #1803
Comments
…1900) There are **NO doc changes in this PR**, only infrastructure updates. Prep work to #1803. Details: - create_site_main_example.dart: apply dart --fix and other cleanup - create_site_main_example.dart: refactoring to support multiple src files - create_site_main_example.dart: support tool tip title - create_site_main_example.dart refactoring - create_site_main_example.dart: add support for tooltips on their own line - create_site_main_example.dart: skip docregion lines - pi_monte_carlo.dart: adjust tip instructions so that we can run dartfmt on file
Kathy, I've moved into the opening comment the work items that used to appear in separate comments. That will make it a bit easier to track. |
Resolves the second item of #1803. * Analysis options page: ensure code excerpts are analyzed/tested * Replace images of code with tooltip by code excerpts * Edits inspired by Kathy's comments * Add IDE-like analyzer-error highlighting to implicit-casts example * Drop linenums from implicit-casts example
@kwalrath So I noticed the src for the Dart cheatsheet codelab to be here https://github.com/dart-lang/site-www/edit/master/src/codelabs/dart-cheatsheet.md. So if were to add the code-excerpt for the code snippet: int a; // The initial value of a is null.
a ??= 3;
print(a); // <-- Prints 3.
a ??= 5;
print(a); // <-- Still prints 3. Is there the code file for this snippet already there to be linked or we need to create first? Also should it be just a gist or we should add as |
You've got the right source file for the cheatsheet codelab, although it'd probably be easiest to edit it locally rather than in GitHub. I believe that all of those samples are untested, and grepping the repo for Once that code is in your copy of the repo, then in a separate commit (for the same branch & PR) you could add Does that make sense? |
Yes, @kwalrath that makes sense. |
@kwalrath Adding all the code snippets as in the cheatsheet.md file, into a single dart file, say, |
I'm fine with splitting this up into two PRs, although what I'm about to say next might change your mind... To deal with multiple objects/classes having the same name, one possibility is to put them in different files, as you said. Another one is to change the names used in the samples, so they aren't all the same. (We generally don't do this, since the names were the same for a reason.) A technique we often use is to have one file with different names for the objects/classes — and then to modify them to be the same name by using I don't remember exactly where I've done the latter, but if you do the following command in your copy of the repo, you can see lots of examples of using
Many of those uses are for the purpose of highlighting (by surrounding it with For example, instead of having |
@kwalrath Thanks for letting me know about this technique :) Will implement when I work on the next files. |
I'd love to see that PR and how Travis likes it. Did you find any issues with the code while creating those files? It'd probably be good to have a separate issue for adding the cheatsheet code samples. (Then I can add that issue above by the cheatsheet item.) Either you or I can create that issue. |
Nope i didn't find any such issues while creating the files. |
@kwalrath nvm :) have opened the issue for us. |
This issue is quite out of date as a lot of progress has been made. I'm going to close this in favor of more specific issues as we determine excerpts are needed. |
This bug replaces #407, which is the equivalent for the pre-dart.dev version of this site. We'll need to be able to test all samples as null safety is released.
New pages that need tests for code excerpts:
Old pages that should have tests for code excerpts, including DartPad code (which in most cases is contained in a Gist):
else
statements foruseIframe
) for an example of how to do this.Lower priority code in new pages:
Other:
Tested to some extent:
Done:
Intentionally not testing:
Native Extensions article Update Native Extensions article #980 - is this article still relevant? Or should / will it be replaced by https://dart.dev/server/c-interop?(won't write tests because this has a very small audience)The text was updated successfully, but these errors were encountered: