Closed Sfshaza closed 9 years ago
The first solution might be cleanest, as long as you can generate the name using the directory structure. E.g.:
It'd be nice to be able to have an arbitrarily deep directory structure.
@Sfshaza @kwalrath Can I find anywhere this tutorial repo, so that I can test that repo against my executable ?
here the directories seem all kind of flat ?
@Sfshaza is working on gist-ifying the tutorial samples. Maybe she can upload her work-in-progress.
Which reminds me, I have a bunch of samples under https://github.com/dart-lang/dart-up-and-running-book/tree/master/code, which I need to reorganize to work with DartPad. But ch02, in particular, has a mixed-depth hierarchy. (It's not ready for the generator yet, though, and might end up all one depth... depending.)
Okay, this functionality is now in the master, I hope it doesn't break anything... @Sfshaza @kwalrath
We're trying it out. Thanks!
For at least one of my example apps (haven't tested others yet), gist generate
works when you're above app's directory, but not when you're in the app's directory. Here's what I see:
$ gist generate
...
"assert" gist updated at https://gist.github.com/a0d6042d97b7e71347c2
"break_continue" gist updated at https://gist.github.com/7417291c1fd6c74b56be
"exceptions" gist updated at https://gist.github.com/bb5c060b6d9d050419c8
"for_loops" gist updated at https://gist.github.com/836a6f67f4ef7af349bc
flow (gist)$ cd assert
$ ls
pubspec.yaml web/
$ gist generate
...
(seems to silently fail)
$
I'll continue to play with this to characterize the failure.
I just tested this and it works, though I have another request.
My directory structure looks like this:
streams
last_positive
pubspec.yaml
web
main.dart
read_file
pubspec.yaml
web
main.dart
simple_stream
pubspec.yaml
web
main.dart
throw_error
pubspec.yaml
web
main.dart
When I run the gist generator, I want to see the gists named like this:
streams/last_positive streams/simple_stream streams/throw_error
(read_file isn't converted to a gist because it uses dart:io.)
But the gists are named like this:
last_positive simple_stream throw_error
Can you modify to create a name that includes both directory names?
I can't reproduce this. For me the description is like you suggest. Not sure what is going on, are you using the latest version ? Could I otherwise maybe clone your repo, so I can check myself ? @Sfshaza
Actually, it works if you're in the directory above streams—it just doesn't work if you're in the streams directory.
Which might be OK, because if you're in the top directory (which might have a random name like dart-tutorial-samples-FOR-REAL), you certainly don't want its name prepended to all its examples.
But... What if you want to generate gists for just a subset of the directories? Say, you want to regenerate streams but not fetchdata. I suppose a workaround would be to temporarily move fetchdata to .fetchdata or to a .HIDE directory.
Can you think of a better flow?
To be clear, this problem has workarounds and doesn't need a fix urgently.
Interestingly, the name gets replaced each time you regenerate. This effectively makes generating from any subdirectory difficult, since you don't get consistent names in github.
A workaround would be to create completely explanatory (probably long and hierarchical) app directory names, and use just the filename without the directory path.
Another workaround might be to specify a prefix on the command line.
The -n command should show the name/description of the gist... that might help us catch the problem before generating the final gist.
Can you think of anything else that would help?
Shams's changes to streams are in the master github.com/dart-lang/dart-tutorials-samples repo, if you want to try for yourself.
I cloned that directory, the output is now like this:
$ gist generate streams
? Create a github token here:
https://github.com/settings/tokens
Github Token: ********
"streams/last_positive" gist created at https://gist.github.com/3cc9c4cad6d7cb28e5c5
Gist url and dartpad url inserted in pubspec.yaml.
"streams/simple_stream" gist created at https://gist.github.com/dab53ed77ab0e2a47307
Gist url and dartpad url inserted in pubspec.yaml.
"streams/throw_error" gist created at https://gist.github.com/1245d936eaca16067a06
Gist url and dartpad url inserted in pubspec.yaml.
$ gist generate streams -n
streams/last_positive is dartpadable
streams/simple_stream is dartpadable
streams/throw_error is dartpadable
$ gist generate streams --test-gist
"streams/last_positive": dartpad for testing created at https://dartpad.dartlang.org/7bc83e032fb7739c9247
"streams/simple_stream": dartpad for testing created at https://dartpad.dartlang.org/542868ee96f0ae909934
"streams/throw_error": dartpad for testing created at https://dartpad.dartlang.org/515c47dbfdd6a09cfdd2
gist generate streams/ -n --verbose
streams/last_positive is dartpadable
Skipping streams/last_positive/web: App contains no web directory.
Skipping streams/read_file: App contains no web directory.
Skipping streams/read_file/bin: App contains no web directory.
streams/simple_stream is dartpadable
Skipping streams/simple_stream/web: App contains no web directory.
streams/throw_error is dartpadable
Skipping streams/throw_error/web: App contains no web directory.
That looks great. Thanks!!
Some of the examples directories in the tutorial repo contain multiple examples. Also, it would be nice if there were a way to associate an example with a tutorial. What might be a good way to solve both problems?
Maybe a hierarchical directory structure like this:
In this case, it would be preferable if the generator placed both names on the gist file, such as fetchdata/example1.
Another solution might be to use a flat directory structure:
Thoughts?