glyph 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.textile +8 -0
- data/CHANGELOG.textile +260 -0
- data/LICENSE.textile +26 -0
- data/README.textile +49 -21
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/book/config.yml +11 -5
- data/book/document.glyph +24 -13
- data/book/lib/macros/reference.rb +41 -14
- data/book/output/html/glyph.html +2298 -687
- data/book/output/pdf/glyph.pdf +6218 -2698
- data/book/script/authors +1 -0
- data/book/script/changelog +1 -0
- data/book/script/compile.rb +8 -0
- data/book/script/license +1 -0
- data/book/script/prof +1 -0
- data/book/script/prof_results.htm +21079 -0
- data/book/script/readme +1 -0
- data/book/snippets.yml +3 -4
- data/book/text/acknowledgement.glyph +8 -0
- data/book/text/authoring.glyph +548 -0
- data/book/text/changelog.glyph +76 -0
- data/book/text/extending.glyph +224 -0
- data/book/text/{getting_started.textile → getting_started.glyph} +30 -24
- data/book/text/{introduction.textile → introduction.glyph} +22 -12
- data/book/text/license.glyph +21 -0
- data/book/text/{ref_commands.textile → ref_commands.glyph} +30 -8
- data/book/text/ref_config.glyph +108 -0
- data/book/text/ref_macros.glyph +378 -0
- data/book/text/troubleshooting.glyph +179 -0
- data/config.yml +16 -4
- data/glyph.gemspec +83 -22
- data/lib/glyph.rb +164 -31
- data/lib/glyph/commands.rb +98 -23
- data/lib/glyph/document.rb +13 -7
- data/lib/glyph/glyph_language.rb +9 -1
- data/lib/glyph/glyph_language.treetop +1 -1
- data/lib/glyph/interpreter.rb +19 -9
- data/lib/glyph/macro.rb +88 -11
- data/lib/glyph/macro_validators.rb +48 -0
- data/lib/glyph/node.rb +13 -1
- data/lib/glyph/system_extensions.rb +0 -28
- data/macros/common.rb +125 -31
- data/macros/filters.rb +19 -13
- data/macros/html/block.rb +119 -68
- data/macros/html/inline.rb +29 -3
- data/macros/html/structure.rb +40 -40
- data/spec/files/article.glyph +5 -0
- data/spec/lib/commands_spec.rb +98 -3
- data/spec/lib/document_spec.rb +15 -2
- data/spec/lib/glyph_spec.rb +39 -10
- data/spec/lib/interpreter_spec.rb +8 -2
- data/spec/lib/macro_spec.rb +54 -6
- data/spec/lib/macro_validators_spec.rb +33 -0
- data/spec/lib/node_spec.rb +11 -3
- data/spec/macros/filters_spec.rb +5 -5
- data/spec/macros/macros_spec.rb +185 -8
- data/spec/macros/textile_spec.rb +217 -0
- data/spec/spec_helper.rb +25 -15
- data/spec/tasks/generate_spec.rb +3 -3
- data/spec/tasks/load_spec.rb +11 -1
- data/spec/tasks/project_spec.rb +0 -3
- data/styles/coderay.css +121 -0
- data/styles/default.css +54 -20
- data/{book/styles/css3.css → styles/pagination.css} +35 -7
- data/styles/ultraviolet/active4d.css +114 -0
- data/styles/ultraviolet/all_hallows_eve.css +72 -0
- data/styles/ultraviolet/amy.css +147 -0
- data/styles/ultraviolet/blackboard.css +88 -0
- data/styles/ultraviolet/brilliance_black.css +605 -0
- data/styles/ultraviolet/brilliance_dull.css +599 -0
- data/styles/ultraviolet/cobalt.css +149 -0
- data/styles/ultraviolet/dawn.css +121 -0
- data/styles/ultraviolet/eiffel.css +121 -0
- data/styles/ultraviolet/espresso_libre.css +109 -0
- data/styles/ultraviolet/idle.css +62 -0
- data/styles/ultraviolet/iplastic.css +80 -0
- data/styles/ultraviolet/lazy.css +73 -0
- data/styles/ultraviolet/mac_classic.css +123 -0
- data/styles/ultraviolet/magicwb_amiga.css +104 -0
- data/styles/ultraviolet/pastels_on_dark.css +188 -0
- data/styles/ultraviolet/slush_poppies.css +85 -0
- data/styles/ultraviolet/spacecadet.css +51 -0
- data/styles/ultraviolet/sunburst.css +180 -0
- data/styles/ultraviolet/twilight.css +137 -0
- data/styles/ultraviolet/zenburnesque.css +91 -0
- data/tasks/generate.rake +45 -26
- data/tasks/load.rake +21 -18
- data/tasks/project.rake +3 -1
- metadata +210 -41
- data/book/styles/default.css +0 -190
- data/book/text/authoring.textile +0 -351
- data/book/text/extending.textile +0 -148
- data/book/text/ref_config.textile +0 -0
- data/book/text/ref_macros.textile +0 -256
- data/book/text/troubleshooting.textile +0 -118
- data/styles/css3.css +0 -220
@@ -0,0 +1,179 @@
|
|
1
|
+
This chapter lists the most common error messages that can be returned when running a Glyph command. It does not aim to be an exhaustive list, especially if you =>[#extending|extended] Glyph by creating your own macros or you're embedding Ruby code using the %>[ruby] macro.
|
2
|
+
|
3
|
+
tip[As a general rule, more diagnostic information is provided if Glyph is run in =>[#debug_switch|debug mode].]
|
4
|
+
|
5
|
+
section[header[Generic Errors]
|
6
|
+
|
7
|
+
error_table[
|
8
|
+
ref_error[Incorrect macro syntax|
|
9
|
+
This error is returned if the parsing of the document (or one of its included files) failed. In 99% of the cases, this means there is an extra or missing macro delimiter somewhere.
|
10
|
+
]
|
11
|
+
ref_error[Invalid alias: macro '_macro-name_' already exists|
|
12
|
+
The alias name supplied to the @macro_alias@ method has already been used for another macro or alias.
|
13
|
+
]
|
14
|
+
ref_error[Undefined macro '_macro-name_'|
|
15
|
+
The document contains a macro that does not exist, i.e. it is not a standard or used-defined =>[#macro_ref|Glyph macro or alias].
|
16
|
+
]
|
17
|
+
ref_error[An error occurred when generating _file-name_.pdf|
|
18
|
+
Returned if Prince could not generate the PDF file or if Prince is not installed. Normally, Prince provides additional details on the specific error(s).
|
19
|
+
]
|
20
|
+
ref_error[Glyph cannot generate PDF. Please specify a valid tools.pdf_generator setting|
|
21
|
+
Returned if the $>[tools.pdf_generator] has not be set to a valid PDF renderer. Currently, the only supported value for this setting is @prince@.
|
22
|
+
]
|
23
|
+
ref_error[The current directory is not a valid Glyph project|
|
24
|
+
Returned if a glyph command was executed outside a valid glyph project directory.
|
25
|
+
]
|
26
|
+
ref_error[Invalid snippet file|
|
27
|
+
The @snippet.yml@ file contains invalid data. Most likely, it does not evaluate to a Ruby @Hash@.
|
28
|
+
]
|
29
|
+
ref_error[Directory '_directory-name_' is not empty|
|
30
|
+
Returned when executing the #>[init] in a directory that is not empty.
|
31
|
+
]
|
32
|
+
ref_error[File '_file-name_' already exists|
|
33
|
+
Returned if the name of an existing file was specified as a parameter for the #>[add].
|
34
|
+
]
|
35
|
+
]
|
36
|
+
] --[End Generic Errors]
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
section[header[Command Errors]
|
41
|
+
|
42
|
+
error_table[
|
43
|
+
|
44
|
+
ref_error[Source file '_source-file_' does not exist|
|
45
|
+
Returned if Glyph is running in =>[#lite_mode|lite mode] and the specified source file was not found.
|
46
|
+
]
|
47
|
+
|
48
|
+
ref_error[Source and destination file are the same|
|
49
|
+
Returned if Glyph is running in =>[#lite_mode|lite mode] and you specified the same source and destination files.
|
50
|
+
]
|
51
|
+
|
52
|
+
ref_error[DirectoryWatcher is not available. Install it with: gem install directory_watcher|
|
53
|
+
Returned if =>[#auto_regeneration|auto regeneration] is enabled but the @directory_watcher@ gem in not installed.
|
54
|
+
]
|
55
|
+
|
56
|
+
ref_error[Document cannot be finalized due to previous errors|
|
57
|
+
Returned if one or more errors occurred in the document prevented finalization.
|
58
|
+
]
|
59
|
+
|
60
|
+
ref_error[Please specify a file name|
|
61
|
+
No file name was specified for the #>[add].
|
62
|
+
]
|
63
|
+
|
64
|
+
ref_error[Output target not specified|
|
65
|
+
Returned if no target was specified for the #>[compile] _and_ if the $>[document.output] is not set.
|
66
|
+
]
|
67
|
+
|
68
|
+
ref_error[Unknown output target '_target-name_'|
|
69
|
+
An unsupported output target was specified for the #>[compile]. Only the following output targets are supported:
|
70
|
+
- @html@
|
71
|
+
- @pdf@
|
72
|
+
]
|
73
|
+
|
74
|
+
ref_error[Too few/too many arguments|
|
75
|
+
Returned if the #>[config] was used with no arguments or more than two arguments respectively.
|
76
|
+
]
|
77
|
+
|
78
|
+
ref_error[Unknown setting '_setting-name_'|
|
79
|
+
The name of an unknown setting was specified for the #>[config].
|
80
|
+
]
|
81
|
+
]
|
82
|
+
] --[End Command Errors]
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
section[header[Macro Errors]
|
87
|
+
|
88
|
+
The following errors are displayed in the form:
|
89
|
+
|
90
|
+
_message_
|
91
|
+
-> source: _macro-source_
|
92
|
+
-> path: _macro-path_
|
93
|
+
-> value: _macro-value_
|
94
|
+
|
95
|
+
Where:
|
96
|
+
* _message_ is the error message.
|
97
|
+
* _macro-source_ is the file or snippet where the error occurred.
|
98
|
+
* _macro-path_ is the full path to the macro that returned the error, within the document syntax tree, e.g. @document/body/bodymatter/chapter/section/header/&@ if the error occurrent in a snippet within the header of a section in the @bodymatter@ part of the document.
|
99
|
+
* _macro-value_ is the value of the macro (shown only if Glyph is running in =>[#debug_switch|debug mode]).
|
100
|
+
|
101
|
+
error_table[
|
102
|
+
|
103
|
+
ref_error[Macro '_name_' takes up to _x_ parameter(s) (_y_ given)|
|
104
|
+
Returned if the macro was called with extra parameters.
|
105
|
+
]
|
106
|
+
|
107
|
+
ref_error[Macro '_name_' takes at least _x_ parameter(s) (_y_ given)|
|
108
|
+
Returned if the macro was called with fewer parameters than expected.
|
109
|
+
]
|
110
|
+
|
111
|
+
ref_error[Macro '_name_' takes exactly _x_ parameter(s) (_y_ given)|
|
112
|
+
Returned if the macro was called with a different number of parameters than.
|
113
|
+
]
|
114
|
+
|
115
|
+
ref_error[Macro not available when compiling a single file.|
|
116
|
+
Returned by the %>[include] if used in =>[#lite_mode|lite mode].
|
117
|
+
]
|
118
|
+
|
119
|
+
ref_error[Filter macro '_extension_' not available|
|
120
|
+
Returned by a filter macro if $>[filters.by_file_extension] is set to @true@, but the extension was not recognized.
|
121
|
+
]
|
122
|
+
|
123
|
+
ref_error[Invalid regular expression: _regexp_|
|
124
|
+
Returned by the %>[match] macro if an invalid regular expression was supplied.
|
125
|
+
]
|
126
|
+
|
127
|
+
ref_error[Macro '_name_' takes no parameters (_x_ given)|
|
128
|
+
Returned if the macro was called with parameters but none are requested.
|
129
|
+
]
|
130
|
+
|
131
|
+
ref_error[No highlighter installed. Please run: gem install coderay|
|
132
|
+
Returned by the %>[highlight] macro if no highlighters are installed.
|
133
|
+
]
|
134
|
+
|
135
|
+
ref_error[CodeRay highlighter not installed. Please run: gem install coderay|
|
136
|
+
Returned by the %>[highlight] macro if $>[highlighters.current] is set to @coderay@ but &[coderay] is not installed.
|
137
|
+
]
|
138
|
+
|
139
|
+
ref_error[UltraViolet highlighter not installed. Please run: gem install ultraviolet|
|
140
|
+
Returned by the %>[highlight] macro if $>[highlighters.current] is set to @ultraviolet@ but &[uv] is not installed.
|
141
|
+
]
|
142
|
+
|
143
|
+
ref_error[Mutual inclusion|
|
144
|
+
Returned if a catch-22 situation occurs with macro inclusion, for example if the body of a snippet includes a reference to the same snippet.
|
145
|
+
]
|
146
|
+
ref_error[Snippet '_snippet-id_' does not exist|
|
147
|
+
Returned by the %>[snippet] if an invalid snippet was supplied.
|
148
|
+
]
|
149
|
+
ref_error[File '_file-name_' not found|
|
150
|
+
Returned by the %>[include] if an invalid file was supplied.
|
151
|
+
]
|
152
|
+
ref_error[Filter macro '_macro-name_' not found|
|
153
|
+
Returned by the %>[include] macro if the $>[filters.by_file_extension] is set to @true@ but the file extension of the included file is not recognized as a filter macro.
|
154
|
+
]
|
155
|
+
ref_error[RedCloth gem not installed. Please run: gem insall RedCloth|
|
156
|
+
Returned by the %>[textile] if the RedCloth gem is not installed.
|
157
|
+
]
|
158
|
+
ref_error[No MarkDown converter installed. Please run: gem insall bluecloth|
|
159
|
+
Returned by the %>[markdown] if no valid Markdown converter gem is installed.
|
160
|
+
|
161
|
+
Glyph checks for: BlueCloth, Maruku, Kramdown and RDiscount.
|
162
|
+
]
|
163
|
+
ref_error[Image/Figure not found|
|
164
|
+
Retured by the %>[img] or the %>[fig] respectively, if the specified image file could not be found within the @images/@ folder.
|
165
|
+
]
|
166
|
+
ref_error[Bookmark '_bookmark-name_' already exists|
|
167
|
+
Returned by the %>[anchor] or by the %>[header] if the anchor ID supplied as parameter has already been used in the document.
|
168
|
+
]
|
169
|
+
ref_error[Bookmark '_bookmark-name_' already exists|
|
170
|
+
Returned by the %>[link] if the anchor ID supplied as parameter has not been used in the document.
|
171
|
+
]
|
172
|
+
ref_error[Stylesheet '_file-name_' not found|
|
173
|
+
Returned by the %>[style] if the @.css@ or @.sass@ file supplied as parameter was not found in the @styles/@ directory.
|
174
|
+
]
|
175
|
+
ref_error[Haml is not installed. Please run: gem install haml|
|
176
|
+
Returned by the %>[style] if a @.sass@ file was passed as parameter but the Haml gem is not installed.
|
177
|
+
]
|
178
|
+
]
|
179
|
+
] --[End Macro Errors]
|
data/config.yml
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
:source: 'document.glyph'
|
3
3
|
:author: ""
|
4
4
|
:title: ""
|
5
|
+
:subtitle: ""
|
5
6
|
:filename: ""
|
6
|
-
:
|
7
|
+
:draft: false
|
8
|
+
:output: 'html'
|
7
9
|
:output_targets: [:html, :pdf]
|
8
10
|
:structure:
|
9
11
|
:hidden:
|
@@ -14,9 +16,7 @@
|
|
14
16
|
- :colophon
|
15
17
|
- :promotion
|
16
18
|
:special:
|
17
|
-
- :preface
|
18
19
|
- :foreword
|
19
|
-
- :introduction
|
20
20
|
- :acknowledgement
|
21
21
|
- :prologue
|
22
22
|
- :epilogue
|
@@ -55,9 +55,21 @@
|
|
55
55
|
- :index
|
56
56
|
- :lot
|
57
57
|
- :lof
|
58
|
-
:
|
58
|
+
:tools:
|
59
|
+
:pdf_generator: 'prince'
|
60
|
+
:highlighters:
|
61
|
+
:target: 'html'
|
62
|
+
:current: 'coderay'
|
63
|
+
:coderay:
|
64
|
+
# See options at http://coderay.rubychan.de/doc/classes/CodeRay/Encoders/HTML.html
|
65
|
+
:css: :class
|
66
|
+
:ultraviolet:
|
67
|
+
:line_numbers: false
|
68
|
+
:theme: 'blackboard'
|
59
69
|
:filters:
|
60
70
|
:by_file_extension: true
|
61
71
|
:target: 'html'
|
72
|
+
:markdown:
|
73
|
+
:converter: 'bluecloth'
|
62
74
|
:redcloth:
|
63
75
|
:restrictions: []
|
data/glyph.gemspec
CHANGED
@@ -5,20 +5,24 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{glyph}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Fabio Cevasco"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-09}
|
13
13
|
s.default_executable = %q{glyph}
|
14
14
|
s.description = %q{Glyph is a framework for structured document authoring.}
|
15
15
|
s.email = %q{h3rald@h3rald.com}
|
16
16
|
s.executables = ["glyph"]
|
17
17
|
s.extra_rdoc_files = [
|
18
|
-
"
|
18
|
+
"LICENSE.textile",
|
19
|
+
"README.textile"
|
19
20
|
]
|
20
21
|
s.files = [
|
21
|
-
"
|
22
|
+
"AUTHORS.textile",
|
23
|
+
"CHANGELOG.textile",
|
24
|
+
"LICENSE.textile",
|
25
|
+
"README.textile",
|
22
26
|
"Rakefile",
|
23
27
|
"VERSION",
|
24
28
|
"bin/glyph",
|
@@ -31,17 +35,25 @@ Gem::Specification.new do |s|
|
|
31
35
|
"book/output/html/images/glyph.png",
|
32
36
|
"book/output/html/images/glyph.svg",
|
33
37
|
"book/output/pdf/glyph.pdf",
|
38
|
+
"book/script/authors",
|
39
|
+
"book/script/changelog",
|
40
|
+
"book/script/compile.rb",
|
41
|
+
"book/script/license",
|
42
|
+
"book/script/prof",
|
43
|
+
"book/script/prof_results.htm",
|
44
|
+
"book/script/readme",
|
34
45
|
"book/snippets.yml",
|
35
|
-
"book/
|
36
|
-
"book/
|
37
|
-
"book/text/
|
38
|
-
"book/text/extending.
|
39
|
-
"book/text/getting_started.
|
40
|
-
"book/text/introduction.
|
41
|
-
"book/text/
|
42
|
-
"book/text/
|
43
|
-
"book/text/
|
44
|
-
"book/text/
|
46
|
+
"book/text/acknowledgement.glyph",
|
47
|
+
"book/text/authoring.glyph",
|
48
|
+
"book/text/changelog.glyph",
|
49
|
+
"book/text/extending.glyph",
|
50
|
+
"book/text/getting_started.glyph",
|
51
|
+
"book/text/introduction.glyph",
|
52
|
+
"book/text/license.glyph",
|
53
|
+
"book/text/ref_commands.glyph",
|
54
|
+
"book/text/ref_config.glyph",
|
55
|
+
"book/text/ref_macros.glyph",
|
56
|
+
"book/text/troubleshooting.glyph",
|
45
57
|
"config.yml",
|
46
58
|
"document.glyph",
|
47
59
|
"glyph.gemspec",
|
@@ -53,6 +65,7 @@ Gem::Specification.new do |s|
|
|
53
65
|
"lib/glyph/glyph_language.treetop",
|
54
66
|
"lib/glyph/interpreter.rb",
|
55
67
|
"lib/glyph/macro.rb",
|
68
|
+
"lib/glyph/macro_validators.rb",
|
56
69
|
"lib/glyph/node.rb",
|
57
70
|
"lib/glyph/system_extensions.rb",
|
58
71
|
"macros/common.rb",
|
@@ -60,6 +73,7 @@ Gem::Specification.new do |s|
|
|
60
73
|
"macros/html/block.rb",
|
61
74
|
"macros/html/inline.rb",
|
62
75
|
"macros/html/structure.rb",
|
76
|
+
"spec/files/article.glyph",
|
63
77
|
"spec/files/container.textile",
|
64
78
|
"spec/files/document.glyph",
|
65
79
|
"spec/files/document_with_toc.glyph",
|
@@ -73,15 +87,39 @@ Gem::Specification.new do |s|
|
|
73
87
|
"spec/lib/glyph_spec.rb",
|
74
88
|
"spec/lib/interpreter_spec.rb",
|
75
89
|
"spec/lib/macro_spec.rb",
|
90
|
+
"spec/lib/macro_validators_spec.rb",
|
76
91
|
"spec/lib/node_spec.rb",
|
77
92
|
"spec/macros/filters_spec.rb",
|
78
93
|
"spec/macros/macros_spec.rb",
|
94
|
+
"spec/macros/textile_spec.rb",
|
79
95
|
"spec/spec_helper.rb",
|
80
96
|
"spec/tasks/generate_spec.rb",
|
81
97
|
"spec/tasks/load_spec.rb",
|
82
98
|
"spec/tasks/project_spec.rb",
|
83
|
-
"styles/
|
99
|
+
"styles/coderay.css",
|
84
100
|
"styles/default.css",
|
101
|
+
"styles/pagination.css",
|
102
|
+
"styles/ultraviolet/active4d.css",
|
103
|
+
"styles/ultraviolet/all_hallows_eve.css",
|
104
|
+
"styles/ultraviolet/amy.css",
|
105
|
+
"styles/ultraviolet/blackboard.css",
|
106
|
+
"styles/ultraviolet/brilliance_black.css",
|
107
|
+
"styles/ultraviolet/brilliance_dull.css",
|
108
|
+
"styles/ultraviolet/cobalt.css",
|
109
|
+
"styles/ultraviolet/dawn.css",
|
110
|
+
"styles/ultraviolet/eiffel.css",
|
111
|
+
"styles/ultraviolet/espresso_libre.css",
|
112
|
+
"styles/ultraviolet/idle.css",
|
113
|
+
"styles/ultraviolet/iplastic.css",
|
114
|
+
"styles/ultraviolet/lazy.css",
|
115
|
+
"styles/ultraviolet/mac_classic.css",
|
116
|
+
"styles/ultraviolet/magicwb_amiga.css",
|
117
|
+
"styles/ultraviolet/pastels_on_dark.css",
|
118
|
+
"styles/ultraviolet/slush_poppies.css",
|
119
|
+
"styles/ultraviolet/spacecadet.css",
|
120
|
+
"styles/ultraviolet/sunburst.css",
|
121
|
+
"styles/ultraviolet/twilight.css",
|
122
|
+
"styles/ultraviolet/zenburnesque.css",
|
85
123
|
"tasks/generate.rake",
|
86
124
|
"tasks/load.rake",
|
87
125
|
"tasks/project.rake"
|
@@ -89,15 +127,17 @@ Gem::Specification.new do |s|
|
|
89
127
|
s.homepage = %q{http://www.h3rald.com/glyph/}
|
90
128
|
s.rdoc_options = ["--charset=UTF-8"]
|
91
129
|
s.require_paths = ["lib"]
|
92
|
-
s.rubygems_version = %q{1.3.
|
130
|
+
s.rubygems_version = %q{1.3.6}
|
93
131
|
s.summary = %q{Glyph -- A Ruby-powered Document Authoring Framework}
|
94
132
|
s.test_files = [
|
95
133
|
"spec/macros/filters_spec.rb",
|
134
|
+
"spec/macros/textile_spec.rb",
|
96
135
|
"spec/macros/macros_spec.rb",
|
97
136
|
"spec/lib/interpreter_spec.rb",
|
98
137
|
"spec/lib/commands_spec.rb",
|
99
138
|
"spec/lib/node_spec.rb",
|
100
139
|
"spec/lib/macro_spec.rb",
|
140
|
+
"spec/lib/macro_validators_spec.rb",
|
101
141
|
"spec/lib/config_spec.rb",
|
102
142
|
"spec/lib/glyph_spec.rb",
|
103
143
|
"spec/lib/document_spec.rb",
|
@@ -116,23 +156,44 @@ Gem::Specification.new do |s|
|
|
116
156
|
s.add_runtime_dependency(%q<extlib>, [">= 0.9.12"])
|
117
157
|
s.add_runtime_dependency(%q<treetop>, [">= 0.4.3"])
|
118
158
|
s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
|
119
|
-
s.add_development_dependency(%q<rspec>, [">=
|
120
|
-
s.add_development_dependency(%q<yard>, [">=
|
159
|
+
s.add_development_dependency(%q<rspec>, [">= 1.1.11"])
|
160
|
+
s.add_development_dependency(%q<yard>, [">= 1.5.4"])
|
161
|
+
s.add_development_dependency(%q<jeweler>, ["= 1.4.0"])
|
162
|
+
s.add_development_dependency(%q<directory_watcher>, [">= 1.3.2"])
|
163
|
+
s.add_development_dependency(%q<haml>, [">= 2.2.3"])
|
164
|
+
s.add_development_dependency(%q<RedCloth>, [">= 4.2.3"])
|
165
|
+
s.add_development_dependency(%q<bluecloth>, [">= 2.0.7"])
|
166
|
+
s.add_development_dependency(%q<coderay>, [">= 0.9.3"])
|
167
|
+
s.add_development_dependency(%q<ruby-prof>, [">= 0.8.1"])
|
121
168
|
else
|
122
169
|
s.add_dependency(%q<gli>, [">= 0.3.1"])
|
123
170
|
s.add_dependency(%q<extlib>, [">= 0.9.12"])
|
124
171
|
s.add_dependency(%q<treetop>, [">= 0.4.3"])
|
125
172
|
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
126
|
-
s.add_dependency(%q<rspec>, [">=
|
127
|
-
s.add_dependency(%q<yard>, [">=
|
173
|
+
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
174
|
+
s.add_dependency(%q<yard>, [">= 1.5.4"])
|
175
|
+
s.add_dependency(%q<jeweler>, ["= 1.4.0"])
|
176
|
+
s.add_dependency(%q<directory_watcher>, [">= 1.3.2"])
|
177
|
+
s.add_dependency(%q<haml>, [">= 2.2.3"])
|
178
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.3"])
|
179
|
+
s.add_dependency(%q<bluecloth>, [">= 2.0.7"])
|
180
|
+
s.add_dependency(%q<coderay>, [">= 0.9.3"])
|
181
|
+
s.add_dependency(%q<ruby-prof>, [">= 0.8.1"])
|
128
182
|
end
|
129
183
|
else
|
130
184
|
s.add_dependency(%q<gli>, [">= 0.3.1"])
|
131
185
|
s.add_dependency(%q<extlib>, [">= 0.9.12"])
|
132
186
|
s.add_dependency(%q<treetop>, [">= 0.4.3"])
|
133
187
|
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
134
|
-
s.add_dependency(%q<rspec>, [">=
|
135
|
-
s.add_dependency(%q<yard>, [">=
|
188
|
+
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
189
|
+
s.add_dependency(%q<yard>, [">= 1.5.4"])
|
190
|
+
s.add_dependency(%q<jeweler>, ["= 1.4.0"])
|
191
|
+
s.add_dependency(%q<directory_watcher>, [">= 1.3.2"])
|
192
|
+
s.add_dependency(%q<haml>, [">= 2.2.3"])
|
193
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.3"])
|
194
|
+
s.add_dependency(%q<bluecloth>, [">= 2.0.7"])
|
195
|
+
s.add_dependency(%q<coderay>, [">= 0.9.3"])
|
196
|
+
s.add_dependency(%q<ruby-prof>, [">= 0.8.1"])
|
136
197
|
end
|
137
198
|
end
|
138
199
|
|
data/lib/glyph.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (c) 2009-2010 Fabio Cevasco
|
2
2
|
# website: http://www.h3rald.com/glyph
|
3
|
-
# license:
|
3
|
+
# license: MIT
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'pathname'
|
@@ -13,47 +13,76 @@ require 'rake'
|
|
13
13
|
# Glyph is a Rapid Document Authoring Framework able to produce structured documents effortlessly.
|
14
14
|
module Glyph
|
15
15
|
|
16
|
+
# The directory containing Glyph library files
|
16
17
|
LIB = Pathname(__FILE__).dirname.expand_path/'glyph'
|
17
18
|
|
19
|
+
# The directory containing the full Glyph installation
|
18
20
|
HOME = LIB/'../../'
|
19
21
|
|
22
|
+
# The directory containing all Glyph tests
|
23
|
+
SPEC_DIR = Pathname(__FILE__).dirname.expand_path/'../spec'
|
24
|
+
|
25
|
+
# The directory containing all Glyph Rake tasks
|
26
|
+
TASKS_DIR = Pathname(__FILE__).dirname.expand_path/'../tasks'
|
27
|
+
|
20
28
|
require LIB/'system_extensions'
|
21
29
|
require LIB/'config'
|
22
30
|
require LIB/'node'
|
23
31
|
require LIB/'document'
|
24
32
|
require LIB/'glyph_language'
|
33
|
+
require LIB/'macro_validators'
|
25
34
|
require LIB/'macro'
|
26
35
|
require LIB/'interpreter'
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
TASKS_DIR = Pathname(__FILE__).dirname.expand_path/'../tasks'
|
37
|
+
class Error < RuntimeError; end
|
38
|
+
class SyntaxError < Error; end
|
39
|
+
class MacroError < Error; end
|
40
|
+
class MutualInclusionError < MacroError; end
|
33
41
|
|
34
|
-
|
42
|
+
# The current version of Glyph
|
43
|
+
VERSION = file_load(HOME/'VERSION').strip
|
35
44
|
|
45
|
+
# All the currently-loaded snippets
|
36
46
|
SNIPPETS = {}
|
37
47
|
|
48
|
+
# All the currently-loaded macros
|
38
49
|
MACROS = {}
|
39
50
|
|
40
|
-
|
51
|
+
begin
|
52
|
+
unless const_defined? :MODE then
|
53
|
+
# Glyph's modes: debug/lite/test
|
54
|
+
MODE = {:debug => false, :lite => false, :test => false, :library => false}
|
55
|
+
end
|
56
|
+
rescue
|
57
|
+
end
|
41
58
|
|
42
|
-
|
59
|
+
# The main document being generated by Glyph
|
60
|
+
@@document = nil
|
43
61
|
|
44
|
-
|
45
|
-
|
46
|
-
|
62
|
+
(class << self; self; end).instance_eval do
|
63
|
+
["test", "lite", "debug", "library"].each do |mode|
|
64
|
+
define_method((mode+"?").to_sym) do
|
65
|
+
MODE[mode.to_sym]
|
66
|
+
end
|
67
|
+
define_method((mode+"_mode=")) do |m|
|
68
|
+
MODE[mode.to_sym] = m
|
69
|
+
end
|
70
|
+
end
|
47
71
|
end
|
48
72
|
|
49
|
-
|
73
|
+
# The directory of the current Glyph project.
|
74
|
+
PROJECT = (Glyph.test?) ? Glyph::SPEC_DIR/"test_project" : Pathname.new(Dir.pwd)
|
50
75
|
|
76
|
+
# Glyph's configuration
|
51
77
|
CONFIG = Glyph::Config.new :resettable => true, :mutable => false
|
52
78
|
|
53
79
|
home_dir = Pathname.new(RUBY_PLATFORM.match(/win32|mingw/) ? ENV['HOMEPATH'] : ENV['HOME'])
|
54
|
-
SYSTEM_CONFIG =
|
55
|
-
|
56
|
-
|
80
|
+
SYSTEM_CONFIG =
|
81
|
+
Glyph::Config.new(:file => HOME/'config.yml')
|
82
|
+
GLOBAL_CONFIG =
|
83
|
+
Glyph.test? ? Glyph::Config.new(:file => SPEC_DIR/'.glyphrc') : Glyph::Config.new(:file => home_dir/'.glyphrc')
|
84
|
+
PROJECT_CONFIG =
|
85
|
+
Glyph::Config.new(:file => PROJECT/'config.yml', :resettable => true) rescue Glyph::Config.new(:resettable => true, :mutable => true)
|
57
86
|
|
58
87
|
# Loads all Rake tasks
|
59
88
|
def self.setup
|
@@ -62,34 +91,72 @@ module Glyph
|
|
62
91
|
end
|
63
92
|
end
|
64
93
|
|
94
|
+
# Used to access @@document
|
95
|
+
def self.document
|
96
|
+
@@document
|
97
|
+
end
|
98
|
+
|
99
|
+
# Used to set @@document
|
100
|
+
def self.document=(document)
|
101
|
+
@@document = document
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the value of a configuration setting
|
105
|
+
def self.[](setting)
|
106
|
+
Glyph::CONFIG.get(setting)
|
107
|
+
end
|
108
|
+
|
65
109
|
# Overrides a configuration setting
|
66
|
-
# @param
|
110
|
+
# @param [String, Symbol] setting the configuration setting to change
|
67
111
|
# @param value the new value
|
68
|
-
def self.
|
112
|
+
def self.[]=(setting, value)
|
69
113
|
PROJECT_CONFIG.set setting, value
|
70
|
-
|
114
|
+
self.config_refresh
|
71
115
|
end
|
72
116
|
|
73
|
-
#
|
74
|
-
def self.
|
117
|
+
# Restores Glyph configuration (keeping all overrides and project settings)
|
118
|
+
def self.config_refresh
|
75
119
|
CONFIG.merge!(SYSTEM_CONFIG.merge(GLOBAL_CONFIG.merge(PROJECT_CONFIG)))
|
76
120
|
end
|
77
121
|
|
122
|
+
# Resets Glyph configuration (removing all overrides and project settings)
|
123
|
+
def self.config_reset
|
124
|
+
Glyph::CONFIG.reset
|
125
|
+
Glyph::PROJECT_CONFIG.reset
|
126
|
+
self.config_refresh
|
127
|
+
end
|
128
|
+
|
78
129
|
# Returns true if the PROJECT constant is set to a valid Glyph project directory
|
79
130
|
def self.project?
|
80
|
-
children = ["
|
131
|
+
children = ["text", "output", "snippets.yml", "config.yml", "document.glyph"].sort
|
81
132
|
actual_children = PROJECT.children.map{|c| c.basename.to_s}.sort
|
82
133
|
(actual_children & children) == children
|
83
134
|
end
|
84
135
|
|
85
|
-
#
|
86
|
-
#
|
136
|
+
# Resets Glyph completely, i.e.:
|
137
|
+
# * Re-enables all Glyph Rake tasks
|
138
|
+
# * Resets the configuration to system defaults
|
139
|
+
# * Clears macros and snippets
|
140
|
+
def self.reset
|
141
|
+
self.enable_all
|
142
|
+
self.config_reset
|
143
|
+
MACROS.clear
|
144
|
+
SNIPPETS.clear
|
145
|
+
end
|
146
|
+
|
147
|
+
# Reenables all Glyph Rake tasks
|
148
|
+
def self.enable_all
|
149
|
+
Rake::Task.tasks.each {|t| t.reenable }
|
150
|
+
end
|
151
|
+
|
152
|
+
# Reenables a Rake task
|
153
|
+
# @param [Symbol, String] task the task to enable
|
87
154
|
def self.enable(task)
|
88
155
|
Rake::Task[task].reenable
|
89
156
|
end
|
90
157
|
|
91
158
|
# Reenables and runs a Rake task
|
92
|
-
# @param task the task to
|
159
|
+
# @param [Symbol, String] task the task to run
|
93
160
|
# @param *args the task arguments
|
94
161
|
def self.run!(task, *args)
|
95
162
|
Rake::Task[task].reenable
|
@@ -97,32 +164,98 @@ module Glyph
|
|
97
164
|
end
|
98
165
|
|
99
166
|
# Runs a Rake task
|
100
|
-
# @param task the task to
|
167
|
+
# @param [Symbol, String] task the task to run
|
101
168
|
# @param *args the task arguments
|
102
169
|
def self.run(task, *args)
|
103
170
|
Rake::Task[task].invoke *args
|
104
171
|
end
|
105
172
|
|
106
173
|
# Defines a new macro
|
107
|
-
# @param
|
174
|
+
# @param [Symbol, String] name the name of the macro
|
108
175
|
def self.macro(name, &block)
|
109
|
-
MACROS[name] = block
|
176
|
+
MACROS[name.to_sym] = block
|
110
177
|
end
|
111
178
|
|
112
179
|
# Defines an alias for an existing macro
|
113
|
-
# @param [Hash]
|
180
|
+
# @param [Hash] text the single-key hash defining the alias
|
114
181
|
# @example
|
115
182
|
# {:old_name => :new_name}
|
116
183
|
def self.macro_alias(pair)
|
117
184
|
name = pair.keys[0].to_sym
|
118
185
|
found = MACROS[name]
|
119
186
|
if found then
|
120
|
-
warning "Invalid alias: macro '#{name}' already exists."
|
187
|
+
self.warning "Invalid alias: macro '#{name}' already exists."
|
121
188
|
return
|
122
189
|
end
|
123
190
|
MACROS[name] = MACROS[pair.values[0].to_sym]
|
124
191
|
end
|
125
|
-
|
192
|
+
|
193
|
+
# Compiles a single Glyph file
|
194
|
+
# @param [String] src the full or relative path to the source file
|
195
|
+
# @param [String] out the full or relative path to the output file
|
196
|
+
def self.compile(src, out=nil)
|
197
|
+
pwd = Dir.pwd
|
198
|
+
Dir.chdir Pathname.new(src).parent.to_s
|
199
|
+
begin
|
200
|
+
require 'glyph/commands'
|
201
|
+
self[:quiet] = true
|
202
|
+
self.library_mode = true
|
203
|
+
GLI.run ["compile", src.to_s, out].compact
|
204
|
+
rescue Exception => e
|
205
|
+
raise
|
206
|
+
ensure
|
207
|
+
Dir.chdir pwd
|
208
|
+
self.library_mode = false
|
209
|
+
self.lite_mode = false
|
210
|
+
self[:quiet] = false
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Converts a text containing Glyph markup language into the current Glyph output target.
|
215
|
+
#
|
216
|
+
# *Note* Only 'html' is supported as output target for now.
|
217
|
+
# @param [String] text the text to convert
|
218
|
+
# @return [String] the converted text
|
219
|
+
# @example
|
220
|
+
# require 'glyph'
|
221
|
+
# Glyph.filter "section[header[Test]\nA Test section...]"
|
222
|
+
def self.filter(text)
|
223
|
+
self.lite_mode = true
|
224
|
+
self.enable_all
|
225
|
+
result = ""
|
226
|
+
begin
|
227
|
+
self[:quiet] = true
|
228
|
+
self.library_mode = true
|
229
|
+
self.run 'load:all'
|
230
|
+
result = Interpreter.new(text).document.output
|
231
|
+
rescue Exception => e
|
232
|
+
raise
|
233
|
+
ensure
|
234
|
+
self.lite_mode = false
|
235
|
+
self.library_mode = false
|
236
|
+
self[:quiet] = false
|
237
|
+
end
|
238
|
+
result
|
239
|
+
end
|
240
|
+
|
241
|
+
# Prints a message
|
242
|
+
# @param [String] message the message to print
|
243
|
+
def self.info(message)
|
244
|
+
puts "#{message}" unless Glyph[:quiet]
|
245
|
+
end
|
246
|
+
|
247
|
+
# Prints a warning
|
248
|
+
# @param [String] message the message to print
|
249
|
+
def self.warning(message)
|
250
|
+
puts "--> warning: #{message}" unless Glyph[:quiet]
|
251
|
+
end
|
252
|
+
|
253
|
+
# Prints an error
|
254
|
+
# @param [String] message the message to print
|
255
|
+
def self.error(message)
|
256
|
+
puts "==> error: #{message}" unless Glyph[:quiet]
|
257
|
+
end
|
258
|
+
|
126
259
|
end
|
127
260
|
|
128
261
|
Glyph.setup
|