inversion 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.rdoc +23 -0
  3. data/Manifest.txt +1 -38
  4. data/Rakefile +9 -2
  5. data/lib/inversion.rb +2 -2
  6. data/lib/inversion/template.rb +1 -1
  7. data/lib/inversion/template/begintag.rb +1 -1
  8. data/lib/inversion/template/elsiftag.rb +1 -1
  9. metadata +33 -69
  10. metadata.gz.sig +1 -2
  11. data/History.md +0 -4
  12. data/manual/layouts/default.erb +0 -87
  13. data/manual/lib/api-filter.rb +0 -96
  14. data/manual/lib/editorial-filter.rb +0 -59
  15. data/manual/lib/examples-filter.rb +0 -238
  16. data/manual/lib/links-filter.rb +0 -111
  17. data/manual/resources/css/manual.css +0 -764
  18. data/manual/resources/fonts/GraublauWeb.otf +0 -0
  19. data/manual/resources/fonts/GraublauWebBold.otf +0 -0
  20. data/manual/resources/fonts/Inconsolata.otf +0 -0
  21. data/manual/resources/images/arrow_225_small.png +0 -0
  22. data/manual/resources/images/arrow_315_small.png +0 -0
  23. data/manual/resources/images/arrow_skip.png +0 -0
  24. data/manual/resources/images/cc-by.png +0 -0
  25. data/manual/resources/images/dialog-error.png +0 -0
  26. data/manual/resources/images/dialog-information.png +0 -0
  27. data/manual/resources/images/dialog-warning.png +0 -0
  28. data/manual/resources/images/emblem-important.png +0 -0
  29. data/manual/resources/images/help.png +0 -0
  30. data/manual/resources/images/information.png +0 -0
  31. data/manual/resources/images/magnifier.png +0 -0
  32. data/manual/resources/images/magnifier_left.png +0 -0
  33. data/manual/resources/images/page_white_code.png +0 -0
  34. data/manual/resources/images/page_white_copy.png +0 -0
  35. data/manual/resources/images/printer.png +0 -0
  36. data/manual/resources/images/question.png +0 -0
  37. data/manual/resources/images/scripts_code.png +0 -0
  38. data/manual/resources/images/wrap.png +0 -0
  39. data/manual/resources/images/wrapping.png +0 -0
  40. data/manual/resources/js/jquery-1.4.4.min.js +0 -167
  41. data/manual/resources/js/manual.js +0 -30
  42. data/manual/resources/js/sh.js +0 -580
  43. data/manual/resources/swf/clipboard.swf +0 -0
  44. data/manual/src/examples.page +0 -154
  45. data/manual/src/gettingstarted.page +0 -64
  46. data/manual/src/index.page +0 -97
  47. data/manual/src/tags.page +0 -501
  48. data/manual/src/templates.page +0 -74
@@ -1,96 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # A manual filter to generate links from the Darkfish API.
4
- #
5
- # Authors:
6
- # * Michael Granger <ged@FaerieMUD.org>
7
- # * Mahlon E. Smith <mahlon@martini.nu>
8
- #
9
-
10
-
11
- ### A filter for generating links from the generated API documentation. This allows you to refer
12
- ### to class documentation by simply referencing a class name.
13
- ###
14
- ### Links are XML processing instructions. Pages can be referenced as such:
15
- ###
16
- ### <?api Class::Name ?>
17
- ### <?api Class::Name#instance_method ?>
18
- ### <?api Class::Name.class_method ?>
19
- ###
20
- ### Link text can be overridden, too:
21
- ###
22
- ### <?api "click here":Class::Name ?>
23
- ### <?api "click here":Class::Name#instance_method ?>
24
- ###
25
- class Hoe::ManualGen::APIFilter < Hoe::ManualGen::PageFilter
26
-
27
- # PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
28
- ApiPI = %r{
29
- <\?
30
- api # Instruction Target
31
- \s+
32
- (?:"
33
- (.*?) # Optional link text [$1]
34
- ":)?
35
- (.*?) # Class name [$2]
36
- ([\.#].*?)? # Method anchor [$3]
37
- \s+
38
- \?>
39
- }x
40
-
41
-
42
- ######
43
- public
44
- ######
45
-
46
- ### Process the given +source+ for <?api ... ?> processing-instructions, calling out
47
- def process( source, page, metadata )
48
-
49
- apipath = metadata.api_dir or
50
- raise "The API output directory is not defined in the manual task."
51
-
52
- return source.gsub( ApiPI ) do |match|
53
- # Grab the tag values
54
- link_text = $1
55
- classname = $2
56
- methodname = $3
57
-
58
- self.generate_link( page, apipath, classname, methodname, link_text )
59
- end
60
- end
61
-
62
-
63
- ### Create an HTML link fragment from the parsed ApiPI.
64
- def generate_link( current_page, apipath, classname, methodname=nil, link_text=nil )
65
-
66
- classpath = "%s.html" % [ classname.gsub('::', '/') ]
67
- classfile = apipath + classpath
68
- classuri = current_page.basepath + 'api' + classpath
69
-
70
- if classfile.exist?
71
- return %{<a href="%s%s">%s</a>} % [
72
- classuri,
73
- make_anchor( methodname ),
74
- link_text || (classname + methodname || '')
75
- ]
76
- else
77
- link_text ||= classname
78
- error_message = "Could not find a link for class '%s'" % [ classname ]
79
- $stderr.puts( error_message )
80
- return %{<a href="#" title="#{error_message}" class="broken-link">#{link_text}</a>}
81
- end
82
- end
83
-
84
-
85
- ### Attach a method anchor.
86
- def make_anchor( methodname )
87
- return '' unless methodname
88
-
89
- method_type = methodname[ 0, 1 ]
90
- return "#method-%s-%s" % [
91
- ( method_type == '#' ? 'i' : 'c' ),
92
- methodname[ 1..-1 ]
93
- ]
94
- end
95
- end
96
-
@@ -1,59 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # A manual filter to highlight content that needs editorial help.
4
- #
5
- # Authors:
6
- # * Michael Granger <ged@FaerieMUD.org>
7
- #
8
- #
9
-
10
-
11
-
12
- ### A filter for making editorial marks in manual content.
13
- ###
14
- ### Editorial marks are XML processing instructions. There are several available types of
15
- ### marks:
16
- ###
17
- ### <?ed "This is an editor's note." ?>
18
- ### <?ed verify:"this content needs checking or verification" ?>
19
- ###
20
- class Hoe::ManualGen::EditorialFilter < Hoe::ManualGen::PageFilter
21
-
22
- # PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
23
- LinkPI = %r{
24
- <\?
25
- ed # Instruction Target
26
- \s+
27
- (\w+?) # type of editorial mark [$1]
28
- :? # optional colon
29
- "
30
- (.*?) # content that should be edited [$2]
31
- "
32
- \s*
33
- \?>
34
- }x
35
-
36
-
37
- ######
38
- public
39
- ######
40
-
41
- ### Process the given +source+ for <?ed ... ?> processing-instructions
42
- def process( source, page, metadata )
43
- return source.gsub( LinkPI ) do |match|
44
- # Grab the tag values
45
- mark_type = $1
46
- content = $2
47
-
48
- self.generate_mark( page, mark_type, content )
49
- end
50
- end
51
-
52
-
53
- ### Create an HTML fragment from the parsed LinkPI.
54
- def generate_mark( current_page, mark_type, content )
55
- return "%%(editorial %s-mark)%s%%" % [ mark_type, content ]
56
- end
57
-
58
-
59
- end
@@ -1,238 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # A collection of standard filters for the manual generation tasklib.
4
- #
5
- # Authors:
6
- # Michael Granger <ged@FaerieMUD.org>
7
- #
8
- #
9
-
10
- # Dependencies deferred until #initialize
11
-
12
-
13
-
14
- ### A filter for inline example code or command-line sessions -- does
15
- ### syntax-checking for some languages and captioning.
16
- ###
17
- ### Examples are enclosed in XML processing instructions like so:
18
- ###
19
- ### <?example {language: ruby, testable: true, caption: "A fine example"} ?>
20
- ### a = 1
21
- ### puts a
22
- ### <?end example ?>
23
- ###
24
- ### This will be pulled out into a preformatted section in the HTML,
25
- ### highlighted as Ruby source, checked for valid syntax, and annotated with
26
- ### the specified caption. Valid keys in the example PI are:
27
- ###
28
- ### language::
29
- ### Specifies which (machine) language the example is in.
30
- ### testable::
31
- ### If set and there is a testing function for the given language, run it and append
32
- ### any errors to the output.
33
- ### caption::
34
- ### A small blurb to put below the pulled-out example in the HTML.
35
- class Hoe::ManualGen::ExamplesFilter < Hoe::ManualGen::PageFilter
36
-
37
- DEFAULTS = {
38
- :language => :ruby,
39
- :line_numbers => :inline,
40
- :tab_width => 4,
41
- :hint => :debug,
42
- :testable => false,
43
- }
44
-
45
- # PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
46
- ExamplePI = %r{
47
- <\?
48
- example # Instruction Target
49
- (?: # Optional instruction body
50
- \s+
51
- ((?: # [$1]
52
- [^?]* # Run of anything but a question mark
53
- | # -or-
54
- \?(?!>) # question mark not followed by a closing angle bracket
55
- )*)
56
- )?
57
- \?>
58
- }x
59
-
60
- EndPI = %r{ <\? end (?: \s+ example )? \s* \?> }x
61
-
62
-
63
- ### Defer loading of dependenies until the filter is loaded
64
- def initialize( *args )
65
- begin
66
- require 'pathname'
67
- require 'strscan'
68
- require 'yaml'
69
- require 'rcodetools/xmpfilter'
70
- require 'digest/md5'
71
- require 'tmpdir'
72
- require 'erb'
73
- rescue LoadError => err
74
- unless Object.const_defined?( :Gem )
75
- require 'rubygems'
76
- retry
77
- end
78
-
79
- raise
80
- end
81
- end
82
-
83
-
84
- ######
85
- public
86
- ######
87
-
88
- ### Process the given +source+ for <?example ... ?> processing-instructions, calling out
89
- def process( source, page, metadata )
90
- scanner = StringScanner.new( source )
91
-
92
- buffer = ''
93
- until scanner.eos?
94
- startpos = scanner.pos
95
-
96
- # If we find an example
97
- if scanner.skip_until( ExamplePI )
98
- contents = ''
99
-
100
- # Append the interstitial content to the buffer
101
- if ( scanner.pos - startpos > scanner.matched.length )
102
- offset = scanner.pos - scanner.matched.length - 1
103
- buffer << scanner.string[ startpos..offset ]
104
- end
105
-
106
- # Append everything up to it to the buffer and save the contents of
107
- # the tag
108
- params = scanner[1]
109
-
110
- # Now find the end of the example or complain
111
- contentpos = scanner.pos
112
- scanner.skip_until( EndPI ) or
113
- raise "Unterminated example at line %d" %
114
- [ scanner.string[0..scanner.pos].count("\n") ]
115
-
116
- # Now build the example and append to the buffer
117
- if ( scanner.pos - contentpos > scanner.matched.length )
118
- offset = scanner.pos - scanner.matched.length - 1
119
- contents = scanner.string[ contentpos..offset ]
120
- end
121
-
122
- trace "Processing with params: %p, contents: %p" % [ params, contents ]
123
- buffer << self.process_example( params, contents, page )
124
- else
125
- break
126
- end
127
-
128
- end
129
- buffer << scanner.rest
130
- scanner.terminate
131
-
132
- return buffer
133
- end
134
-
135
-
136
- ### Filter out 'example' macros, doing syntax highlighting, and running
137
- ### 'testable' examples through a validation process appropriate to the
138
- ### language the example is in.
139
- def process_example( params, body, page )
140
- options = self.parse_options( params )
141
- caption = options.delete( :caption )
142
- content = ''
143
- lang = options.delete( :language ).to_s
144
-
145
- # Test it if it's testable
146
- if options[:testable]
147
- content = test_content( body, lang, page )
148
- else
149
- content = body
150
- end
151
-
152
- # Strip trailing blank lines and syntax-highlight
153
- content = highlight( content.strip, options, lang )
154
- caption = %{<div class="caption">} + caption.to_s + %{</div>} if caption
155
-
156
- return %{<notextile><div class="example #{lang}-example">%s%s</div></notextile>} %
157
- [content, caption || '']
158
- end
159
-
160
-
161
- ### Parse an options hash for filtering from the given +args+, which can either
162
- ### be a plain String, in which case it is assumed to be the name of the language the example
163
- ### is in, or a Hash of configuration options.
164
- def parse_options( args )
165
- args = "{ #{args} }" unless args.strip[0] == ?{
166
- args = YAML.load( args )
167
-
168
- # Convert to Symbol keys and value
169
- args.keys.each do |k|
170
- newval = args.delete( k )
171
- next if newval.nil? || (newval.respond_to?(:size) && newval.size == 0)
172
- args[ k.to_sym ] = newval.respond_to?( :to_sym ) ? newval.to_sym : newval
173
- end
174
- return DEFAULTS.merge( args )
175
- end
176
-
177
-
178
- ### Test the given +content+ with a rule specific to the given +language+.
179
- def test_content( body, language, page )
180
- case language.to_sym
181
- when :ruby
182
- return self.test_ruby_content( body, page )
183
-
184
- when :yaml
185
- return self.test_yaml_content( body, page )
186
-
187
- else
188
- return body
189
- end
190
- end
191
-
192
-
193
- ### Test the specified Ruby content for valid syntax
194
- def test_ruby_content( source, page )
195
- # $stderr.puts "Testing ruby content..."
196
- libdir = Pathname.new( __FILE__ ).dirname.parent.parent.parent + 'lib'
197
- extdir = Pathname.new( __FILE__ ).dirname.parent.parent.parent + 'ext'
198
-
199
- options = Rcodetools::XMPFilter::INITIALIZE_OPTS.dup
200
- options[:include_paths] |= [ libdir.to_s, extdir.to_s ]
201
- options[:width] = 60
202
-
203
- if page.config['example_prelude']
204
- prelude = page.config['example_prelude']
205
- trace " prepending prelude:\n#{prelude}"
206
- source = prelude.strip + "\n" + source.strip
207
- else
208
- trace " no prelude; page config is: %p" % [ page.config ]
209
- end
210
-
211
- rval = Rcodetools::XMPFilter.run( source, options )
212
-
213
- trace "test output: ", rval
214
- return rval.join
215
- rescue Exception => err
216
- return "%s while testing: %s\n %s" %
217
- [ err.class.name, err.message, err.backtrace.join("\n ") ]
218
- end
219
-
220
-
221
- ### Test the specified YAML content for valid syntax
222
- def test_yaml_content( source, metadata )
223
- YAML.load( source )
224
- rescue YAML::Error => err
225
- return "# Invalid YAML: " + err.message + "\n" + source
226
- else
227
- return source
228
- end
229
-
230
-
231
- ### Highlights the given +content+ in language +lang+.
232
- def highlight( content, options, lang )
233
- source = ERB::Util.html_escape( content )
234
- return %Q{\n\n<pre class="brush:#{lang}">#{source}</pre>\n\n}
235
- end
236
-
237
- end
238
-
@@ -1,111 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # A manual filter to generate links from the page catalog.
4
- #
5
- # Authors:
6
- # * Michael Granger <ged@FaerieMUD.org>
7
- # * Mahlon E. Smith <mahlon@martini.nu>
8
- #
9
- #
10
-
11
-
12
- ### A filter for generating links from the page catalog. This allows you to refer to other pages
13
- ### in the source and have them automatically updated as the structure of the manual changes.
14
- ###
15
- ### Links are XML processing instructions. Pages can be referenced in one of several ways:
16
- ###
17
- ### <?link Page Title ?>
18
- ### <?link "click here":Page Title ?>
19
- ### <?link Page Title #section_id ?>
20
- ### <?link "click here":Page Title#section_id ?>
21
- ###
22
- ### This first form links to a page by title. Link text defaults to the page title unless an
23
- ### optional quoted string is prepended. If you want to link to an anchor inside the page, include
24
- ### its ID with a hash mark after the title.
25
- ###
26
- ### <?link path/to/Catalog.page ?>
27
- ### <?link "click here":path/to/Catalog.page ?>
28
- ### <?link path/to/Catalog.page#section_id ?>
29
- ### <?link "click here":path/to/Catalog.page#section_id ?>
30
- ###
31
- ### The second form links to a page by its path relative to the base manual source directory.
32
- ### Again, the link text defaults to the page title, or can be overriden via a prepended string,
33
- ### and you can link into a page with an appended ID.
34
- class Hoe::ManualGen::LinksFilter < Hoe::ManualGen::PageFilter
35
-
36
- # PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
37
- LinkPI = %r{
38
- <\?
39
- link # Instruction Target
40
- \s+
41
- (?:"
42
- (.*?) # Optional link text [$1]
43
- ":)?
44
- (.*?) # Title or path [$2]
45
- \s*
46
- (\#[\-\w]+)? # Fragment [$3]
47
- \s+
48
- \?>
49
- }x
50
-
51
-
52
- ######
53
- public
54
- ######
55
-
56
- ### Process the given +source+ for <?link ... ?> processing-instructions, calling out
57
- def process( source, page, metadata )
58
- return source.gsub( LinkPI ) do |match|
59
- # Grab the tag values
60
- link_text = $1
61
- reference = $2
62
- fragment = $3
63
-
64
- self.generate_link( page, reference, link_text, fragment )
65
- end
66
- end
67
-
68
-
69
- ### Create an HTML link fragment from the parsed LinkPI.
70
- def generate_link( current_page, reference, link_text=nil, fragment=nil )
71
-
72
- if other_page = self.find_linked_page( current_page, reference )
73
- href_path = other_page.sourcefile.relative_path_from( current_page.sourcefile.dirname )
74
- href = href_path.to_s.gsub( '.page', '.html' )
75
-
76
- if link_text
77
- return %{<a href="#{href}#{fragment}">#{link_text}</a>}
78
- else
79
- return %{<a href="#{href}#{fragment}">#{other_page.title}</a>}
80
- end
81
- else
82
- link_text ||= reference
83
- error_message = "Could not find a link for reference '%s'" % [ reference ]
84
- $stderr.puts( error_message )
85
- return %{<a href="#" title="#{error_message}" class="broken-link">#{link_text}</a>}
86
- end
87
- end
88
-
89
-
90
- ### Lookup a page +reference+ in the catalog. +reference+ can be either a
91
- ### path to the .page file, relative to the manual root path, or a page title.
92
- ### Returns a matching Page object, or nil if no match is found.
93
- def find_linked_page( current_page, reference )
94
-
95
- catalog = current_page.catalog
96
-
97
- # Lookup by page path
98
- if reference =~ /\.page$/
99
- return catalog.uri_index[ reference ]
100
-
101
- # Lookup by page title
102
- else
103
- return catalog.title_index[ reference ]
104
- end
105
- end
106
- end
107
-
108
-
109
-
110
-
111
-