Add support for playgrounds with multiple pages#34
Conversation
|
Fascinating! I didn't realize that, that make writing playgrounds books inside playgrounds much much easier, thank you for the pull request! The example repo really helped me understand what was going on. I'll take a look at adding tests later 👍 |
|
Yeah, with support for this, writing Playgrounds for iPad will be much more manageable. Thank you for getting a large bulk of the work done! I've written a bunch of interactive/visual Playgrounds for Xcode and I'm in the process of deciding what to port over. In addition to the root It looks like this is also true of |
|
Alright, this now supports Do you think |
|
That's an excellent question. I think if Xcode Playgrounds support pages out of the box, our abstraction no longer provides significant value. I'm wary of removing it only because of anyone still using the tool, a note in the readme and updating my blog post should mitigate that risk. |
|
@orta @rpowelll I'd love to hear your thoughts on this question ^ |
|
Thanks for the poke was not watching, lets have a look |
|
re: |
|
Great. I'll get started on documentation and tests then. |
|
Really excited about this, since it seems like such a better way to write playground books. If there's anything I can do to help, please let me know 🙇 |
|
Sorry about the delays. I'm back on this starting tomorrow. I just returned from some personal travel. |
|
Never feel guilty for not contributing to OSS in your spare time 👍 |
|
Looks good to me, @dionlarson can you confirm this is good to merge? |
|
I took some time to test this implementation with a simple book I'm writing and it works really well, however, if I may suggest an improvement, it's the ability to copy folders (not only files) placed in the Resources folders. At the moment an exception is returned. /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1394:in `copy_stream': Is a directory - read (Errno::EISDIR)
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1394:in `block (2 levels) in copy_file'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1393:in `open'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1393:in `block in copy_file'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1392:in `open'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1392:in `copy_file'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:486:in `copy_file'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:403:in `block in cp'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1571:in `block in fu_each_src_dest'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1585:in `fu_each_src_dest0'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:1569:in `fu_each_src_dest'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:402:in `cp'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:79:in `block in copy_resources'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:78:in `each'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:78:in `copy_resources'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:41:in `block in collate'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:22:in `chdir'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/chapter_collator.rb:22:in `collate'
from /Users/matteo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/playgroundbook-0.4.0/lib/renderer/playgroundbook_renderer.rb:93:in `block (4 levels) iTo solve the issue you can just replace the FileUtils.copy_entry("../../../../#{resource}", SharedResourcesDirectoryName) |
|
Just a quick note, in order to build the gem (but I'm not that expert) I had to rename the Code of Conduct.md file removing the spaces as the s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)in the .gemspec was messing with them. |
|
Going to take a look at this PR this afternoon and merge if it looks good. Thanks again @dionlarson. |
Playgrounds for Xcode can have multiple pages. When you add a new page, the file structure becomes:
The default Playground (with only one page) has a file structure of:
I believe that taking advantage of this structure is better than putting everything in a single
Contents.swift. This is currently just a proof of concept (not fully implemented and no tests).Work in Progress:
Sourcesinstead of looking forSources/Preample.swiftResourcesfrom.playgroundto.playgroundchapterSourcesfrom.xcplaygroundpageto.playgroundpageResourcesfrom.xcplaygroundpageto.playgroundpage////split) should still be supported////codeYou can test it against this repo (the generated
.playgroundbookis included in the repo).