mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# YAML::YamlNode class
|
3
|
+
#
|
4
|
+
require 'yaml/basenode'
|
5
|
+
|
6
|
+
module YAML
|
7
|
+
|
8
|
+
#
|
9
|
+
# YAML Generic Model container
|
10
|
+
#
|
11
|
+
class YamlNode
|
12
|
+
include BaseNode
|
13
|
+
attr_accessor :kind, :type_id, :value, :anchor
|
14
|
+
def initialize( t, v )
|
15
|
+
@type_id = t
|
16
|
+
if Hash === v
|
17
|
+
@kind = 'map'
|
18
|
+
@value = {}
|
19
|
+
v.each { |k,v|
|
20
|
+
@value[ k.transform ] = [ k, v ]
|
21
|
+
}
|
22
|
+
elsif Array === v
|
23
|
+
@kind = 'seq'
|
24
|
+
@value = v
|
25
|
+
elsif String === v
|
26
|
+
@kind = 'scalar'
|
27
|
+
@value = v
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Transform this node fully into a native type
|
33
|
+
#
|
34
|
+
def transform
|
35
|
+
t = nil
|
36
|
+
if @value.is_a? Hash
|
37
|
+
t = {}
|
38
|
+
@value.each { |k,v|
|
39
|
+
t[ k ] = v[1].transform
|
40
|
+
}
|
41
|
+
elsif @value.is_a? Array
|
42
|
+
t = []
|
43
|
+
@value.each { |v|
|
44
|
+
t.push v.transform
|
45
|
+
}
|
46
|
+
else
|
47
|
+
t = @value
|
48
|
+
end
|
49
|
+
YAML.transfer_method( @type_id, t )
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# YAML::YPath
|
3
|
+
#
|
4
|
+
|
5
|
+
module YAML
|
6
|
+
|
7
|
+
class YPath
|
8
|
+
attr_accessor :segments, :predicates, :flags
|
9
|
+
def initialize( str )
|
10
|
+
@segments = []
|
11
|
+
@predicates = []
|
12
|
+
@flags = nil
|
13
|
+
while str =~ /^\/?(\/|[^\/\[]+)(?:\[([^\]]+)\])?/
|
14
|
+
@segments.push $1
|
15
|
+
@predicates.push $2
|
16
|
+
str = $'
|
17
|
+
end
|
18
|
+
unless str.to_s.empty?
|
19
|
+
@segments += str.split( "/" )
|
20
|
+
end
|
21
|
+
if @segments.length == 0
|
22
|
+
@segments.push "."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
def YPath.each_path( str )
|
26
|
+
#
|
27
|
+
# Find choices
|
28
|
+
#
|
29
|
+
paths = []
|
30
|
+
str = "(#{ str })"
|
31
|
+
while str.sub!( /\(([^()]+)\)/, "\n#{ paths.length }\n" )
|
32
|
+
paths.push $1.split( '|' )
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Construct all possible paths
|
37
|
+
#
|
38
|
+
all = [ str ]
|
39
|
+
( paths.length - 1 ).downto( 0 ) do |i|
|
40
|
+
all = all.collect do |a|
|
41
|
+
paths[i].collect do |p|
|
42
|
+
a.gsub( /\n#{ i }\n/, p )
|
43
|
+
end
|
44
|
+
end.flatten.uniq
|
45
|
+
end
|
46
|
+
all.collect do |path|
|
47
|
+
yield YPath.new( path )
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,1168 @@
|
|
1
|
+
# vim:sw=4:ts=4
|
2
|
+
# $Id: yod.rb,v 1.1 2003/03/20 13:25:38 whythluckystiff Exp $
|
3
|
+
#
|
4
|
+
# YOD: Yaml Ok Documentation
|
5
|
+
#
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
#
|
9
|
+
# Hi. Yod is... well... something. Okay, look.
|
10
|
+
# It's a personal project for building documentation.
|
11
|
+
# It's also meant to be an example project. To give
|
12
|
+
# a more complete example of YAML's use.
|
13
|
+
#
|
14
|
+
module Yod
|
15
|
+
|
16
|
+
VERSION = '0.2'
|
17
|
+
SECTION_GIF =<<EOF
|
18
|
+
R0lGODlhCQAMAMYAAERFP0NEPj0+OEFCPEhJQ0pLRTw9N1NUTlZXUVhZU1xd
|
19
|
+
V1laVDY3MVFSTWRlYIeIg5WWkZOUj19gWz9AO1hZVG9wa6Kjnri5tLGyrbCx
|
20
|
+
rLS1sD0+OVVWUW1uaaanor/Au8DBvHN0bzk6NVlaVXBxbKeoo76/urq7tsPE
|
21
|
+
v3d4c0BBPExLSWFgXpGQjqOioJybmWdmZDg3NURDQVdWVIB/fYyLiYKBf4OC
|
22
|
+
gFtaWDMyMD49O0dGRGBfXXJxb25ta0pJRzIxLzk4Nj08Ok1MSlVUUlJRT1RT
|
23
|
+
UUVEQi4tKygkJS8rLDIuLy4qKy0pKjEtLjUxMiEdHicjJCwoKSsnKCklJjQw
|
24
|
+
Mf//////////////////////////////////////////////////////////
|
25
|
+
////////////////////////////////////////////////////////////
|
26
|
+
/////////////////////////////////////////////////yH+FUNyZWF0
|
27
|
+
ZWQgd2l0aCBUaGUgR0lNUAAsAAAAAAkADAAAB22AAAABAgMEAQUEBgAHCAkK
|
28
|
+
CwAMDQ4PEBGYEhMUFRYXGBkaFRscHR4fFxcgISIjJCUmFycoKSorLC0uLy8u
|
29
|
+
MDEyMzQ1NjQ3ODk6Ozw9PT4+P0BBQkMzREVGR0hJSUpLTE1OT1BRSVJTSVRM
|
30
|
+
VVGBADs=
|
31
|
+
EOF
|
32
|
+
|
33
|
+
TEXT_CSS =<<EOF
|
34
|
+
.sectionhead {
|
35
|
+
background-color : #667788;
|
36
|
+
color: white;
|
37
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
38
|
+
padding: 5px;
|
39
|
+
border-bottom : 1. solid;
|
40
|
+
font-weight: bold;
|
41
|
+
}
|
42
|
+
.contentshead {
|
43
|
+
background-color : black;
|
44
|
+
color: white;
|
45
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
46
|
+
padding: 5px;
|
47
|
+
border-bottom : 1. solid;
|
48
|
+
font-weight: bold;
|
49
|
+
width: 130%;
|
50
|
+
}
|
51
|
+
.quickhead {
|
52
|
+
background-color : white;
|
53
|
+
color: black;
|
54
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
55
|
+
padding: 10px 5px 5px 5px;
|
56
|
+
border-bottom : 1. solid;
|
57
|
+
font-weight: bold;
|
58
|
+
}
|
59
|
+
.functionhead {
|
60
|
+
background-color : #333344;
|
61
|
+
color: white;
|
62
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
63
|
+
padding: 5px;
|
64
|
+
border-bottom : 1. solid;
|
65
|
+
font-weight: bold;
|
66
|
+
}
|
67
|
+
.indent1 { margin-left:12pt; margin-right:12pt;}
|
68
|
+
.indent2 { margin-left:24pt;margin-right:24pt; }
|
69
|
+
.indent3 { margin-left:36pt; margin-right:24pt;}
|
70
|
+
Th {
|
71
|
+
font-style : italic;
|
72
|
+
font-size : x-small;
|
73
|
+
font-weight : normal;
|
74
|
+
background-color : #DCDCDC;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
BLOCKQUOTE {
|
79
|
+
margin-left : 30;
|
80
|
+
margin-right : 30;
|
81
|
+
color: #112233;
|
82
|
+
}
|
83
|
+
|
84
|
+
.function {
|
85
|
+
font-weight : bold;
|
86
|
+
font-size : larger;
|
87
|
+
margin-top : 8;
|
88
|
+
margin-left : 12pt;
|
89
|
+
margin-bottom: 5px;
|
90
|
+
}
|
91
|
+
|
92
|
+
.welcomehead {
|
93
|
+
background-color : #333333;
|
94
|
+
color: white;
|
95
|
+
width : 100%;
|
96
|
+
padding : 5;
|
97
|
+
border-bottom : 1 solid;
|
98
|
+
text-align : left;
|
99
|
+
vertical-align : middle;
|
100
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
101
|
+
font-size : medium;
|
102
|
+
font-weight : bold;
|
103
|
+
}
|
104
|
+
|
105
|
+
p
|
106
|
+
{
|
107
|
+
margin-left : 15;
|
108
|
+
margin-right : 15;
|
109
|
+
}
|
110
|
+
|
111
|
+
.summarytable
|
112
|
+
{
|
113
|
+
margin-left: 15;
|
114
|
+
margin-right: 15;
|
115
|
+
border-width: 1px;
|
116
|
+
border-color: ACACAC;
|
117
|
+
border-width: solid;
|
118
|
+
}
|
119
|
+
UL
|
120
|
+
{
|
121
|
+
margin-top: 0px;
|
122
|
+
}
|
123
|
+
TD,body
|
124
|
+
{
|
125
|
+
margin-left : 0;
|
126
|
+
margin-right : 0;
|
127
|
+
margin-top : 0;
|
128
|
+
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
|
129
|
+
font-size : x-small;
|
130
|
+
vertical-align : top;
|
131
|
+
}
|
132
|
+
|
133
|
+
TD
|
134
|
+
{
|
135
|
+
padding-left:12pt;
|
136
|
+
}
|
137
|
+
|
138
|
+
.codeblock
|
139
|
+
{
|
140
|
+
margin-left: 20;
|
141
|
+
margin-right: 20;
|
142
|
+
background-color : #EFEFEF;
|
143
|
+
font-family : "Courier New", Courier, monospace;;
|
144
|
+
padding : 4;
|
145
|
+
font-size: 10pt;
|
146
|
+
}
|
147
|
+
DL {
|
148
|
+
margin-left : 12pt;
|
149
|
+
margin-right : 12pt;
|
150
|
+
margin-top: 3;
|
151
|
+
}
|
152
|
+
DT
|
153
|
+
{
|
154
|
+
margin-left:12pt; margin-right:12pt;
|
155
|
+
font-style : italic;
|
156
|
+
}
|
157
|
+
|
158
|
+
.keyword
|
159
|
+
{
|
160
|
+
color: #0000FF;
|
161
|
+
}
|
162
|
+
|
163
|
+
.func
|
164
|
+
{
|
165
|
+
color: #FF0000;
|
166
|
+
}
|
167
|
+
EOF
|
168
|
+
LEFT = 10
|
169
|
+
CENTER = 20
|
170
|
+
RIGHT = 30
|
171
|
+
|
172
|
+
class Error < StandardError; end
|
173
|
+
|
174
|
+
class Document
|
175
|
+
|
176
|
+
attr_accessor :table_of_contents, :contents, :title, :author, :version
|
177
|
+
|
178
|
+
def initialize( data )
|
179
|
+
@contents = {}
|
180
|
+
data.each_pair { |key, val|
|
181
|
+
if key == "Table of Contents"
|
182
|
+
@table_of_contents = val
|
183
|
+
elsif key == "Title"
|
184
|
+
@title = val
|
185
|
+
elsif key == "Author"
|
186
|
+
@author = val
|
187
|
+
elsif key == "Version"
|
188
|
+
@version = val
|
189
|
+
elsif val.is_a?( Yod::DocElement )
|
190
|
+
val.title = key
|
191
|
+
@contents[key] = val
|
192
|
+
else
|
193
|
+
raise Yod::Error, "Invalid Document node #{key} is not a Page or Group."
|
194
|
+
end
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
def pages
|
199
|
+
@table_of_contents.collect { |x|
|
200
|
+
@contents[x].pages
|
201
|
+
}.flatten
|
202
|
+
end
|
203
|
+
|
204
|
+
def index
|
205
|
+
index_all = {}
|
206
|
+
@table_of_contents.each { |x|
|
207
|
+
index_all.update( @contents[x].index ) if @contents[x].respond_to? :index
|
208
|
+
}
|
209
|
+
index_all.sort
|
210
|
+
end
|
211
|
+
|
212
|
+
def to_man( *args )
|
213
|
+
page = args.shift
|
214
|
+
case page
|
215
|
+
when :Make
|
216
|
+
output, name = args
|
217
|
+
|
218
|
+
File.open( output, "w" ) { |f|
|
219
|
+
f.write( <<HEADER )
|
220
|
+
.TH #{title.upcase} 3 "#{Time.now.strftime( '%d %F %Y' )}"
|
221
|
+
.SH NAME
|
222
|
+
#{@title}
|
223
|
+
HEADER
|
224
|
+
@table_of_contents.each_with_index { |x, i|
|
225
|
+
f.write( @contents[x].to_man( :Page, 0 ) )
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def to_pdf( *args )
|
233
|
+
page = args.shift
|
234
|
+
case page
|
235
|
+
when :Make
|
236
|
+
output = args.shift
|
237
|
+
require "ClibPDF"
|
238
|
+
|
239
|
+
pdf = ClibPDF::PDF.open( 0 )
|
240
|
+
pdf.enableCompression( ClibPDF::YES )
|
241
|
+
pdf.init
|
242
|
+
pdf.setTitle( @title )
|
243
|
+
pdf.pageInit(1, ClibPDF::PORTRAIT, ClibPDF::LETTER, ClibPDF::LETTER)
|
244
|
+
|
245
|
+
titleBase = 6.5
|
246
|
+
pdf.beginText( 0 )
|
247
|
+
pdf.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 20.0)
|
248
|
+
pdf.textAligned( 4.4, titleBase, 0.0, ClibPDF::TEXTPOS_MM, @title )
|
249
|
+
pdf.endText
|
250
|
+
|
251
|
+
pdf.setgray(0.0)
|
252
|
+
pdf.setlinewidth(0.2)
|
253
|
+
pdf.moveto(1.0, titleBase - 0.5)
|
254
|
+
pdf.lineto(7.8, titleBase - 0.5)
|
255
|
+
pdf.stroke
|
256
|
+
|
257
|
+
if @author
|
258
|
+
pdf.beginText( 0 )
|
259
|
+
pdf.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 14.0)
|
260
|
+
pdf.textAligned( 4.4, titleBase - 0.8, 0.0, ClibPDF::TEXTPOS_MM, "by #{@author}" )
|
261
|
+
pdf.endText
|
262
|
+
end
|
263
|
+
|
264
|
+
if @version
|
265
|
+
pdf.beginText( 0 )
|
266
|
+
pdf.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 10.0)
|
267
|
+
pdf.textAligned( 4.4, titleBase - 1.2, 0.0, ClibPDF::TEXTPOS_MM, "[Version #{@version}]" )
|
268
|
+
pdf.endText
|
269
|
+
end
|
270
|
+
|
271
|
+
pdf.pageInit(2, ClibPDF::PORTRAIT, ClibPDF::LETTER, ClibPDF::LETTER)
|
272
|
+
pdf.beginText( 0 )
|
273
|
+
pdf.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 14.0)
|
274
|
+
pdf.text(1.0, 10.4, 0.0, "Table of Contents")
|
275
|
+
pdf.endText
|
276
|
+
|
277
|
+
pdf.setgray(0.0)
|
278
|
+
pdf.setlinewidth(0.2)
|
279
|
+
pdf.moveto(1.0, 10.2)
|
280
|
+
pdf.lineto(7.8, 10.2)
|
281
|
+
pdf.stroke
|
282
|
+
|
283
|
+
pdf.beginText( 0 )
|
284
|
+
pdf.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 10.0)
|
285
|
+
pdf.setTextLeading(12.0)
|
286
|
+
pdf.setTextPosition(1.0, 10.0)
|
287
|
+
self.to_pdf( :TableOfContents, pdf )
|
288
|
+
pdf.endText
|
289
|
+
|
290
|
+
def pdf.initPara( title )
|
291
|
+
@guts = {
|
292
|
+
:page => 2,
|
293
|
+
:y => 0.0,
|
294
|
+
:title => title,
|
295
|
+
:sections => []
|
296
|
+
}
|
297
|
+
end
|
298
|
+
def pdf.textPara( fontName, fontSize, fontAlign, indent, ybump, textchunk, force_page = false )
|
299
|
+
if force_page
|
300
|
+
@guts[:y] = 0.0
|
301
|
+
end
|
302
|
+
begint = false
|
303
|
+
textchunk.split( /\n/ ).each do |text|
|
304
|
+
j = 0
|
305
|
+
j_p = 0
|
306
|
+
line_width = ( 6.6 - ( indent * 2.0 ) ) * ClibPDF::INCH
|
307
|
+
self.setFont( fontName, "MacRomanEncoding", fontSize )
|
308
|
+
while j = text.index( /\s/, j ) or text.length.nonzero?
|
309
|
+
unless j
|
310
|
+
j = -1
|
311
|
+
j_p = -1
|
312
|
+
end
|
313
|
+
if j < 0 or self.stringWidth( text[ 0..j-1 ] ) > line_width
|
314
|
+
|
315
|
+
if @guts[:y] < 0.6 # Start a new page
|
316
|
+
if begint
|
317
|
+
self.endText
|
318
|
+
begint = false
|
319
|
+
end
|
320
|
+
@guts[:page] += 1
|
321
|
+
@guts[:y] = 10.2
|
322
|
+
self.pageInit( @guts[:page], ClibPDF::PORTRAIT, ClibPDF::LETTER, ClibPDF::LETTER)
|
323
|
+
|
324
|
+
self.beginText( 0 )
|
325
|
+
self.setFont( "NewCenturySchlbk-Roman", "MacRomanEncoding", 10.0)
|
326
|
+
self.text(1.0, 0.2, 0.0, @guts[:title])
|
327
|
+
self.textAligned( 7.8, 0.2, 0.0, ClibPDF::TEXTPOS_MR, "Page #{@guts[:page]}" )
|
328
|
+
self.endText
|
329
|
+
|
330
|
+
self.setgray(0.0)
|
331
|
+
self.setlinewidth(0.2)
|
332
|
+
self.moveto(1.0, 0.4)
|
333
|
+
self.lineto(7.8, 0.4)
|
334
|
+
self.stroke
|
335
|
+
end
|
336
|
+
|
337
|
+
#
|
338
|
+
# Set the font
|
339
|
+
#
|
340
|
+
unless begint
|
341
|
+
self.beginText( 0 )
|
342
|
+
self.setFont( fontName, "MacRomanEncoding", fontSize )
|
343
|
+
begint = true
|
344
|
+
end
|
345
|
+
|
346
|
+
line = text[ 0..j_p ]
|
347
|
+
# self.text( 1.0 + indent, @guts[:y], 0.0, line )
|
348
|
+
align = ClibPDF::TEXTPOS_ML
|
349
|
+
origin = 1.0 + indent
|
350
|
+
if fontAlign == RIGHT
|
351
|
+
align = ClibPDF::TEXTPOS_MR
|
352
|
+
origin = 7.8 - indent
|
353
|
+
elsif fontAlign == CENTER
|
354
|
+
align = ClibPDF::TEXTPOS_MM
|
355
|
+
origin = 4.4
|
356
|
+
end
|
357
|
+
self.textAligned( origin, @guts[:y], 0.0, align, line )
|
358
|
+
if j_p > 0
|
359
|
+
text = text[ j_p + 2..-1 ]
|
360
|
+
else
|
361
|
+
text = ""
|
362
|
+
end
|
363
|
+
j = 0
|
364
|
+
j_p = 0
|
365
|
+
@guts[:y] -= ybump
|
366
|
+
next
|
367
|
+
end
|
368
|
+
j_p = j - 1
|
369
|
+
j += 1
|
370
|
+
end
|
371
|
+
end
|
372
|
+
self.newline
|
373
|
+
if begint
|
374
|
+
self.endText
|
375
|
+
end
|
376
|
+
end
|
377
|
+
def pdf.newline
|
378
|
+
@guts[:y] -= 0.15
|
379
|
+
end
|
380
|
+
pdf.initPara( @title )
|
381
|
+
|
382
|
+
@table_of_contents.each_with_index { |x, i|
|
383
|
+
@contents[x].to_pdf( :Page, pdf, [ i + 1 ] )
|
384
|
+
}
|
385
|
+
|
386
|
+
pdf.finalizeAll
|
387
|
+
pdf.savePDFmemoryStreamToFile( output )
|
388
|
+
pdf.close()
|
389
|
+
|
390
|
+
when :TableOfContents
|
391
|
+
pdf = args.shift
|
392
|
+
@table_of_contents.each_with_index { |x, i|
|
393
|
+
@contents[x].to_pdf( :TableOfContents, pdf, i + 1 )
|
394
|
+
}
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
def to_chm( *args )
|
399
|
+
page = args.shift
|
400
|
+
case page
|
401
|
+
when :MakeAll
|
402
|
+
output, prefix = args
|
403
|
+
Yod.multi_mkdir( output, 0755 )
|
404
|
+
|
405
|
+
# Write the INI
|
406
|
+
File.open( File.join( output, "#{prefix}.hhp" ), "w" ) { |f|
|
407
|
+
f.write( self.to_chm( :IniFile, prefix ) )
|
408
|
+
}
|
409
|
+
|
410
|
+
# Write the bullet GIF
|
411
|
+
File.open( File.join( output, "section.gif" ), "w" ) { |f|
|
412
|
+
f.write( Yod::SECTION_GIF.unpack( "m*" )[0] )
|
413
|
+
}
|
414
|
+
|
415
|
+
# Write the CSS
|
416
|
+
File.open( File.join( output, "global.css" ), "w" ) { |f|
|
417
|
+
f.write( Yod::TEXT_CSS )
|
418
|
+
}
|
419
|
+
|
420
|
+
# Write the Index
|
421
|
+
File.open( File.join( output, "Index.hhk" ), "w" ) { |f|
|
422
|
+
f.write( self.to_chm( :Index ) )
|
423
|
+
}
|
424
|
+
|
425
|
+
# Write the TOC
|
426
|
+
File.open( File.join( output, "Table of Contents.hhc" ), "w" ) { |f|
|
427
|
+
f.write( self.to_chm( :TableOfContents ) )
|
428
|
+
}
|
429
|
+
|
430
|
+
# Write each page of the manual
|
431
|
+
self.pages.each { |p|
|
432
|
+
Yod.multi_mkdir( output + File::SEPARATOR +
|
433
|
+
p.html_file_name.split( File::SEPARATOR )[0], 0755 )
|
434
|
+
File.open( File.join( output, p.html_file_name ), "w" ) { |f|
|
435
|
+
f.write( p.to_chm( :Html ) )
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
when :IniFile
|
440
|
+
prefix = args.shift
|
441
|
+
page_list = self.pages.collect { |p| p.html_file_name }
|
442
|
+
return <<EOF
|
443
|
+
[OPTIONS]
|
444
|
+
Binary Index=No
|
445
|
+
Binary TOC=Yes
|
446
|
+
Compatibility=1.1 or later
|
447
|
+
Compiled file=#{prefix}.chm
|
448
|
+
Contents file=Table of Contents.hhc
|
449
|
+
Create CHI file=Yes
|
450
|
+
Default topic=#{page_list.first}
|
451
|
+
Display compile progress=No
|
452
|
+
Index file=Index.hhk
|
453
|
+
Language=0x409 English (United States)
|
454
|
+
Title=#{@title}
|
455
|
+
|
456
|
+
|
457
|
+
[FILES]
|
458
|
+
#{page_list.join( "\n" )}
|
459
|
+
|
460
|
+
[INFOTYPES]
|
461
|
+
Category:Bitmaps
|
462
|
+
CategoryDesc:
|
463
|
+
EOF
|
464
|
+
when :Index
|
465
|
+
index_content = self.index.collect { |item| <<EOF
|
466
|
+
<LI> <OBJECT type="text/sitemap">
|
467
|
+
<param name="Name" value="#{item[0]}">
|
468
|
+
<param name="Local" value="#{item[1]}">
|
469
|
+
</OBJECT>
|
470
|
+
EOF
|
471
|
+
}
|
472
|
+
return <<EOF
|
473
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
474
|
+
<HTML>
|
475
|
+
<HEAD>
|
476
|
+
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
477
|
+
<!-- Sitemap 1.0 -->
|
478
|
+
</HEAD><BODY>
|
479
|
+
<UL>
|
480
|
+
#{index_content}
|
481
|
+
</UL>
|
482
|
+
</BODY></HTML>
|
483
|
+
EOF
|
484
|
+
when :TableOfContents
|
485
|
+
return <<EOF
|
486
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
487
|
+
<HTML>
|
488
|
+
<HEAD>
|
489
|
+
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
490
|
+
<!-- Sitemap 1.0 -->
|
491
|
+
</HEAD><BODY>
|
492
|
+
<OBJECT type="text/site properties">
|
493
|
+
<param name="Window Styles" value="0x800025">
|
494
|
+
</OBJECT>
|
495
|
+
<UL>
|
496
|
+
#{@table_of_contents.collect { |x| @contents[x].to_chm( :TableOfContents ) }}
|
497
|
+
</UL>
|
498
|
+
</BODY></HTML>
|
499
|
+
EOF
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
503
|
+
def to_html( *args )
|
504
|
+
page = args.shift
|
505
|
+
case page
|
506
|
+
when :MakeAll
|
507
|
+
output = args.shift
|
508
|
+
Yod.multi_mkdir( output, 0755 )
|
509
|
+
|
510
|
+
# Write the bullet GIF
|
511
|
+
File.open( File.join( output, "section.gif" ), "w" ) { |f|
|
512
|
+
f.write( Yod::SECTION_GIF.unpack( "m*" )[0] )
|
513
|
+
}
|
514
|
+
|
515
|
+
# Write the CSS
|
516
|
+
File.open( File.join( output, "global.css" ), "w" ) { |f|
|
517
|
+
f.write( Yod::TEXT_CSS )
|
518
|
+
}
|
519
|
+
|
520
|
+
# Write the Index frame
|
521
|
+
File.open( File.join( output, "index.html" ), "w" ) { |f|
|
522
|
+
f.write( self.to_html( :Frame ) )
|
523
|
+
}
|
524
|
+
|
525
|
+
# Write the TOC
|
526
|
+
File.open( File.join( output, "contents.html" ), "w" ) { |f|
|
527
|
+
f.write( self.to_html( :TableOfContents ) )
|
528
|
+
}
|
529
|
+
|
530
|
+
# Write each page of the manual
|
531
|
+
self.pages.each { |p|
|
532
|
+
Yod.multi_mkdir( output + File::SEPARATOR +
|
533
|
+
p.html_file_name.split( File::SEPARATOR )[0], 0755 )
|
534
|
+
File.open( File.join( output, p.html_file_name ), "w" ) { |f|
|
535
|
+
f.write( p.to_html( :Html ) )
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
when :Frame
|
540
|
+
prefix = args.shift
|
541
|
+
page_list = self.pages.collect { |p| p.html_file_name }
|
542
|
+
return <<EOF
|
543
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
|
544
|
+
"http://www.w3.org/TR/html4/frameset.dtd">
|
545
|
+
<HTML>
|
546
|
+
<HEAD>
|
547
|
+
<TITLE>#{@title}</TITLE>
|
548
|
+
</HEAD>
|
549
|
+
<FRAMESET cols="200,*">
|
550
|
+
<FRAME src="contents.html">
|
551
|
+
<FRAME name="docview" src="#{page_list.first}">
|
552
|
+
</FRAMESET>
|
553
|
+
</HTML>
|
554
|
+
EOF
|
555
|
+
|
556
|
+
when :TableOfContents
|
557
|
+
return <<EOF
|
558
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
559
|
+
<HTML>
|
560
|
+
<HEAD>
|
561
|
+
<meta name="GENERATOR" content="Yod #{Yod::VERSION}">
|
562
|
+
<link href="global.css" type="text/css" rel="stylesheet">
|
563
|
+
</HEAD><BODY>
|
564
|
+
<div class="contentshead">CONTENTS</div>
|
565
|
+
<p>
|
566
|
+
#{@table_of_contents.collect { |x| @contents[x].to_html( :TableOfContents ) }}
|
567
|
+
</p>
|
568
|
+
</BODY></HTML>
|
569
|
+
EOF
|
570
|
+
end
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
class DocElement; attr_accessor :title, :elements; def pages; self; end; end
|
575
|
+
|
576
|
+
class Group < DocElement
|
577
|
+
def initialize( data )
|
578
|
+
@elements = []
|
579
|
+
data.each { |ele|
|
580
|
+
name, ele = ele.to_a[0]
|
581
|
+
if ele.is_a?( Yod::DocElement )
|
582
|
+
ele.title = name
|
583
|
+
@elements << ele
|
584
|
+
else
|
585
|
+
raise Yod::Error, "Invalid node of type #{ele.class} in Group: " + ele.inspect
|
586
|
+
end
|
587
|
+
}
|
588
|
+
end
|
589
|
+
|
590
|
+
def pages
|
591
|
+
self.elements.collect { |e|
|
592
|
+
e.pages
|
593
|
+
}
|
594
|
+
end
|
595
|
+
|
596
|
+
def index
|
597
|
+
index_all = {}
|
598
|
+
self.elements.each { |e|
|
599
|
+
index_all.update( e.index ) if e.respond_to? :index
|
600
|
+
}
|
601
|
+
index_all
|
602
|
+
end
|
603
|
+
|
604
|
+
def to_man( *args )
|
605
|
+
page = args.shift
|
606
|
+
case page
|
607
|
+
when :Page
|
608
|
+
depth = args.shift
|
609
|
+
if depth.zero?
|
610
|
+
str = ".SH #{self.title}\n"
|
611
|
+
else
|
612
|
+
str = ".Sh #{self.title}\n"
|
613
|
+
end
|
614
|
+
self.elements.each { |e|
|
615
|
+
str += e.to_man( :Page, depth + 1 )
|
616
|
+
}
|
617
|
+
str
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
def to_pdf( *args )
|
622
|
+
page = args.shift
|
623
|
+
case page
|
624
|
+
when :TableOfContents
|
625
|
+
pdf, idx = args
|
626
|
+
pdf.textCRLFshow( "#{idx}. #{self.title}" )
|
627
|
+
self.elements.each_with_index { |e, i|
|
628
|
+
e.to_pdf( :TableOfContents, pdf, "#{idx}.#{i+1}" )
|
629
|
+
}
|
630
|
+
when :Page
|
631
|
+
pdf, idx = args
|
632
|
+
size = 22.0 - ( idx.length * 2.0 )
|
633
|
+
if size < 14.0
|
634
|
+
size = 14.0
|
635
|
+
end
|
636
|
+
pdf.newline
|
637
|
+
pdf.textPara( "NewCenturySchlbk-Roman", size, LEFT, 0.0, 0.4,
|
638
|
+
"#{idx.join('.')}. #{self.title}", idx.length == 1 )
|
639
|
+
self.elements.each_with_index { |e, i|
|
640
|
+
e.to_pdf( :Page, pdf, [ idx ] + [ i + 1 ] )
|
641
|
+
}
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
def to_chm( page )
|
646
|
+
case page
|
647
|
+
when :TableOfContents
|
648
|
+
return <<EOF
|
649
|
+
<LI> <OBJECT type="text/sitemap">
|
650
|
+
<param name="Name" value="#{self.title}">
|
651
|
+
</OBJECT>
|
652
|
+
<UL>
|
653
|
+
#{self.elements.collect { |e| e.to_chm( :TableOfContents ) }}
|
654
|
+
</UL>
|
655
|
+
EOF
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
def to_html( page )
|
660
|
+
case page
|
661
|
+
when :TableOfContents
|
662
|
+
return <<EOF
|
663
|
+
<LI> <B>#{self.title}</B>
|
664
|
+
<UL>
|
665
|
+
#{self.elements.collect { |e| e.to_html( :TableOfContents ) }}
|
666
|
+
</UL>
|
667
|
+
EOF
|
668
|
+
end
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
class Page < DocElement
|
673
|
+
def initialize( data )
|
674
|
+
@elements = []
|
675
|
+
data.each { |ele|
|
676
|
+
if ele.is_a?( Yod::PageElement )
|
677
|
+
@elements << ele
|
678
|
+
else
|
679
|
+
raise Yod::Error, "Invalid node of type #{ele.class} in Page: " + ele.inspect
|
680
|
+
end
|
681
|
+
}
|
682
|
+
end
|
683
|
+
|
684
|
+
def html_file_name
|
685
|
+
"page" + File::SEPARATOR + @title.downcase.gsub( /[^A-Za-z0-9]/, '_' ) + ".htm"
|
686
|
+
end
|
687
|
+
|
688
|
+
def index
|
689
|
+
index_all = { @title => self.html_file_name }
|
690
|
+
end
|
691
|
+
|
692
|
+
def to_man( *args )
|
693
|
+
page = args.shift
|
694
|
+
case page
|
695
|
+
when :Page
|
696
|
+
depth = args.shift
|
697
|
+
if depth.zero?
|
698
|
+
str = ".SH #{self.title}\n"
|
699
|
+
else
|
700
|
+
str = ".Sh #{self.title}\n"
|
701
|
+
end
|
702
|
+
self.elements.collect { |e|
|
703
|
+
str += e.to_man
|
704
|
+
}
|
705
|
+
str
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
def to_pdf( *args )
|
710
|
+
page = args.shift
|
711
|
+
case page
|
712
|
+
when :TableOfContents
|
713
|
+
pdf, idx = args
|
714
|
+
pdf.textCRLFshow( "#{idx}. #{self.title}" )
|
715
|
+
when :Page
|
716
|
+
pdf, idx = args
|
717
|
+
size = 22.0 - ( idx.length * 2.0 )
|
718
|
+
if size < 14.0
|
719
|
+
size = 14.0
|
720
|
+
end
|
721
|
+
pdf.newline
|
722
|
+
pdf.textPara( "NewCenturySchlbk-Roman", size, LEFT, 0.0, 0.4,
|
723
|
+
"#{idx.join('.')}. #{self.title}", idx.length == 1 )
|
724
|
+
self.elements.collect { |e|
|
725
|
+
e.to_pdf( pdf )
|
726
|
+
}
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
730
|
+
def to_chm( page )
|
731
|
+
case page
|
732
|
+
when :TableOfContents
|
733
|
+
return <<EOF
|
734
|
+
<LI> <OBJECT type="text/sitemap">
|
735
|
+
<param name="Name" value="#{@title}">
|
736
|
+
<param name="Local" value="#{self.html_file_name}">
|
737
|
+
</OBJECT>
|
738
|
+
EOF
|
739
|
+
when :Html
|
740
|
+
return self.to_html( :Html )
|
741
|
+
end
|
742
|
+
end
|
743
|
+
|
744
|
+
def to_html( page )
|
745
|
+
case page
|
746
|
+
when :TableOfContents
|
747
|
+
return <<EOF
|
748
|
+
<LI> <A HREF="#{self.html_file_name}" TARGET="docview">#{@title}</A>
|
749
|
+
EOF
|
750
|
+
when :Html
|
751
|
+
return <<EOF
|
752
|
+
<html>
|
753
|
+
<head>
|
754
|
+
<link href="../global.css" type="text/css" rel="stylesheet">
|
755
|
+
<title>#{@title}</title>
|
756
|
+
</head>
|
757
|
+
|
758
|
+
<body>
|
759
|
+
<div class="sectionhead">#{@title}</div>
|
760
|
+
#{self.elements.collect { |e| e.to_html( :Html ) }}
|
761
|
+
</body>
|
762
|
+
</html>
|
763
|
+
EOF
|
764
|
+
end
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
class CodePage < Page
|
769
|
+
def initialize( data )
|
770
|
+
super( data )
|
771
|
+
ctr = 0
|
772
|
+
@elements.each { |e|
|
773
|
+
e.text['no'] = ( ctr += 1 ) if Yod::Code === e
|
774
|
+
}
|
775
|
+
end
|
776
|
+
end
|
777
|
+
|
778
|
+
class ClassDef < Group
|
779
|
+
attr_accessor :const_name
|
780
|
+
def title=( t )
|
781
|
+
@title = t
|
782
|
+
@const_name = t
|
783
|
+
@elements.each { |e|
|
784
|
+
e.add_const_namespace( self.const_namespace )
|
785
|
+
}
|
786
|
+
end
|
787
|
+
def add_const_namespace( ns )
|
788
|
+
self.const_name = ns + self.const_name
|
789
|
+
self.elements.each { |e|
|
790
|
+
e.add_const_namespace( ns )
|
791
|
+
}
|
792
|
+
end
|
793
|
+
def const_namespace
|
794
|
+
"#{@title}#"
|
795
|
+
end
|
796
|
+
def title
|
797
|
+
"#{@const_name} Class"
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
class ModuleDef < ClassDef
|
802
|
+
def const_namespace
|
803
|
+
"#{@title}::"
|
804
|
+
end
|
805
|
+
def title
|
806
|
+
"#{@const_name} Module"
|
807
|
+
end
|
808
|
+
end
|
809
|
+
|
810
|
+
class Method < DocElement
|
811
|
+
attr_accessor :brief, :since, :arguments, :block, :details, :returns, :const_name
|
812
|
+
def initialize( data )
|
813
|
+
if Hash === data
|
814
|
+
[:brief, :since, :arguments, :block, :returns, :details].each { |a|
|
815
|
+
self.send( "#{a.id2name}=", data[a.id2name] )
|
816
|
+
}
|
817
|
+
else
|
818
|
+
raise Yod::Error, "ClassMethod must be a Hash."
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
def add_const_namespace( ns )
|
823
|
+
self.const_name = ns + self.const_name
|
824
|
+
end
|
825
|
+
|
826
|
+
def html_file_name
|
827
|
+
"class" + File::SEPARATOR + self.title.downcase.gsub( /\W+/, '_' ) + ".htm"
|
828
|
+
end
|
829
|
+
|
830
|
+
def title=( t )
|
831
|
+
@title = t
|
832
|
+
@const_name = t
|
833
|
+
end
|
834
|
+
|
835
|
+
def title
|
836
|
+
"#{@const_name} Method"
|
837
|
+
end
|
838
|
+
|
839
|
+
def index
|
840
|
+
index_all = { self.title => self.html_file_name }
|
841
|
+
end
|
842
|
+
|
843
|
+
def method_example
|
844
|
+
case self.const_name
|
845
|
+
when /^(.+)#(\w+)$/
|
846
|
+
meth = $2
|
847
|
+
classObj = $1.gsub( /[A-Z]+/ ) { |s| s[0..0] + s[1..-1].downcase }.gsub( /::/, '' )
|
848
|
+
"a#{classObj}.#{meth}"
|
849
|
+
else
|
850
|
+
self.const_name
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
854
|
+
def to_man( *args )
|
855
|
+
page = args.shift
|
856
|
+
case page
|
857
|
+
when :Page
|
858
|
+
depth = args.shift
|
859
|
+
if depth.zero?
|
860
|
+
str = ".SH #{self.title}\n"
|
861
|
+
else
|
862
|
+
str = ".Sh #{self.title}\n"
|
863
|
+
end
|
864
|
+
str
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
def to_pdf( *args )
|
869
|
+
page = args.shift
|
870
|
+
case page
|
871
|
+
when :TableOfContents
|
872
|
+
pdf, idx = args
|
873
|
+
pdf.textCRLFshow( "#{idx}. #{self.title}" )
|
874
|
+
when :Page
|
875
|
+
pdf, idx = args
|
876
|
+
txt = {}
|
877
|
+
if Array === @arguments
|
878
|
+
txt['args'] = "\n" + @arguments.collect { |p|
|
879
|
+
if Array === p['type']
|
880
|
+
" (" + p['type'].join( " or " ) + ") #{p['name']}"
|
881
|
+
else
|
882
|
+
" (#{p['type']}) #{p['name']}"
|
883
|
+
end
|
884
|
+
}.join( ",\n" ) + "\n"
|
885
|
+
end
|
886
|
+
|
887
|
+
pdf.newline
|
888
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 16.0, LEFT, 0.0,
|
889
|
+
0.4, "#{idx.join('.')}. #{self.title}" )
|
890
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.0, 0.2, @brief )
|
891
|
+
pdf.textPara( "Courier-Bold", 12.0, LEFT, 0.3,
|
892
|
+
0.2, "#{self.method_example}(#{txt['args']})" )
|
893
|
+
pdf.newline
|
894
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 14.0, LEFT, 0.0,
|
895
|
+
0.2, "Parameters" )
|
896
|
+
if Array === @arguments
|
897
|
+
@arguments.each { |p|
|
898
|
+
pdf.textPara( "NewCenturySchlbk-Italic", 10.0, LEFT, 0.2,
|
899
|
+
0.1, p['name'] )
|
900
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.4,
|
901
|
+
0.2, p['brief'] )
|
902
|
+
}
|
903
|
+
else
|
904
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.2,
|
905
|
+
0.2, "None" )
|
906
|
+
end
|
907
|
+
if Array === @block
|
908
|
+
pdf.newline
|
909
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 14.0, LEFT, 0.0,
|
910
|
+
0.2, "Block Parameters" )
|
911
|
+
@block.collect { |p|
|
912
|
+
pdf.textPara( "NewCenturySchlbk-Italic", 10.0, LEFT, 0.2,
|
913
|
+
0.1, p['name'] )
|
914
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.4,
|
915
|
+
0.2, p['brief'] )
|
916
|
+
}
|
917
|
+
end
|
918
|
+
pdf.newline
|
919
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 14.0, LEFT, 0.0,
|
920
|
+
0.2, "Returns" )
|
921
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.4,
|
922
|
+
0.2, @returns || "None" )
|
923
|
+
if Array === @details
|
924
|
+
pdf.newline
|
925
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 14.0, LEFT, 0.0,
|
926
|
+
0.2, "Details" )
|
927
|
+
@details.each { |e|
|
928
|
+
e.to_pdf( pdf )
|
929
|
+
}
|
930
|
+
end
|
931
|
+
end
|
932
|
+
end
|
933
|
+
|
934
|
+
def to_chm( page )
|
935
|
+
case page
|
936
|
+
when :TableOfContents
|
937
|
+
return <<EOF
|
938
|
+
<LI> <OBJECT type="text/sitemap">
|
939
|
+
<param name="Name" value="#{self.title}">
|
940
|
+
<param name="Local" value="#{self.html_file_name}">
|
941
|
+
</OBJECT>
|
942
|
+
EOF
|
943
|
+
when :Html
|
944
|
+
return self.to_html( :Html )
|
945
|
+
end
|
946
|
+
end
|
947
|
+
|
948
|
+
def to_html( page )
|
949
|
+
case page
|
950
|
+
when :TableOfContents
|
951
|
+
return <<EOF
|
952
|
+
<LI> <A HREF="#{self.html_file_name}" TARGET="docview">#{self.title}</A>
|
953
|
+
EOF
|
954
|
+
when :Html
|
955
|
+
ht = {}
|
956
|
+
if Array === @details
|
957
|
+
ht['remarks'] = <<EOF
|
958
|
+
<!-- Remarks -->
|
959
|
+
<div class="indent1"><strong>Details</strong></div>
|
960
|
+
<div class="indent2">
|
961
|
+
#{@details.collect { |e| e.to_html( :Html ) }}
|
962
|
+
</div>
|
963
|
+
<BR>
|
964
|
+
EOF
|
965
|
+
end
|
966
|
+
|
967
|
+
if Array === @arguments
|
968
|
+
ht['args'] = "\n" + @arguments.collect { |p|
|
969
|
+
if Array === p['type']
|
970
|
+
" <strong>(" + p['type'].join( " or " ) + ")</strong> #{p['name']}"
|
971
|
+
else
|
972
|
+
" <strong>#{p['type']}</strong> #{p['name']}"
|
973
|
+
end
|
974
|
+
}.join( ",\n" ) + "\n"
|
975
|
+
|
976
|
+
ht['args2'] = @arguments.collect { |p| <<EOF
|
977
|
+
<DT>#{p['name']}</DT>
|
978
|
+
<DD>#{Yod.escapeHTML( p['brief'] )}</DD>
|
979
|
+
EOF
|
980
|
+
}.join( "\n" )
|
981
|
+
else
|
982
|
+
ht['args2'] = "<DT>None</DT>"
|
983
|
+
end
|
984
|
+
|
985
|
+
if Array === @block
|
986
|
+
ht['blockvars'] = @block.collect { |p| <<EOF
|
987
|
+
<DT>#{p['name']}</DT>
|
988
|
+
<DD>#{Yod.escapeHTML( p['brief'] )}</DD>
|
989
|
+
EOF
|
990
|
+
}.join( "\n" )
|
991
|
+
|
992
|
+
ht['blockvars'] = <<EOF
|
993
|
+
<!-- Block Vars -->
|
994
|
+
<div class="indent1"><strong>Block Parameters</strong></div>
|
995
|
+
<DL>
|
996
|
+
#{ht['blockvars']}
|
997
|
+
</DL>
|
998
|
+
EOF
|
999
|
+
end
|
1000
|
+
|
1001
|
+
return <<EOF
|
1002
|
+
<html>
|
1003
|
+
<head>
|
1004
|
+
<link href="../global.css" type="text/css" rel="stylesheet">
|
1005
|
+
<title>#{self.title}</title>
|
1006
|
+
</head>
|
1007
|
+
|
1008
|
+
<body>
|
1009
|
+
<div class="functionhead"><img src="../section.gif" alt="" width="15" height="15" border="0" align="middle"> #{self.title}</div>
|
1010
|
+
|
1011
|
+
<!-- Function Name -->
|
1012
|
+
<div class="function">#{@title}</div>
|
1013
|
+
|
1014
|
+
<!-- Summary -->
|
1015
|
+
<div class="indent2">#{Yod.escapeHTML( @brief )}
|
1016
|
+
</div>
|
1017
|
+
<BR>
|
1018
|
+
|
1019
|
+
<!-- Function Declaration -->
|
1020
|
+
<div class="indent2">
|
1021
|
+
<pre class="codeblock"><strong>#{self.method_example}(</strong>#{ht['args']})</pre>
|
1022
|
+
</div>
|
1023
|
+
<BR>
|
1024
|
+
|
1025
|
+
<!-- Parameters -->
|
1026
|
+
<div class="indent1"><strong>Parameters</strong></div>
|
1027
|
+
<DL>
|
1028
|
+
#{ht['args2']}
|
1029
|
+
</DL>
|
1030
|
+
|
1031
|
+
#{ht['blockvars']}
|
1032
|
+
|
1033
|
+
<!-- Return values -->
|
1034
|
+
<div class="indent1"><strong>Return Values</strong></div>
|
1035
|
+
<div class="indent2">#{@returns || "None"}</div>
|
1036
|
+
<BR>
|
1037
|
+
|
1038
|
+
#{ht['remarks']}
|
1039
|
+
|
1040
|
+
<!-- See Also
|
1041
|
+
<div class="indent1"><strong>See Also</strong></div>
|
1042
|
+
<div class="indent2">
|
1043
|
+
See_Also
|
1044
|
+
</div>
|
1045
|
+
-->
|
1046
|
+
|
1047
|
+
</body>
|
1048
|
+
</html>
|
1049
|
+
EOF
|
1050
|
+
end
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
class PageElement
|
1055
|
+
attr_accessor :text
|
1056
|
+
def initialize( text )
|
1057
|
+
@text = text
|
1058
|
+
end
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
class Paragraph < PageElement
|
1062
|
+
def to_man
|
1063
|
+
"#{text}\n.LP\n"
|
1064
|
+
end
|
1065
|
+
def to_pdf( pdf )
|
1066
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 10.0, LEFT, 0.0, 0.2, "#{text}" )
|
1067
|
+
end
|
1068
|
+
def to_html( page )
|
1069
|
+
case page
|
1070
|
+
when :Html
|
1071
|
+
return <<EOF
|
1072
|
+
<P>
|
1073
|
+
#{Yod.escapeHTML( text )}
|
1074
|
+
</P>
|
1075
|
+
EOF
|
1076
|
+
end
|
1077
|
+
end
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
class Code < PageElement
|
1081
|
+
def to_man
|
1082
|
+
"#{text['code']}\n.LP\n"
|
1083
|
+
end
|
1084
|
+
def to_pdf( pdf )
|
1085
|
+
pdf.textPara( "CPDF-Monospace", 12.0, LEFT, 0.3, 0.2, text['code'] )
|
1086
|
+
pdf.textPara( "NewCenturySchlbk-Italic", 10.0, CENTER, 0.3,
|
1087
|
+
0.2, "Ex. #{text['no']}: #{Yod.escapeHTML( text['name'] )}" )
|
1088
|
+
end
|
1089
|
+
def to_html( page )
|
1090
|
+
case page
|
1091
|
+
when :Html
|
1092
|
+
return <<EOF
|
1093
|
+
<pre class="codeblock">#{Yod.escapeHTML( text['code'] )}</pre>
|
1094
|
+
<center><i>Ex. #{text['no']}: #{Yod.escapeHTML( text['name'] )}</i></center>
|
1095
|
+
EOF
|
1096
|
+
end
|
1097
|
+
end
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
class Quote < PageElement
|
1101
|
+
def to_man
|
1102
|
+
".IP\n#{text}\n"
|
1103
|
+
end
|
1104
|
+
def to_pdf( pdf )
|
1105
|
+
pdf.textPara( "NewCenturySchlbk-Italic", 10.0, LEFT, 0.3, 0.2, "#{text}" )
|
1106
|
+
end
|
1107
|
+
def to_html( page )
|
1108
|
+
case page
|
1109
|
+
when :Html
|
1110
|
+
return <<EOF
|
1111
|
+
<BLOCKQUOTE>
|
1112
|
+
<I>#{Yod.escapeHTML( text )}</I>
|
1113
|
+
</BLOCKQUOTE>
|
1114
|
+
EOF
|
1115
|
+
end
|
1116
|
+
end
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
class Title < PageElement
|
1120
|
+
def to_man
|
1121
|
+
".Sh #{text}\n"
|
1122
|
+
end
|
1123
|
+
def to_pdf( pdf )
|
1124
|
+
pdf.newline
|
1125
|
+
pdf.textPara( "NewCenturySchlbk-Roman", 14.0, LEFT, 0.0, 0.2, "#{text}" )
|
1126
|
+
end
|
1127
|
+
def to_html( page )
|
1128
|
+
case page
|
1129
|
+
when :Html
|
1130
|
+
return <<EOF
|
1131
|
+
<div class="quickhead">#{Yod.escapeHTML( text )}</div>
|
1132
|
+
EOF
|
1133
|
+
end
|
1134
|
+
end
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
YAML.add_domain_type( "yaml4r.sf.net,2003", /^yod\// ) { |type, val|
|
1138
|
+
type =~ /^yod\/(\w+)(?::?(\w+))?/
|
1139
|
+
if Yod.const_defined?( $1 )
|
1140
|
+
if $2
|
1141
|
+
Yod.const_get( $1 ).new( $2, val )
|
1142
|
+
else
|
1143
|
+
Yod.const_get( $1 ).new( val )
|
1144
|
+
end
|
1145
|
+
else
|
1146
|
+
raise Yod::Error, "Invalid type #{type} not available in Yod module."
|
1147
|
+
end
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
def Yod.load( io )
|
1151
|
+
YAML::load( io )
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
# based on code by WATANABE Tetsuya
|
1155
|
+
def Yod.multi_mkdir( mpath, mask )
|
1156
|
+
path = ''
|
1157
|
+
mpath.split( File::SEPARATOR ).each do |f|
|
1158
|
+
path.concat( f )
|
1159
|
+
Dir.mkdir( path, mask ) unless path == '' || File.exist?( path )
|
1160
|
+
path.concat( File::SEPARATOR )
|
1161
|
+
end
|
1162
|
+
end
|
1163
|
+
|
1164
|
+
def Yod.escapeHTML( string )
|
1165
|
+
string.to_s.gsub(/&/n, '&').gsub(/\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<')
|
1166
|
+
end
|
1167
|
+
end
|
1168
|
+
|