-
Notifications
You must be signed in to change notification settings - Fork 551
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
Provide a way to hide boilerplate code #562
Comments
Thanks for filing this, @Sfshaza! I couldn't have said it better. |
Thanks for the detailed write-up; I have a few questions to help me figure out your requirements a bit more: Would you expect the summarized versions to be editable? |
Not necessarily. I can imagine having a button that takes you to a DartPad window with the full app.
Maybe these aren't even runnable until you go to the DartPad window with the full app.
Yes, although not necessarily inside the page. (See above.)
Yes, somehow.
I think so.
We already tried something like this once with the contents of the language tour and library tour, so you can see something that worked (assuming I saved the branch correctly): https://github.com/dart-lang/dart-up-and-running-book/tree/old has all the source files (XML and Dart) for the 10/2012 version of the book. It also has instructions for using a merge tool called doc-code-merge. The doc-code-merge repo has gone away, but you can read a post about it at http://news.dartlang.org/2012/12/darts-approach-to-illiterate.html. Unfortunately we never adopted doc-code-merge, mainly because O'Reilly reworked all our files and we lost the inclusion information; we opted to use their edited source rather than applying all their edits to our original source. O'Reilly's production process is not an issue any more. Another reason we opted to use O'Reilly's was that we found it painful to write about code we couldn't see; we probably don't have much choice about that, though. As an example of the markup we used, in https://github.com/dart-lang/dart-up-and-running-book/blob/old/xml/ch02.xml you can see We had only a few cases where the same file would be used multiple times, so a way to optionally label sections would be good but not crucial; we could probably just duplicate the files. However, there were multiple cases (I believe) where a single snippet in the book would have multiple, discontiguous sections of a single Dart file. |
I met with George and Devon to discuss this while K was on vacation. George had an interesting idea. He suggested that maybe they could add an "invisible" (to the user) CSS/HTML file that specifies what to expose and what to hide. If the user enters edit mode, all of the code would be visible. So, for "embed inline", at least, there would be "obscure boilerplate" mode or "edit mode". A great idea! |
As DartPad and the Dart documentation sites have evolved a lot since this issue, I'm going to close this issue. I think the best route forward for these scenarios will be #2702 which could potentially include support for this. Thanks all! |
Kathy will be updating the language tour with lots and lots of embedded DartPad instances of the embed-inline variety. Currently, she has a repo that contains all of the complete code examples (so that we can build and verify them) but she is only displaying a snippet in the page itself.
Here is an example. Here is the code for factory_constructor.dart:
In the page on dartlang.org, you see only a snippet of the code:
The following example demonstrates a factory constructor returning objects from a cache:
It would be nice if there was a way to identify (and hide) the boilerplate code in the embed-inline version. The example would still run, but only the relevant code is exposed.
language tour: https://www.dartlang.org/docs/dart-up-and-running/ch02.html
book code repo: https://github.com/dart-lang/dart-up-and-running-book/tree/master/code/ch02
The text was updated successfully, but these errors were encountered: