Skip to content

Commit

Permalink
docs: minor revisions to layouts and other
Browse files Browse the repository at this point in the history
  • Loading branch information
andymeneely committed Feb 3, 2016
1 parent 9cef989 commit 29b8d31
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gemfile.lock
InstalledFiles
_yardoc
coverage
docs/_build
docs/_build*
doc/
lib/bundler/man
pkg
Expand Down
2 changes: 1 addition & 1 deletion docs/args/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fill_color
stroke_color
default: ``:black``

the color with which to stroke the outside of the rectangle. See :docs:`/colors`.
the color with which to stroke the outside of the rectangle. See :doc:`/colors`.


stroke_width
Expand Down
6 changes: 6 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Installation
------------

Squib is a Ruby gem, and is managed like most Ruby gems.

TODO: recover this from other writing
39 changes: 29 additions & 10 deletions docs/layouts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ For example, back to our example::

# custom-layout.yml
bleed:
x: 75
y: 75
width: 975
height: 675
x: 0.25in
y: 0.25in
width: 2.5in
height: 3.5in

(Note that this example makes use of :doc:`/units`)

And this script::
Combined with this script:

.. code-block:: ruby
# deck.rb
Squib::Deck.new(layout: 'custom-layout.yml') do
Expand Down Expand Up @@ -87,20 +91,35 @@ When Layouts Are Similar, Use ``extends``

Using layouts are a great way of keeping your Ruby code clean and concise. But those layout Yaml files can get pretty long. If you have a bunch of icons along the top of a card, for example, you're specifying the same ``y`` option over and over again. This is annoyingly verbose, and what if you want to move all those icons downward at once?

Squib provides a way of reusing layouts with the special `extends`` key. When defining an `extends`` key, we can merge in another key and modify its data coming in if we want to. This allows us to do things like place text next to an icon and be able to move them with each other. Like this::
Squib provides a way of reusing layouts with the special `extends`` key. When defining an ```extends`` key, we can merge in another key and modify its data coming in if we want to. This allows us to do things like place text next to an icon and be able to move them with each other. Like this::

# If we change attack, we move defend too!
attack:
x: 100
y: 100
radius: 100
defend:
extends: attack
x: += 50
x: 150
#defend now is {:x => 150, :y => 100}

Over time, using ``extends`` saves you a lot of space in your Yaml files while also giving more structure and readability to the file itself.

You can also **modify** data as they get passed through extends::

# If we change attack, we move defend too!
attack:
x: 100
defend:
extends: attack
x: += 50
#defend now is {:x => 150, :y => 100}

The following operators are supported within evaluating ``extends``
* ``+=`` will add the giuven number to the inherited number
* ``-=`` will subtract the given number from the inherited number

Both operators also support :doc:`/units`

From a design point of view, you can also extract out a base design and have your other layouts extend from them::

top_icons:
Expand Down Expand Up @@ -144,9 +163,9 @@ If multiple keys override the same keys in a parent, the later ("younger") child
x: 200
aristotle:
extends:
- plato
- plato # note the order here
- socrates
x: += 50 # evaluates to 250 from socrates
x: += 50 # evaluates to 150 from socrates


Multiple Layout Files get Merged
Expand Down

0 comments on commit 29b8d31

Please sign in to comment.