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 +4 -4
- data/README.md +17 -8
- data/bin/playgroundbook +1 -1
- data/lib/renderer/playgroundbook_renderer.rb +4 -2
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd293e21e00aec27ecdd40d1637a7de8a4e0ae2d
|
4
|
+
data.tar.gz: 6f799975a931872ef587c9a0ac4677d3c3f3b1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
@@ -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
|
-
|
55
|
-
|
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