rdoc-f95 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +79 -0
  3. data/PostInstall.txt +7 -0
  4. data/README.rdoc +147 -0
  5. data/Rakefile +28 -0
  6. data/bin/rdoc-f95 +70 -0
  7. data/lib/rdoc-f95.rb +306 -0
  8. data/lib/rdoc-f95/code_objects.rb +776 -0
  9. data/lib/rdoc-f95/diagram.rb +342 -0
  10. data/lib/rdoc-f95/dot.rb +249 -0
  11. data/lib/rdoc-f95/generator.rb +1088 -0
  12. data/lib/rdoc-f95/generator/chm.rb +113 -0
  13. data/lib/rdoc-f95/generator/chm/chm.rb +98 -0
  14. data/lib/rdoc-f95/generator/html.rb +370 -0
  15. data/lib/rdoc-f95/generator/html/hefss.rb +414 -0
  16. data/lib/rdoc-f95/generator/html/html.rb +708 -0
  17. data/lib/rdoc-f95/generator/html/kilmer.rb +418 -0
  18. data/lib/rdoc-f95/generator/html/one_page_html.rb +121 -0
  19. data/lib/rdoc-f95/generator/ri.rb +229 -0
  20. data/lib/rdoc-f95/generator/xhtml.rb +106 -0
  21. data/lib/rdoc-f95/generator/xhtml/ctop.xsl +1318 -0
  22. data/lib/rdoc-f95/generator/xhtml/mathml.xsl +42 -0
  23. data/lib/rdoc-f95/generator/xhtml/pmathml.xsl +612 -0
  24. data/lib/rdoc-f95/generator/xhtml/pmathmlcss.xsl +872 -0
  25. data/lib/rdoc-f95/generator/xhtml/xhtml.rb +732 -0
  26. data/lib/rdoc-f95/generator/xml.rb +120 -0
  27. data/lib/rdoc-f95/generator/xml/rdf.rb +113 -0
  28. data/lib/rdoc-f95/generator/xml/xml.rb +111 -0
  29. data/lib/rdoc-f95/install.rb +166 -0
  30. data/lib/rdoc-f95/markup.rb +506 -0
  31. data/lib/rdoc-f95/markup/formatter.rb +14 -0
  32. data/lib/rdoc-f95/markup/fragments.rb +337 -0
  33. data/lib/rdoc-f95/markup/inline.rb +361 -0
  34. data/lib/rdoc-f95/markup/install.rb +57 -0
  35. data/lib/rdoc-f95/markup/lines.rb +152 -0
  36. data/lib/rdoc-f95/markup/mathml_wrapper.rb +91 -0
  37. data/lib/rdoc-f95/markup/preprocess.rb +71 -0
  38. data/lib/rdoc-f95/markup/sample/rdoc2latex.rb +16 -0
  39. data/lib/rdoc-f95/markup/sample/sample.rb +42 -0
  40. data/lib/rdoc-f95/markup/to_flow.rb +185 -0
  41. data/lib/rdoc-f95/markup/to_html.rb +357 -0
  42. data/lib/rdoc-f95/markup/to_html_crossref.rb +123 -0
  43. data/lib/rdoc-f95/markup/to_latex.rb +328 -0
  44. data/lib/rdoc-f95/markup/to_test.rb +50 -0
  45. data/lib/rdoc-f95/markup/to_xhtml_texparser.rb +234 -0
  46. data/lib/rdoc-f95/options.rb +745 -0
  47. data/lib/rdoc-f95/parsers/parse_c.rb +775 -0
  48. data/lib/rdoc-f95/parsers/parse_f95.rb +2499 -0
  49. data/lib/rdoc-f95/parsers/parse_rb.rb +2587 -0
  50. data/lib/rdoc-f95/parsers/parse_simple.rb +39 -0
  51. data/lib/rdoc-f95/parsers/parserfactory.rb +99 -0
  52. data/lib/rdoc-f95/ri.rb +2 -0
  53. data/lib/rdoc-f95/ri/cache.rb +188 -0
  54. data/lib/rdoc-f95/ri/descriptions.rb +147 -0
  55. data/lib/rdoc-f95/ri/display.rb +244 -0
  56. data/lib/rdoc-f95/ri/driver.rb +435 -0
  57. data/lib/rdoc-f95/ri/formatter.rb +603 -0
  58. data/lib/rdoc-f95/ri/paths.rb +105 -0
  59. data/lib/rdoc-f95/ri/reader.rb +106 -0
  60. data/lib/rdoc-f95/ri/util.rb +81 -0
  61. data/lib/rdoc-f95/ri/writer.rb +64 -0
  62. data/lib/rdoc-f95/stats.rb +23 -0
  63. data/lib/rdoc-f95/template.rb +64 -0
  64. data/lib/rdoc-f95/tokenstream.rb +33 -0
  65. data/lib/rdoc-f95/usage.rb +210 -0
  66. data/script/console +10 -0
  67. data/script/destroy +14 -0
  68. data/script/generate +14 -0
  69. data/test/test_helper.rb +3 -0
  70. data/test/test_rdoc-f95.rb +11 -0
  71. metadata +156 -0
@@ -0,0 +1,33 @@
1
+ module RDocF95; end
2
+
3
+ ##
4
+ # A TokenStream is a list of tokens, gathered during the parse of some entity
5
+ # (say a method). Entities populate these streams by being registered with the
6
+ # lexer. Any class can collect tokens by including TokenStream. From the
7
+ # outside, you use such an object by calling the start_collecting_tokens
8
+ # method, followed by calls to add_token and pop_token.
9
+
10
+ module RDocF95::TokenStream
11
+
12
+ def token_stream
13
+ @token_stream
14
+ end
15
+
16
+ def start_collecting_tokens
17
+ @token_stream = []
18
+ end
19
+
20
+ def add_token(tk)
21
+ @token_stream << tk
22
+ end
23
+
24
+ def add_tokens(tks)
25
+ tks.each {|tk| add_token(tk)}
26
+ end
27
+
28
+ def pop_token
29
+ @token_stream.pop
30
+ end
31
+
32
+ end
33
+
@@ -0,0 +1,210 @@
1
+ # = Synopsis
2
+ #
3
+ # This library allows command-line tools to encapsulate their usage
4
+ # as a comment at the top of the main file. Calling <tt>RDocF95::usage</tt>
5
+ # then displays some or all of that comment, and optionally exits
6
+ # the program with an exit status. We always look for the comment
7
+ # in the main program file, so it is safe to call this method
8
+ # from anywhere in the executing program.
9
+ #
10
+ # = Usage
11
+ #
12
+ # RDocF95::usage( [ exit_status ], [ section, ...])
13
+ # RDocF95::usage_no_exit( [ section, ...])
14
+ #
15
+ # where:
16
+ #
17
+ # exit_status::
18
+ # the integer exit code (default zero). RDocF95::usage will exit
19
+ # the calling program with this status.
20
+ #
21
+ # section::
22
+ # an optional list of section names. If specified, only the
23
+ # sections with the given names as headings will be output.
24
+ # For example, this section is named 'Usage', and the next
25
+ # section is named 'Examples'. The section names are case
26
+ # insensitive.
27
+ #
28
+ # = Examples
29
+ #
30
+ # # Comment block describing usage
31
+ # # with (optional) section headings
32
+ # # . . .
33
+ #
34
+ # require 'rdoc-f95/usage'
35
+ #
36
+ # # Display all usage and exit with a status of 0
37
+ #
38
+ # RDocF95::usage
39
+ #
40
+ # # Display all usage and exit with a status of 99
41
+ #
42
+ # RDocF95::usage(99)
43
+ #
44
+ # # Display usage in the 'Summary' section only, then
45
+ # # exit with a status of 99
46
+ #
47
+ # RDocF95::usage(99, 'Summary')
48
+ #
49
+ # # Display information in the Author and Copyright
50
+ # # sections, then exit 0.
51
+ #
52
+ # RDocF95::usage('Author', 'Copyright')
53
+ #
54
+ # # Display information in the Author and Copyright
55
+ # # sections, but don't exit
56
+ #
57
+ # RDocF95::usage_no_exit('Author', 'Copyright')
58
+ #
59
+ # = Author
60
+ #
61
+ # Dave Thomas, The Pragmatic Programmers, LLC
62
+ #
63
+ # = Copyright
64
+ #
65
+ # Copyright (c) 2004 Dave Thomas.
66
+ # Licensed under the same terms as Ruby
67
+ #
68
+
69
+ require 'rdoc-f95/markup/simple_markup'
70
+ require 'rdoc-f95/markup/simple_markup/to_flow'
71
+ require 'rdoc-f95/ri/ri_formatter'
72
+ require 'rdoc-f95/ri/ri_options'
73
+
74
+ module RDocF95
75
+
76
+ # Display usage information from the comment at the top of
77
+ # the file. String arguments identify specific sections of the
78
+ # comment to display. An optional integer first argument
79
+ # specifies the exit status (defaults to 0)
80
+
81
+ def RDocF95.usage(*args)
82
+ exit_code = 0
83
+
84
+ if args.size > 0
85
+ status = args[0]
86
+ if status.respond_to?(:to_int)
87
+ exit_code = status.to_int
88
+ args.shift
89
+ end
90
+ end
91
+
92
+ # display the usage and exit with the given code
93
+ usage_no_exit(*args)
94
+ exit(exit_code)
95
+ end
96
+
97
+ # Display usage
98
+ def RDocF95.usage_no_exit(*args)
99
+ main_program_file, = caller[-1].split(/:\d+/, 2)
100
+ comment = File.open(main_program_file) do |file|
101
+ find_comment(file)
102
+ end
103
+
104
+ comment = comment.gsub(/^\s*#/, '')
105
+
106
+ markup = SM::SimpleMarkup.new
107
+ flow_convertor = SM::ToFlow.new
108
+
109
+ flow = markup.convert(comment, flow_convertor)
110
+
111
+ format = "plain"
112
+
113
+ unless args.empty?
114
+ flow = extract_sections(flow, args)
115
+ end
116
+
117
+ options = RI::Options.instance
118
+ if args = ENV["RI"]
119
+ options.parse(args.split)
120
+ end
121
+ formatter = options.formatter.new(options, "")
122
+ formatter.display_flow(flow)
123
+ end
124
+
125
+ ######################################################################
126
+
127
+ private
128
+
129
+ # Find the first comment in the file (that isn't a shebang line)
130
+ # If the file doesn't start with a comment, report the fact
131
+ # and return empty string
132
+
133
+ def RDocF95.gets(file)
134
+ if (line = file.gets) && (line =~ /^#!/) # shebang
135
+ throw :exit, find_comment(file)
136
+ else
137
+ line
138
+ end
139
+ end
140
+
141
+ def RDocF95.find_comment(file)
142
+ catch(:exit) do
143
+ # skip leading blank lines
144
+ 0 while (line = gets(file)) && (line =~ /^\s*$/)
145
+
146
+ comment = []
147
+ while line && line =~ /^\s*#/
148
+ comment << line
149
+ line = gets(file)
150
+ end
151
+
152
+ 0 while line && (line = gets(file))
153
+ return no_comment if comment.empty?
154
+ return comment.join
155
+ end
156
+ end
157
+
158
+
159
+ #####
160
+ # Given an array of flow items and an array of section names, extract those
161
+ # sections from the flow which have headings corresponding to
162
+ # a section name in the list. Return them in the order
163
+ # of names in the +sections+ array.
164
+
165
+ def RDocF95.extract_sections(flow, sections)
166
+ result = []
167
+ sections.each do |name|
168
+ name = name.downcase
169
+ copy_upto_level = nil
170
+
171
+ flow.each do |item|
172
+ case item
173
+ when SM::Flow::H
174
+ if copy_upto_level && item.level >= copy_upto_level
175
+ copy_upto_level = nil
176
+ else
177
+ if item.text.downcase == name
178
+ result << item
179
+ copy_upto_level = item.level
180
+ end
181
+ end
182
+ else
183
+ if copy_upto_level
184
+ result << item
185
+ end
186
+ end
187
+ end
188
+ end
189
+ if result.empty?
190
+ puts "Note to developer: requested section(s) [#{sections.join(', ')}] " +
191
+ "not found"
192
+ result = flow
193
+ end
194
+ result
195
+ end
196
+
197
+ #####
198
+ # Report the fact that no doc comment count be found
199
+ def RDocF95.no_comment
200
+ $stderr.puts "No usage information available for this program"
201
+ ""
202
+ end
203
+ end
204
+
205
+
206
+ if $0 == __FILE__
207
+
208
+ RDocF95::usage(*ARGV)
209
+
210
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/rdoc-f95.rb'}"
9
+ puts "Loading rdoc-f95 gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/rdoc-f95'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestRdoc-f95 < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdoc-f95
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - FIXME full name
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-09 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ version:
35
+ description: FIX (describe your package)
36
+ email:
37
+ - morikawa@gfd-dennou.org
38
+ executables:
39
+ - rdoc-f95
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - PostInstall.txt
46
+ - README.rdoc
47
+ files:
48
+ - History.txt
49
+ - Manifest.txt
50
+ - PostInstall.txt
51
+ - README.rdoc
52
+ - Rakefile
53
+ - lib/rdoc-f95.rb
54
+ - script/console
55
+ - script/destroy
56
+ - script/generate
57
+ - test/test_helper.rb
58
+ - test/test_rdoc-f95.rb
59
+ - bin/rdoc-f95
60
+ - lib/rdoc-f95/code_objects.rb
61
+ - lib/rdoc-f95/diagram.rb
62
+ - lib/rdoc-f95/dot.rb
63
+ - lib/rdoc-f95/generator
64
+ - lib/rdoc-f95/generator/chm.rb
65
+ - lib/rdoc-f95/generator/html.rb
66
+ - lib/rdoc-f95/generator/ri.rb
67
+ - lib/rdoc-f95/generator/xhtml.rb
68
+ - lib/rdoc-f95/generator/xml.rb
69
+ - lib/rdoc-f95/generator/chm
70
+ - lib/rdoc-f95/generator/chm/chm.rb
71
+ - lib/rdoc-f95/generator/html
72
+ - lib/rdoc-f95/generator/html/hefss.rb
73
+ - lib/rdoc-f95/generator/html/html.rb
74
+ - lib/rdoc-f95/generator/html/kilmer.rb
75
+ - lib/rdoc-f95/generator/html/one_page_html.rb
76
+ - lib/rdoc-f95/generator/xhtml
77
+ - lib/rdoc-f95/generator/xhtml/ctop.xsl
78
+ - lib/rdoc-f95/generator/xhtml/mathml.xsl
79
+ - lib/rdoc-f95/generator/xhtml/pmathml.xsl
80
+ - lib/rdoc-f95/generator/xhtml/pmathmlcss.xsl
81
+ - lib/rdoc-f95/generator/xhtml/xhtml.rb
82
+ - lib/rdoc-f95/generator/xml
83
+ - lib/rdoc-f95/generator/xml/rdf.rb
84
+ - lib/rdoc-f95/generator/xml/xml.rb
85
+ - lib/rdoc-f95/generator.rb
86
+ - lib/rdoc-f95/install.rb
87
+ - lib/rdoc-f95/markup
88
+ - lib/rdoc-f95/markup/formatter.rb
89
+ - lib/rdoc-f95/markup/fragments.rb
90
+ - lib/rdoc-f95/markup/inline.rb
91
+ - lib/rdoc-f95/markup/install.rb
92
+ - lib/rdoc-f95/markup/lines.rb
93
+ - lib/rdoc-f95/markup/mathml_wrapper.rb
94
+ - lib/rdoc-f95/markup/preprocess.rb
95
+ - lib/rdoc-f95/markup/to_flow.rb
96
+ - lib/rdoc-f95/markup/to_html.rb
97
+ - lib/rdoc-f95/markup/to_html_crossref.rb
98
+ - lib/rdoc-f95/markup/to_latex.rb
99
+ - lib/rdoc-f95/markup/to_test.rb
100
+ - lib/rdoc-f95/markup/to_xhtml_texparser.rb
101
+ - lib/rdoc-f95/markup/sample
102
+ - lib/rdoc-f95/markup/sample/rdoc2latex.rb
103
+ - lib/rdoc-f95/markup/sample/sample.rb
104
+ - lib/rdoc-f95/markup.rb
105
+ - lib/rdoc-f95/options.rb
106
+ - lib/rdoc-f95/parsers
107
+ - lib/rdoc-f95/parsers/parse_c.rb
108
+ - lib/rdoc-f95/parsers/parse_f95.rb
109
+ - lib/rdoc-f95/parsers/parse_rb.rb
110
+ - lib/rdoc-f95/parsers/parse_simple.rb
111
+ - lib/rdoc-f95/parsers/parserfactory.rb
112
+ - lib/rdoc-f95/ri
113
+ - lib/rdoc-f95/ri/cache.rb
114
+ - lib/rdoc-f95/ri/descriptions.rb
115
+ - lib/rdoc-f95/ri/display.rb
116
+ - lib/rdoc-f95/ri/driver.rb
117
+ - lib/rdoc-f95/ri/formatter.rb
118
+ - lib/rdoc-f95/ri/paths.rb
119
+ - lib/rdoc-f95/ri/reader.rb
120
+ - lib/rdoc-f95/ri/util.rb
121
+ - lib/rdoc-f95/ri/writer.rb
122
+ - lib/rdoc-f95/ri.rb
123
+ - lib/rdoc-f95/stats.rb
124
+ - lib/rdoc-f95/template.rb
125
+ - lib/rdoc-f95/tokenstream.rb
126
+ - lib/rdoc-f95/usage.rb
127
+ has_rdoc: true
128
+ homepage: FIX (url)
129
+ post_install_message: PostInstall.txt
130
+ rdoc_options:
131
+ - --main
132
+ - README.rdoc.org
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: "0"
140
+ version:
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: "0"
146
+ version:
147
+ requirements: []
148
+
149
+ rubyforge_project: rdoc-f95
150
+ rubygems_version: 1.3.1
151
+ signing_key:
152
+ specification_version: 2
153
+ summary: FIX (describe your package)
154
+ test_files:
155
+ - test/test_helper.rb
156
+ - test/test_rdoc-f95.rb