squib 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.gitmodules +22 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +40 -0
- data/README.md +25 -553
- data/RELEASE TODO.md +2 -2
- data/Rakefile +6 -64
- data/appveyor.yml +0 -4
- data/benchmarks/antialias_best.rb +2 -2
- data/benchmarks/antialias_fast.rb +2 -2
- data/benchmarks/{backend-memory.rb → backend_memory.rb} +2 -2
- data/benchmarks/{backend-svg.rb → backend_svg.rb} +2 -2
- data/benchmarks/tons_of_png.rb +1 -1
- data/benchmarks/tons_of_svg.rb +1 -1
- data/benchmarks/tons_of_text.rb +1 -1
- data/docs/Makefile +216 -0
- data/docs/_static/css/squibdocs.css +18 -0
- data/docs/args/draw.rst +36 -0
- data/docs/args/expansion.rst +3 -0
- data/docs/args/layout.rst +6 -0
- data/docs/args/output_dir.rst +6 -0
- data/docs/args/range.rst +6 -0
- data/docs/args/transform.rst +51 -0
- data/docs/args/trim.rst +11 -0
- data/docs/args/wh.rst +12 -0
- data/docs/args/xy.rst +12 -0
- data/docs/arrays.rst +77 -0
- data/docs/backends.rst +20 -0
- data/docs/bleed.rst +13 -0
- data/docs/build_groups.rst +47 -0
- data/docs/colors.rst +64 -0
- data/docs/conf.py +287 -0
- data/docs/config.rst +117 -0
- data/docs/data.rst +22 -0
- data/docs/dsl/background.rst +20 -0
- data/docs/dsl/build.rst +32 -0
- data/docs/dsl/build_groups.rst +23 -0
- data/docs/dsl/circle.rst +27 -0
- data/docs/dsl/cm.rst +19 -0
- data/docs/dsl/csv.rst +62 -0
- data/docs/dsl/curve.rst +63 -0
- data/docs/dsl/deck.rst +45 -0
- data/docs/dsl/disable_build.rst +28 -0
- data/docs/dsl/ellipse.rst +17 -0
- data/docs/dsl/enable_build.rst +25 -0
- data/docs/dsl/grid.rst +31 -0
- data/docs/dsl/hand.rst +40 -0
- data/docs/dsl/hint.rst +15 -0
- data/docs/dsl/inches.rst +19 -0
- data/docs/dsl/index.rst +9 -0
- data/docs/dsl/line.rst +52 -0
- data/docs/dsl/png.rst +49 -0
- data/docs/dsl/polygon.rst +28 -0
- data/docs/dsl/rect.rst +18 -0
- data/docs/dsl/save.rst +23 -0
- data/docs/dsl/save_pdf.rst +48 -0
- data/docs/dsl/save_png.rst +46 -0
- data/docs/dsl/save_sheet.rst +55 -0
- data/docs/dsl/showcase.rst +65 -0
- data/docs/dsl/star.rst +35 -0
- data/docs/dsl/svg.rst +119 -0
- data/docs/dsl/text.rst +294 -0
- data/docs/dsl/triangle.rst +38 -0
- data/docs/dsl/use_layout.rst +16 -0
- data/docs/dsl/xlsx.rst +50 -0
- data/docs/guides/game_icons.rst +2 -0
- data/docs/guides/getting-started/index.rst +5 -0
- data/docs/guides/getting-started/part_0_learning_ruby.rst +145 -0
- data/docs/guides/getting-started/part_1_zero_to_game.rst +216 -0
- data/docs/guides/getting-started/part_2_iconography.rst +152 -0
- data/docs/guides/getting-started/part_3_workflows.rst +4 -0
- data/docs/guides/git.rst +13 -0
- data/docs/guides/hello_world.rst +6 -0
- data/docs/help.rst +157 -0
- data/docs/index.rst +35 -0
- data/docs/install.rst +66 -0
- data/docs/layouts.rst +235 -0
- data/docs/learning.rst +10 -0
- data/docs/make.bat +263 -0
- data/docs/parameters.rst +26 -0
- data/docs/server.bat +1 -0
- data/docs/text_feature.rst +86 -0
- data/docs/units.rst +6 -0
- data/lib/squib.rb +4 -4
- data/lib/squib/api/background.rb +5 -10
- data/lib/squib/api/data.rb +30 -54
- data/lib/squib/api/groups.rb +47 -0
- data/lib/squib/api/image.rb +8 -67
- data/lib/squib/api/save.rb +15 -105
- data/lib/squib/api/settings.rb +8 -22
- data/lib/squib/api/shapes.rb +15 -185
- data/lib/squib/api/text.rb +9 -49
- data/lib/squib/api/text_embed.rb +12 -12
- data/lib/squib/api/units.rb +3 -17
- data/lib/squib/args/arg_loader.rb +6 -6
- data/lib/squib/args/box.rb +2 -2
- data/lib/squib/args/card_range.rb +1 -1
- data/lib/squib/args/color_validator.rb +2 -2
- data/lib/squib/args/coords.rb +2 -2
- data/lib/squib/args/csv_opts.rb +25 -0
- data/lib/squib/args/dir_validator.rb +1 -1
- data/lib/squib/args/draw.rb +2 -2
- data/lib/squib/args/embed_adjust.rb +1 -1
- data/lib/squib/args/embed_key.rb +1 -1
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +2 -2
- data/lib/squib/args/input_file.rb +1 -1
- data/lib/squib/args/paint.rb +3 -3
- data/lib/squib/args/paragraph.rb +2 -2
- data/lib/squib/args/save_batch.rb +2 -2
- data/lib/squib/args/scale_box.rb +1 -1
- data/lib/squib/args/sheet.rb +3 -3
- data/lib/squib/args/showcase_special.rb +2 -2
- data/lib/squib/args/svg_special.rb +1 -1
- data/lib/squib/args/transform.rb +2 -2
- data/lib/squib/args/typographer.rb +5 -4
- data/lib/squib/args/unit_conversion.rb +4 -4
- data/lib/squib/card.rb +8 -8
- data/lib/squib/conf.rb +5 -5
- data/lib/squib/deck.rb +20 -18
- data/lib/squib/graphics/cairo_context_wrapper.rb +3 -3
- data/lib/squib/graphics/gradient_regex.rb +1 -1
- data/lib/squib/graphics/hand.rb +2 -2
- data/lib/squib/graphics/save_doc.rb +9 -8
- data/lib/squib/graphics/save_images.rb +24 -11
- data/lib/squib/graphics/shapes.rb +16 -17
- data/lib/squib/graphics/showcase.rb +9 -9
- data/lib/squib/graphics/text.rb +21 -21
- data/lib/squib/layout_parser.rb +9 -9
- data/lib/squib/layouts/economy.yml +85 -85
- data/lib/squib/layouts/fantasy.yml +101 -101
- data/lib/squib/layouts/hand.yml +62 -62
- data/lib/squib/layouts/playing-card.yml +35 -35
- data/lib/squib/layouts/tuck_box.yml +45 -45
- data/lib/squib/sample_helpers.rb +1 -1
- data/lib/squib/version.rb +1 -1
- data/samples/{backend.rb → backend/_backend.rb} +2 -2
- data/samples/basic.rb +3 -3
- data/samples/bug134.rb +14 -0
- data/samples/build_groups/build_groups.rb +36 -0
- data/samples/cairo_access.rb +12 -1
- data/samples/{colors.rb → colors/_colors.rb} +12 -12
- data/samples/{gradients.rb → colors/_gradients.rb} +1 -1
- data/samples/config_text_markup.rb +2 -2
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/{csv_import.rb → data/_csv.rb} +8 -1
- data/samples/{excel.rb → data/_excel.rb} +3 -3
- data/samples/embed_text.rb +21 -0
- data/samples/hello_world.rb +1 -1
- data/samples/{load_images.rb → images/_more_load_images.rb} +2 -2
- data/samples/layouts.rb +11 -1
- data/samples/layouts_builtin.rb +51 -51
- data/samples/offset.svg +71 -71
- data/samples/ranges.rb +7 -7
- data/samples/{hand.rb → saves/_hand.rb} +1 -2
- data/samples/{portrait-landscape.rb → saves/_portrait_landscape.rb} +4 -4
- data/samples/{saves.rb → saves/_saves.rb} +0 -0
- data/samples/{showcase.rb → saves/_showcase.rb} +2 -2
- data/samples/{draw_shapes.rb → shapes/_draw_shapes.rb} +1 -1
- data/samples/text/_text.rb +4 -3
- data/samples/text_options.rb +6 -6
- data/samples/unicode.rb +1 -1
- data/spec/api/api_data_spec.rb +59 -4
- data/spec/api/api_settings_spec.rb +1 -1
- data/spec/args/box_spec.rb +7 -7
- data/spec/args/draw_spec.rb +19 -19
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +2 -2
- data/spec/args/paint_spec.rb +5 -5
- data/spec/args/paragraph_spec.rb +28 -28
- data/spec/args/range_spec.rb +1 -1
- data/spec/args/save_batch_spec.rb +10 -10
- data/spec/args/scale_box_spec.rb +9 -9
- data/spec/args/sheet_spec.rb +8 -8
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +4 -4
- data/spec/args/typographer_spec.rb +11 -11
- data/spec/args/unit_conversion_spec.rb +2 -2
- data/spec/card_spec.rb +1 -1
- data/spec/commands/new_spec.rb +1 -1
- data/spec/data/csv/custom_opts.csv +2 -0
- data/spec/data/csv/newline.csv +3 -0
- data/spec/data/csv/qty.csv +2 -2
- data/spec/data/csv/qty_named.csv +2 -2
- data/spec/data/csv/with_spaces.csv +2 -2
- data/spec/data/csv/yield.csv +3 -0
- data/spec/data/samples/{autoscale_font.rb.txt → autoscale_font/_autoscale_font.rb.txt} +55 -18
- data/spec/data/samples/cairo_access.rb.txt +24 -0
- data/spec/data/samples/{gradients.rb.txt → colors/_gradients.rb.txt} +0 -0
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/custom_config.rb.txt +1 -0
- data/spec/data/samples/{csv_import.rb.txt → data/_csv.rb.txt} +0 -0
- data/spec/data/samples/{excel.rb.txt → data/_excel.rb.txt} +0 -0
- data/spec/data/samples/embed_text.rb.txt +79 -0
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/{load_images.rb.txt → images/_more_load_images.rb.txt} +4 -4
- data/spec/data/samples/{hand.rb.txt → saves/_hand.rb.txt} +0 -0
- data/spec/data/samples/{portrait-landscape.rb.txt → saves/_portrait_landscape.rb.txt} +11 -7
- data/spec/data/samples/{save_pdf.rb.txt → saves/_save_pdf.rb.txt} +0 -0
- data/spec/data/samples/{saves.rb.txt → saves/_saves.rb.txt} +3 -4
- data/spec/data/samples/{showcase.rb.txt → saves/_showcase.rb.txt} +0 -0
- data/spec/data/samples/{draw_shapes.rb.txt → shapes/_draw_shapes.rb.txt} +0 -0
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/graphics/cairo_context_wrapper_spec.rb +10 -10
- data/spec/graphics/graphics_save_doc_spec.rb +11 -5
- data/spec/layout_parser_spec.rb +21 -9
- data/spec/logger_spec.rb +2 -2
- data/spec/samples/run_samples_spec.rb +1 -1
- data/spec/samples/samples_regression_spec.rb +16 -18
- data/spec/samples/sanity.rb +9 -9
- data/spec/sanity/.gitignore +1 -0
- data/spec/sanity/sanity.html.erb +42 -0
- data/spec/sanity/sanity_test.rb +42 -0
- data/spec/sanity/tests.yml +12 -0
- data/spec/spec_helper.rb +22 -20
- data/squib.gemspec +3 -4
- metadata +143 -81
- data/.rspec +0 -1
- data/.yardopts +0 -10
- data/samples/autoscale_font.rb +0 -27
- data/samples/backend-config.yml +0 -5
- data/samples/color_shortcuts.rb +0 -6
- data/samples/explode_quantities.xlsx +0 -0
- data/samples/quantity_explosion.csv +0 -3
- data/samples/sample.csv +0 -3
- data/samples/sample.xlsx +0 -0
- data/squib.sublime-project +0 -42
data/docs/learning.rst
ADDED
data/docs/make.bat
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
@ECHO OFF
|
2
|
+
|
3
|
+
REM Command file for Sphinx documentation
|
4
|
+
|
5
|
+
if "%SPHINXBUILD%" == "" (
|
6
|
+
set SPHINXBUILD=sphinx-build
|
7
|
+
)
|
8
|
+
set BUILDDIR=_build
|
9
|
+
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
10
|
+
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
11
|
+
if NOT "%PAPER%" == "" (
|
12
|
+
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
13
|
+
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
14
|
+
)
|
15
|
+
|
16
|
+
if "%1" == "" goto help
|
17
|
+
|
18
|
+
if "%1" == "help" (
|
19
|
+
:help
|
20
|
+
echo.Please use `make ^<target^>` where ^<target^> is one of
|
21
|
+
echo. html to make standalone HTML files
|
22
|
+
echo. dirhtml to make HTML files named index.html in directories
|
23
|
+
echo. singlehtml to make a single large HTML file
|
24
|
+
echo. pickle to make pickle files
|
25
|
+
echo. json to make JSON files
|
26
|
+
echo. htmlhelp to make HTML files and a HTML help project
|
27
|
+
echo. qthelp to make HTML files and a qthelp project
|
28
|
+
echo. devhelp to make HTML files and a Devhelp project
|
29
|
+
echo. epub to make an epub
|
30
|
+
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
31
|
+
echo. text to make text files
|
32
|
+
echo. man to make manual pages
|
33
|
+
echo. texinfo to make Texinfo files
|
34
|
+
echo. gettext to make PO message catalogs
|
35
|
+
echo. changes to make an overview over all changed/added/deprecated items
|
36
|
+
echo. xml to make Docutils-native XML files
|
37
|
+
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
38
|
+
echo. linkcheck to check all external links for integrity
|
39
|
+
echo. doctest to run all doctests embedded in the documentation if enabled
|
40
|
+
echo. coverage to run coverage check of the documentation if enabled
|
41
|
+
goto end
|
42
|
+
)
|
43
|
+
|
44
|
+
if "%1" == "clean" (
|
45
|
+
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
46
|
+
del /q /s %BUILDDIR%\*
|
47
|
+
goto end
|
48
|
+
)
|
49
|
+
|
50
|
+
|
51
|
+
REM Check if sphinx-build is available and fallback to Python version if any
|
52
|
+
%SPHINXBUILD% 1>NUL 2>NUL
|
53
|
+
if errorlevel 9009 goto sphinx_python
|
54
|
+
goto sphinx_ok
|
55
|
+
|
56
|
+
:sphinx_python
|
57
|
+
|
58
|
+
set SPHINXBUILD=python -m sphinx.__init__
|
59
|
+
%SPHINXBUILD% 2> nul
|
60
|
+
if errorlevel 9009 (
|
61
|
+
echo.
|
62
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
63
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
64
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
65
|
+
echo.may add the Sphinx directory to PATH.
|
66
|
+
echo.
|
67
|
+
echo.If you don't have Sphinx installed, grab it from
|
68
|
+
echo.http://sphinx-doc.org/
|
69
|
+
exit /b 1
|
70
|
+
)
|
71
|
+
|
72
|
+
:sphinx_ok
|
73
|
+
|
74
|
+
|
75
|
+
if "%1" == "html" (
|
76
|
+
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
77
|
+
if errorlevel 1 exit /b 1
|
78
|
+
echo.
|
79
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
80
|
+
goto end
|
81
|
+
)
|
82
|
+
|
83
|
+
if "%1" == "dirhtml" (
|
84
|
+
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
85
|
+
if errorlevel 1 exit /b 1
|
86
|
+
echo.
|
87
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
88
|
+
goto end
|
89
|
+
)
|
90
|
+
|
91
|
+
if "%1" == "singlehtml" (
|
92
|
+
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
93
|
+
if errorlevel 1 exit /b 1
|
94
|
+
echo.
|
95
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
96
|
+
goto end
|
97
|
+
)
|
98
|
+
|
99
|
+
if "%1" == "pickle" (
|
100
|
+
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
101
|
+
if errorlevel 1 exit /b 1
|
102
|
+
echo.
|
103
|
+
echo.Build finished; now you can process the pickle files.
|
104
|
+
goto end
|
105
|
+
)
|
106
|
+
|
107
|
+
if "%1" == "json" (
|
108
|
+
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
109
|
+
if errorlevel 1 exit /b 1
|
110
|
+
echo.
|
111
|
+
echo.Build finished; now you can process the JSON files.
|
112
|
+
goto end
|
113
|
+
)
|
114
|
+
|
115
|
+
if "%1" == "htmlhelp" (
|
116
|
+
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
117
|
+
if errorlevel 1 exit /b 1
|
118
|
+
echo.
|
119
|
+
echo.Build finished; now you can run HTML Help Workshop with the ^
|
120
|
+
.hhp project file in %BUILDDIR%/htmlhelp.
|
121
|
+
goto end
|
122
|
+
)
|
123
|
+
|
124
|
+
if "%1" == "qthelp" (
|
125
|
+
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
126
|
+
if errorlevel 1 exit /b 1
|
127
|
+
echo.
|
128
|
+
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
129
|
+
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
130
|
+
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Squib.qhcp
|
131
|
+
echo.To view the help file:
|
132
|
+
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Squib.ghc
|
133
|
+
goto end
|
134
|
+
)
|
135
|
+
|
136
|
+
if "%1" == "devhelp" (
|
137
|
+
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
138
|
+
if errorlevel 1 exit /b 1
|
139
|
+
echo.
|
140
|
+
echo.Build finished.
|
141
|
+
goto end
|
142
|
+
)
|
143
|
+
|
144
|
+
if "%1" == "epub" (
|
145
|
+
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
146
|
+
if errorlevel 1 exit /b 1
|
147
|
+
echo.
|
148
|
+
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
149
|
+
goto end
|
150
|
+
)
|
151
|
+
|
152
|
+
if "%1" == "latex" (
|
153
|
+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
154
|
+
if errorlevel 1 exit /b 1
|
155
|
+
echo.
|
156
|
+
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
157
|
+
goto end
|
158
|
+
)
|
159
|
+
|
160
|
+
if "%1" == "latexpdf" (
|
161
|
+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
162
|
+
cd %BUILDDIR%/latex
|
163
|
+
make all-pdf
|
164
|
+
cd %~dp0
|
165
|
+
echo.
|
166
|
+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
167
|
+
goto end
|
168
|
+
)
|
169
|
+
|
170
|
+
if "%1" == "latexpdfja" (
|
171
|
+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
172
|
+
cd %BUILDDIR%/latex
|
173
|
+
make all-pdf-ja
|
174
|
+
cd %~dp0
|
175
|
+
echo.
|
176
|
+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
177
|
+
goto end
|
178
|
+
)
|
179
|
+
|
180
|
+
if "%1" == "text" (
|
181
|
+
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
182
|
+
if errorlevel 1 exit /b 1
|
183
|
+
echo.
|
184
|
+
echo.Build finished. The text files are in %BUILDDIR%/text.
|
185
|
+
goto end
|
186
|
+
)
|
187
|
+
|
188
|
+
if "%1" == "man" (
|
189
|
+
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
190
|
+
if errorlevel 1 exit /b 1
|
191
|
+
echo.
|
192
|
+
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
193
|
+
goto end
|
194
|
+
)
|
195
|
+
|
196
|
+
if "%1" == "texinfo" (
|
197
|
+
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
198
|
+
if errorlevel 1 exit /b 1
|
199
|
+
echo.
|
200
|
+
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
201
|
+
goto end
|
202
|
+
)
|
203
|
+
|
204
|
+
if "%1" == "gettext" (
|
205
|
+
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
206
|
+
if errorlevel 1 exit /b 1
|
207
|
+
echo.
|
208
|
+
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
209
|
+
goto end
|
210
|
+
)
|
211
|
+
|
212
|
+
if "%1" == "changes" (
|
213
|
+
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
214
|
+
if errorlevel 1 exit /b 1
|
215
|
+
echo.
|
216
|
+
echo.The overview file is in %BUILDDIR%/changes.
|
217
|
+
goto end
|
218
|
+
)
|
219
|
+
|
220
|
+
if "%1" == "linkcheck" (
|
221
|
+
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
222
|
+
if errorlevel 1 exit /b 1
|
223
|
+
echo.
|
224
|
+
echo.Link check complete; look for any errors in the above output ^
|
225
|
+
or in %BUILDDIR%/linkcheck/output.txt.
|
226
|
+
goto end
|
227
|
+
)
|
228
|
+
|
229
|
+
if "%1" == "doctest" (
|
230
|
+
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
231
|
+
if errorlevel 1 exit /b 1
|
232
|
+
echo.
|
233
|
+
echo.Testing of doctests in the sources finished, look at the ^
|
234
|
+
results in %BUILDDIR%/doctest/output.txt.
|
235
|
+
goto end
|
236
|
+
)
|
237
|
+
|
238
|
+
if "%1" == "coverage" (
|
239
|
+
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
|
240
|
+
if errorlevel 1 exit /b 1
|
241
|
+
echo.
|
242
|
+
echo.Testing of coverage in the sources finished, look at the ^
|
243
|
+
results in %BUILDDIR%/coverage/python.txt.
|
244
|
+
goto end
|
245
|
+
)
|
246
|
+
|
247
|
+
if "%1" == "xml" (
|
248
|
+
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
249
|
+
if errorlevel 1 exit /b 1
|
250
|
+
echo.
|
251
|
+
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
252
|
+
goto end
|
253
|
+
)
|
254
|
+
|
255
|
+
if "%1" == "pseudoxml" (
|
256
|
+
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
257
|
+
if errorlevel 1 exit /b 1
|
258
|
+
echo.
|
259
|
+
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
260
|
+
goto end
|
261
|
+
)
|
262
|
+
|
263
|
+
:end
|
data/docs/parameters.rst
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Parameters are Optional
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Squib is all about sane defaults and shorthand specification. Arguments to DSL methods are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional.
|
5
|
+
|
6
|
+
For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
|
7
|
+
|
8
|
+
.. highlight:: none
|
9
|
+
|
10
|
+
Note: you MUST use named parameters rather than positional parameters. For example: ``save :png`` will lead to an error like this::
|
11
|
+
|
12
|
+
C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/api/save.rb:12:in `save': wrong number of arguments (2 for 0..1) (ArgumentError)
|
13
|
+
from deck.rb:22:in `block in <main>'
|
14
|
+
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `instance_eval'
|
15
|
+
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `initialize'
|
16
|
+
from deck.rb:18:in `new'
|
17
|
+
from deck.rb:18:in `<main>'
|
18
|
+
|
19
|
+
Instead, you must name the parameters: `save format: :png`
|
20
|
+
|
21
|
+
.. warning::
|
22
|
+
|
23
|
+
If you provide an option to a DSL method that the DSL method does not recognize, Squib ignores the extraenous option without warning. For example, these two calls have identical behavior::
|
24
|
+
|
25
|
+
save_png prefix: 'front_'
|
26
|
+
save_png prefix: 'front_', narf: true
|
data/docs/server.bat
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
sphinx-autobuild . _build/html
|
@@ -0,0 +1,86 @@
|
|
1
|
+
The Mighty text Method
|
2
|
+
======================
|
3
|
+
|
4
|
+
|
5
|
+
The :doc:`/dsl/text` method is a particularly powerful method with a ton of options. Be sure to check the option-by-option details in the DSL reference, but here are the highlights.
|
6
|
+
|
7
|
+
Fonts
|
8
|
+
-----
|
9
|
+
|
10
|
+
To set the font, your ``text`` method call will look something like this::
|
11
|
+
|
12
|
+
text str: "Hello", font: 'MyFont Bold 32'
|
13
|
+
|
14
|
+
|
15
|
+
The ``'MyFont Bold 32'`` is specified as a "Pango font string", which can involve `a lot of options <http://ruby-gnome2.osdn.jp/hiki.cgi?Pango%3A%3AFontDescription#Pango%3A%3AFontDescription.new>`_ including backup font families, size, all-caps, stretch, oblique, italic, and degree of boldness. (These options are only available if the underlying font supports them, however.) Here's are some :doc:`/dsl/text` calls with different Pango font strings::
|
16
|
+
|
17
|
+
text str: "Hello", font: 'Sans 18'
|
18
|
+
text str: "Hello", font: 'Arial,Verdana weight=900 style=oblique 36'
|
19
|
+
text str: "Hello", font: 'Times New Roman,Sans 25'
|
20
|
+
|
21
|
+
|
22
|
+
Finally, Squib's ``text`` method has options such as ``font_size`` that allow you to override the font string. This means that you can set a blanket font for the whole deck, then adjust sizes from there. This is useful with layouts and ``extends`` too (see :doc:`/layouts`).
|
23
|
+
|
24
|
+
.. note::
|
25
|
+
|
26
|
+
When the font has a space in the name (e.g. Times New Roman), you'll need to put a backup to get Pango's parsing to work. In some operating systems, you'll want to simply end with a comma::
|
27
|
+
|
28
|
+
text str: "Hello", font: 'Times New Roman, 25'
|
29
|
+
|
30
|
+
.. note::
|
31
|
+
|
32
|
+
Most of the font rendering is done by a combination of your installed fonts, your OS, and your graphics card. Thus, different systems will render text slightly differently.
|
33
|
+
|
34
|
+
Width and Height
|
35
|
+
------------------
|
36
|
+
|
37
|
+
By default, Pango text boxes will scale the text box to whatever you need, hence the ``:native`` default. However, for most of the other customizations to work (e.g. center-aligned) you'll need to specify the width. If both the width and the height are specified and the text overflows, then the ``ellipsize`` option is consulted to figure out what to do with the overflow. Also, the ``valign`` will only work if ``height`` is also set to something other than ``:native``.
|
38
|
+
|
39
|
+
Hints
|
40
|
+
-----
|
41
|
+
|
42
|
+
Laying out text by typing in numbers can be confusing. What Squib calls "hints" is merely a rectangle around the text box. Hints can be turned on globally in the config file, using the :doc:`/dsl/hint` method, or in an individual text method. These are there merely for prototyping and are not intended for production. Additionally, these are not to be conflated with "rendering hints" that Pango and Cairo mention in their documentation.
|
43
|
+
|
44
|
+
Extents
|
45
|
+
------
|
46
|
+
|
47
|
+
Sometimes you want size things based on the size of your rendered text. For example, drawing a rectangle around card's title such that the rectangle perfectly fits. Squib returns the final rendered size of the text so you can work with it afterward. It's an array of hashes that correspond to each card. The output looks like this::
|
48
|
+
|
49
|
+
Squib::Deck.new(cards: 2) do
|
50
|
+
extents = text(str: ['Hello', 'World!'])
|
51
|
+
puts extents
|
52
|
+
end
|
53
|
+
|
54
|
+
will output::
|
55
|
+
|
56
|
+
[{:width=>109, :height=>55}, {:width=>142, :height=>55}] # Hello was 109 pixels wide, World 142 pixels
|
57
|
+
|
58
|
+
Embedding Images
|
59
|
+
------------------
|
60
|
+
|
61
|
+
Squib can embed icons into the flow of text. To do this, you need to define text keys for Squib to look for, and then the corresponding files. The object given to the block is a ``TextEmbed``, which supports PNG and SVG. Here's a minimal example::
|
62
|
+
|
63
|
+
text(str: 'Gain 1 :health:') do |embed|
|
64
|
+
embed.svg key: ':health:', file: 'heart.svg'
|
65
|
+
end
|
66
|
+
|
67
|
+
Markup
|
68
|
+
------
|
69
|
+
|
70
|
+
See :ref:`Markup <text-markup>` in :doc:`/dsl/text`.
|
71
|
+
|
72
|
+
Examples
|
73
|
+
--------
|
74
|
+
|
75
|
+
* Examples of all of the above are crammed into the ``text_options.rb`` sample `found here <https://github.com/andymeneely/squib/tree/master/samples/text_options.rb>`_
|
76
|
+
* The ``embed_text.rb`` sample has more examples of embedding text, which can be `found here <https://github.com/andymeneely/squib/tree/master/samples/embed_text.rb>`_
|
77
|
+
* The ``config_text_markup.rb`` sample demonstrates how quoting can be configured, `found here <https://github.com/andymeneely/squib/tree/master/samples/config_text_markup.rb>`_
|
78
|
+
|
79
|
+
And this one too:
|
80
|
+
|
81
|
+
.. raw:: html
|
82
|
+
|
83
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
84
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.4/gist-embed.min.js"></script>
|
85
|
+
<code data-gist-id="52d7b8e332194946bc69" data-gist-file="_text.rb"></code>
|
86
|
+
<code data-gist-id="52d7b8e332194946bc69" data-gist-file="_text_00_expected.png"></code>
|
data/docs/units.rst
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
Unit Conversion
|
2
|
+
===============
|
3
|
+
|
4
|
+
By default, Squib thinks in pixels. This decision was made so that we can have pixel-perfect layouts without automatically scaling everything, even though working in units is sometimes easier. We provide some conversion methods, including looking for strings that end in "in" and "cm" and computing based on the current DPI. The dpi is set on `Squib::Deck.new` (not `config.yml`).
|
5
|
+
|
6
|
+
Example is in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
|
data/lib/squib.rb
CHANGED
@@ -2,10 +2,10 @@ require 'logger'
|
|
2
2
|
require 'cairo'
|
3
3
|
require 'pango'
|
4
4
|
require 'rsvg2'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require_relative 'squib/version'
|
6
|
+
require_relative 'squib/commands/new'
|
7
|
+
require_relative 'squib/deck'
|
8
|
+
require_relative 'squib/card'
|
9
9
|
|
10
10
|
module Squib
|
11
11
|
|
data/lib/squib/api/background.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
+
require_relative '../args/card_range'
|
2
|
+
require_relative '../args/draw'
|
3
|
+
|
1
4
|
module Squib
|
2
5
|
class Deck
|
3
|
-
|
4
|
-
#
|
5
|
-
# background color: :white
|
6
|
-
#
|
7
|
-
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
8
|
-
#
|
9
|
-
# @option opts range [Enumerable] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
10
|
-
# @option opts color [String] (:black) the color the font will render to. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
11
|
-
# @return [nil] nothing
|
12
|
-
# @api public
|
6
|
+
|
7
|
+
# DSL method. See http://squib.readthedocs.org
|
13
8
|
def background(opts = {})
|
14
9
|
range = Args::CardRange.new(opts[:range], deck_size: size)
|
15
10
|
draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
|
data/lib/squib/api/data.rb
CHANGED
@@ -1,30 +1,12 @@
|
|
1
1
|
require 'roo'
|
2
2
|
require 'csv'
|
3
|
-
|
4
|
-
|
3
|
+
require_relative '../args/input_file'
|
4
|
+
require_relative '../args/import'
|
5
|
+
require_relative '../args/csv_opts'
|
5
6
|
|
6
7
|
module Squib
|
7
8
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
|
11
|
-
# See the example `samples/excel.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
|
12
|
-
#
|
13
|
-
# @example
|
14
|
-
# # Excel file looks like this:
|
15
|
-
# # | h1 | h2 |
|
16
|
-
# # ------------
|
17
|
-
# # | 1 | 2 |
|
18
|
-
# # | 3 | 4 |
|
19
|
-
# data = xlsx file: 'data.xlsx', sheet: 0
|
20
|
-
# => {'h1' => [1,3], 'h2' => [2,4]}
|
21
|
-
#
|
22
|
-
# @option opts file [String] the file to open. Must end in `.xlsx`. Opens relative to the current directory.
|
23
|
-
# @option opts sheet [Integer] (0) The zero-based index of the sheet from which to read.
|
24
|
-
# @option opts strip [Boolean] (true) When true, strips leading and trailing whitespace on values and headers
|
25
|
-
# @option opts explode [String] ('qty') Quantity explosion will be applied to the column this name. See README for example.
|
26
|
-
# @return [Hash] a hash of arrays based on columns in the spreadsheet
|
27
|
-
# @api public
|
9
|
+
# DSL method. See http://squib.readthedocs.org
|
28
10
|
def xlsx(opts = {})
|
29
11
|
input = Args::InputFile.new(file: 'deck.xlsx').load!(opts)
|
30
12
|
import = Args::Import.new.load!(opts)
|
@@ -32,47 +14,30 @@ module Squib
|
|
32
14
|
s.default_sheet = s.sheets[input.sheet[0]]
|
33
15
|
data = {}
|
34
16
|
s.first_column.upto(s.last_column) do |col|
|
35
|
-
header = s.cell(s.first_row,col).to_s
|
17
|
+
header = s.cell(s.first_row, col).to_s
|
36
18
|
header.strip! if import.strip?
|
37
19
|
data[header] = []
|
38
20
|
(s.first_row + 1).upto(s.last_row) do |row|
|
39
|
-
cell = s.cell(row,col)
|
21
|
+
cell = s.cell(row, col)
|
40
22
|
# Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
|
41
|
-
cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
|
23
|
+
cell = s.excelx_value(row, col) if s.excelx_type(row, col) == [:numeric_or_formula, 'General']
|
42
24
|
cell.strip! if cell.respond_to?(:strip) && import.strip?
|
43
25
|
cell = yield(header, cell) if block_given?
|
44
26
|
data[header] << cell
|
45
|
-
end#row
|
46
|
-
end#col
|
27
|
+
end# row
|
28
|
+
end# col
|
47
29
|
explode_quantities(data, import.explode)
|
48
|
-
end#xlsx
|
30
|
+
end# xlsx
|
49
31
|
module_function :xlsx
|
50
32
|
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
|
54
|
-
# See the example `samples/csv.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
|
55
|
-
#
|
56
|
-
# @example
|
57
|
-
# # File data.csv looks like this (without the comment symbols)
|
58
|
-
# # h1,h2
|
59
|
-
# # 1,2
|
60
|
-
# # 3,4
|
61
|
-
# data = csv file: 'data.csv'
|
62
|
-
# => {'h1' => [1,3], 'h2' => [2,4]}
|
63
|
-
#
|
64
|
-
# Parsing uses Ruby's CSV, with options `{headers: true, converters: :numeric}`
|
65
|
-
# http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html
|
66
|
-
#
|
67
|
-
# @option opts file [String] the CSV-formatted file to open. Opens relative to the current directory.
|
68
|
-
# @option opts strip [Boolean] (true) When true, strips leading and trailing whitespace on values and headers
|
69
|
-
# @option opts explode [String] ('qty') Quantity explosion will be applied to the column this name. See README for example.
|
70
|
-
# @return [Hash] a hash of arrays based on columns in the table
|
71
|
-
# @api public
|
33
|
+
# DSL method. See http://squib.readthedocs.org
|
72
34
|
def csv(opts = {})
|
73
|
-
|
35
|
+
# TODO refactor all this out to separate methods, and its own class
|
74
36
|
import = Args::Import.new.load!(opts)
|
75
|
-
|
37
|
+
file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
|
38
|
+
data = opts.key?(:data) ? opts[:data] : File.read(file)
|
39
|
+
csv_opts = Args::CSV_Opts.new(opts)
|
40
|
+
table = CSV.parse(data, csv_opts.to_hash)
|
76
41
|
check_duplicate_csv_headers(table)
|
77
42
|
hash = Hash.new
|
78
43
|
table.headers.each do |header|
|
@@ -83,10 +48,20 @@ module Squib
|
|
83
48
|
if import.strip?
|
84
49
|
new_hash = Hash.new
|
85
50
|
hash.each do |header, col|
|
86
|
-
new_hash[header] = col.map
|
51
|
+
new_hash[header] = col.map do |str|
|
52
|
+
str = str.strip if str.respond_to?(:strip)
|
53
|
+
str
|
54
|
+
end
|
87
55
|
end
|
88
56
|
hash = new_hash
|
89
57
|
end
|
58
|
+
if block_given?
|
59
|
+
hash.each do |header, col|
|
60
|
+
col.map! do |val|
|
61
|
+
yield(header, val)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
90
65
|
return explode_quantities(hash, import.explode)
|
91
66
|
end
|
92
67
|
module_function :csv
|
@@ -101,6 +76,7 @@ module Squib
|
|
101
76
|
end
|
102
77
|
module_function :check_duplicate_csv_headers
|
103
78
|
|
79
|
+
# @api private
|
104
80
|
def explode_quantities(data, qty)
|
105
81
|
return data unless data.key? qty.to_s.strip
|
106
82
|
qtys = data[qty]
|
@@ -117,12 +93,12 @@ module Squib
|
|
117
93
|
|
118
94
|
class Deck
|
119
95
|
|
120
|
-
#
|
96
|
+
# DSL method. See http://squib.readthedocs.org
|
121
97
|
def xlsx(opts = {})
|
122
98
|
Squib.xlsx(opts)
|
123
99
|
end
|
124
100
|
|
125
|
-
#
|
101
|
+
# DSL method. See http://squib.readthedocs.org
|
126
102
|
def csv(opts = {})
|
127
103
|
Squib.csv(opts)
|
128
104
|
end
|