playgroundbook 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 000ecb1a02bff2b04307cd2a25a719a1aa242ae9
4
- data.tar.gz: 5b30b076d2763c7132140535c2258b67221ef8b4
3
+ metadata.gz: cd293e21e00aec27ecdd40d1637a7de8a4e0ae2d
4
+ data.tar.gz: 6f799975a931872ef587c9a0ac4677d3c3f3b1dc
5
5
  SHA512:
6
- metadata.gz: ebd0b322c996b8a2698e553726319d575998573be3729f8a36af2a75940bd6401f81549e74d50aad1d772b9be8f8cc06108368d3075afa4a08b741b544e94e73
7
- data.tar.gz: 7e7b5e305994ff92ef6b43200dcf50d8a6b84c3c8775f047a7b8fca4d710a7f88d5461e4148bcd4b8bba5bc9655d800113d78c79f8e6bd05d1d378f4a20bece6
6
+ metadata.gz: b39647c796f1c89acae80b3f701b38462a2e6f2946f8ca3bbcd520c007cb6d9cd3e71b3c6fbed80db8cac6f037391e2dd3fc563d5e5b2a5074ae35aa7b801ff2
7
+ data.tar.gz: b555c07c7b784e9a7f5e968866263e62eb140629348fd6a912acf88e2b015f53884b36750db95c59733201c386d3ddc7729103c810e41ac19ad7816825b7d1da
data/README.md CHANGED
@@ -47,7 +47,23 @@ glossary:
47
47
  term: definition
48
48
  ```
49
49
 
50
- Each chapter needs to have a corresponding playground; so `Chapter 1` requires there be a `Chapter 1.playground` playground. The playgrounds can reference (not copy) resources from an optionally specified directory. `import` frameworks are specified in the yaml file and are added to every page of the book. You can specify a cover image file name that's stored in the `resources` directory (it should be 400x300 pixels). Finally, you can supply a glossary, a dictionary of term/definition pairs. This lets you link to terms in markdown. For example:
50
+ Each chapter needs to have a corresponding playground; so `Chapter 1` requires there be a `Chapter 1.playground` playground. Your directory should look like this:
51
+
52
+ ![](web/finder.png)
53
+
54
+ Once you've created a playground for each _chapter_, it's time to add pages to your playgrounds. You can do this in Xcode.
55
+
56
+ ![](web/xcode.png)
57
+
58
+ Note that the order of the pages is determined by the ordering of the filesystem, which is lexicographical. You also can't have any periods in your pages.
59
+
60
+ Then run the `render` command in the directory containing the yaml file.
61
+
62
+ ```sh
63
+ playgroundbook render book.yaml
64
+ ```
65
+
66
+ The playgrounds can reference (not copy) resources from an optionally specified directory. `import` frameworks are specified in the yaml file and are added to every page of the book. You can specify a cover image file name that's stored in the `resources` directory (it should be 400x300 pixels). Finally, you can supply a glossary, a dictionary of term/definition pairs. This lets you link to terms in markdown. For example:
51
67
 
52
68
  ```md
53
69
  ... [term](glossary://term) ...
@@ -60,13 +76,6 @@ Each page in a chapter's `.playground` will be a separate page in the `.playgrou
60
76
  ### Limitations of Book Rendering
61
77
 
62
78
  Playground books support a rich set of awesome features to make learning how to code really easy, and this tool only scratches the surface. Read over the [Playground Book reference](https://developer.apple.com/library/content/documentation/Xcode/Conceptual/swift_playgrounds_doc_format/) to see all the available options. If you have suggestions, please open an issue :+1:
63
- =======
64
- The preamble (anything about the first `////` page) is put in its own file. That means declarations there need to be `public` to be visible within individual pages (even though when you're writing, everything is in one file). Additionally, the preamble is at the top-level and can't contain expressions. This would cause a compiler error in the Swift Playrounds iPad app:
65
-
66
- ```swift
67
- public let layout = UICollectionViewFlowLayout()
68
- layout.itemSize = CGSize(width: 20, height: 20)
69
- ```
70
79
 
71
80
  ### Creating a Playground from markdown
72
81
 
data/bin/playgroundbook CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  unless ARGV.length >= 2
4
4
  puts "You must specify either lint or render. Example usage:"
5
- puts " playgroundbook [lint|render] file_name"
5
+ puts " playgroundbook [lint|render|wrapper] file_name"
6
6
  exit 1
7
7
  end
8
8
 
@@ -51,8 +51,10 @@ module Playgroundbook
51
51
  c = File.read(single_page_file)
52
52
  page_parser.parse_chapter_pages(c, source_names, resource_names)
53
53
  elsif !Dir.glob("#{chapter['name']}.playground/Pages/*.xcplaygroundpage").empty?
54
- toc = Nokogiri::XML(File.read("#{chapter['name']}.playground/contents.xcplayground"))
55
- page_names = toc.xpath("//page").map { |p| p["name"] }
54
+ page_names = Dir.glob("#{chapter['name']}.playground/Pages/*.xcplaygroundpage").map do |name|
55
+ # Transforms 'Chapter One.playground/Pages/Untitled Page.xcplaygroundpage' into 'Untitled Page'
56
+ name.split('/').last.split('.').first
57
+ end
56
58
  pages_data = page_names.map do |p|
57
59
  {
58
60
  name: p,
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Playgroundbook
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playgroundbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow