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,113 @@
1
+ require 'rdoc-f95/generator/html'
2
+
3
+ class RDocF95::Generator::CHM < RDocF95::Generator::HTML
4
+
5
+ HHC_PATH = "c:/Program Files/HTML Help Workshop/hhc.exe"
6
+
7
+ ##
8
+ # Standard generator factory
9
+
10
+ def self.for(options)
11
+ new(options)
12
+ end
13
+
14
+ def initialize(*args)
15
+ super
16
+ @op_name = @options.op_name || "rdoc"
17
+ check_for_html_help_workshop
18
+ end
19
+
20
+ def check_for_html_help_workshop
21
+ stat = File.stat(HHC_PATH)
22
+ rescue
23
+ $stderr <<
24
+ "\n.chm output generation requires that Microsoft's Html Help\n" <<
25
+ "Workshop is installed. RDoc looks for it in:\n\n " <<
26
+ HHC_PATH <<
27
+ "\n\nYou can download a copy for free from:\n\n" <<
28
+ " http://msdn.microsoft.com/library/default.asp?" <<
29
+ "url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n"
30
+ end
31
+
32
+ ##
33
+ # Generate the html as normal, then wrap it in a help project
34
+
35
+ def generate(info)
36
+ super
37
+ @project_name = @op_name + ".hhp"
38
+ create_help_project
39
+ end
40
+
41
+ ##
42
+ # The project contains the project file, a table of contents and an index
43
+
44
+ def create_help_project
45
+ create_project_file
46
+ create_contents_and_index
47
+ compile_project
48
+ end
49
+
50
+ ##
51
+ # The project file links together all the various
52
+ # files that go to make up the help.
53
+
54
+ def create_project_file
55
+ template = RDocF95::TemplatePage.new @template::HPP_FILE
56
+ values = { "title" => @options.title, "opname" => @op_name }
57
+ files = []
58
+ @files.each do |f|
59
+ files << { "html_file_name" => f.path }
60
+ end
61
+
62
+ values['all_html_files'] = files
63
+
64
+ File.open(@project_name, "w") do |f|
65
+ template.write_html_on(f, values)
66
+ end
67
+ end
68
+
69
+ ##
70
+ # The contents is a list of all files and modules.
71
+ # For each we include as sub-entries the list
72
+ # of methods they contain. As we build the contents
73
+ # we also build an index file
74
+
75
+ def create_contents_and_index
76
+ contents = []
77
+ index = []
78
+
79
+ (@files+@classes).sort.each do |entry|
80
+ content_entry = { "c_name" => entry.name, "ref" => entry.path }
81
+ index << { "name" => entry.name, "aref" => entry.path }
82
+
83
+ internals = []
84
+
85
+ methods = entry.build_method_summary_list(entry.path)
86
+
87
+ content_entry["methods"] = methods unless methods.empty?
88
+ contents << content_entry
89
+ index.concat methods
90
+ end
91
+
92
+ values = { "contents" => contents }
93
+ template = RDocF95::TemplatePage.new @template::CONTENTS
94
+ File.open("contents.hhc", "w") do |f|
95
+ template.write_html_on(f, values)
96
+ end
97
+
98
+ values = { "index" => index }
99
+ template = RDocF95::TemplatePage.new @template::CHM_INDEX
100
+ File.open("index.hhk", "w") do |f|
101
+ template.write_html_on(f, values)
102
+ end
103
+ end
104
+
105
+ ##
106
+ # Invoke the windows help compiler to compiler the project
107
+
108
+ def compile_project
109
+ system(HHC_PATH, @project_name)
110
+ end
111
+
112
+ end
113
+
@@ -0,0 +1,98 @@
1
+ require 'rdoc-f95/generator/chm'
2
+ require 'rdoc-f95/generator/html/html'
3
+
4
+ module RDocF95::Generator::CHM::CHM
5
+
6
+ HTML = RDocF95::Generator::HTML::HTML
7
+
8
+ INDEX = HTML::INDEX
9
+
10
+ CLASS_INDEX = HTML::CLASS_INDEX
11
+ CLASS_PAGE = HTML::CLASS_PAGE
12
+ FILE_INDEX = HTML::FILE_INDEX
13
+ FILE_PAGE = HTML::FILE_PAGE
14
+ METHOD_INDEX = HTML::METHOD_INDEX
15
+ METHOD_LIST = HTML::METHOD_LIST
16
+
17
+ FR_INDEX_BODY = HTML::FR_INDEX_BODY
18
+
19
+ # This is a nasty little hack, but hhc doesn't support the <?xml tag, so...
20
+ BODY = HTML::BODY.sub!(/<\?xml.*\?>/, '')
21
+ SRC_PAGE = HTML::SRC_PAGE.sub!(/<\?xml.*\?>/, '')
22
+
23
+ HPP_FILE = <<-EOF
24
+ [OPTIONS]
25
+ Auto Index = Yes
26
+ Compatibility=1.1 or later
27
+ Compiled file=<%= values["opname"] %>.chm
28
+ Contents file=contents.hhc
29
+ Full-text search=Yes
30
+ Index file=index.hhk
31
+ Language=0x409 English(United States)
32
+ Title=<%= values["title"] %>
33
+
34
+ [FILES]
35
+ <% values["all_html_files"].each do |all_html_files| %>
36
+ <%= all_html_files["html_file_name"] %>
37
+ <% end # values["all_html_files"] %>
38
+ EOF
39
+
40
+ CONTENTS = <<-EOF
41
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
42
+ <HTML>
43
+ <HEAD>
44
+ <meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
45
+ <!-- Sitemap 1.0 -->
46
+ </HEAD><BODY>
47
+ <OBJECT type="text/site properties">
48
+ <param name="Foreground" value="0x80">
49
+ <param name="Window Styles" value="0x800025">
50
+ <param name="ImageType" value="Folder">
51
+ </OBJECT>
52
+ <UL>
53
+ <% values["contents"].each do |contents| %>
54
+ <LI> <OBJECT type="text/sitemap">
55
+ <param name="Name" value="<%= contents["c_name"] %>">
56
+ <param name="Local" value="<%= contents["ref"] %>">
57
+ </OBJECT>
58
+ <% if contents["methods"] then %>
59
+ <ul>
60
+ <% contents["methods"].each do |methods| %>
61
+ <LI> <OBJECT type="text/sitemap">
62
+ <param name="Name" value="<%= methods["name"] %>">
63
+ <param name="Local" value="<%= methods["aref"] %>">
64
+ </OBJECT>
65
+ <% end # contents["methods"] %>
66
+ </ul>
67
+ <% end %>
68
+ </LI>
69
+ <% end # values["contents"] %>
70
+ </UL>
71
+ </BODY></HTML>
72
+ EOF
73
+
74
+ CHM_INDEX = <<-EOF
75
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
76
+ <HTML>
77
+ <HEAD>
78
+ <meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
79
+ <!-- Sitemap 1.0 -->
80
+ </HEAD><BODY>
81
+ <OBJECT type="text/site properties">
82
+ <param name="Foreground" value="0x80">
83
+ <param name="Window Styles" value="0x800025">
84
+ <param name="ImageType" value="Folder">
85
+ </OBJECT>
86
+ <UL>
87
+ <% values["index"].each do |index| %>
88
+ <LI> <OBJECT type="text/sitemap">
89
+ <param name="Name" value="<%= index["name"] %>">
90
+ <param name="Local" value="<%= index["aref"] %>">
91
+ </OBJECT>
92
+ <% end # values["index"] %>
93
+ </UL>
94
+ </BODY></HTML>
95
+ EOF
96
+
97
+ end
98
+
@@ -0,0 +1,370 @@
1
+ require 'fileutils'
2
+
3
+ require 'rdoc-f95/generator'
4
+ require 'rdoc-f95/markup/to_html'
5
+
6
+ ##
7
+ # We're responsible for generating all the HTML files from the object tree
8
+ # defined in code_objects.rb. We generate:
9
+ #
10
+ # [files] an html file for each input file given. These
11
+ # input files appear as objects of class
12
+ # TopLevel
13
+ #
14
+ # [classes] an html file for each class or module encountered.
15
+ # These classes are not grouped by file: if a file
16
+ # contains four classes, we'll generate an html
17
+ # file for the file itself, and four html files
18
+ # for the individual classes.
19
+ #
20
+ # [indices] we generate three indices for files, classes,
21
+ # and methods. These are displayed in a browser
22
+ # like window with three index panes across the
23
+ # top and the selected description below
24
+ #
25
+ # Method descriptions appear in whatever entity (file, class, or module) that
26
+ # contains them.
27
+ #
28
+ # We generate files in a structure below a specified subdirectory, normally
29
+ # +doc+.
30
+ #
31
+ # opdir
32
+ # |
33
+ # |___ files
34
+ # | |__ per file summaries
35
+ # |
36
+ # |___ classes
37
+ # |__ per class/module descriptions
38
+ #
39
+ # HTML is generated using the Template class.
40
+
41
+ class RDocF95::Generator::HTML
42
+
43
+ include RDocF95::Generator
44
+ include RDocF95::Generator::MarkUp
45
+
46
+ ##
47
+ # Generator may need to return specific subclasses depending on the
48
+ # options they are passed. Because of this we create them using a factory
49
+
50
+ def self.for(options)
51
+ RDocF95::Generator::AllReferences.reset
52
+ RDocF95::Generator::Method.reset
53
+
54
+ if options.all_one_file
55
+ RDocF95::Generator::HTMLInOne.new options
56
+ else
57
+ new options
58
+ end
59
+ end
60
+
61
+ class << self
62
+ protected :new
63
+ end
64
+
65
+ ##
66
+ # Set up a new HTML generator. Basically all we do here is load up the
67
+ # correct output temlate
68
+
69
+ def initialize(options) #:not-new:
70
+ @options = options
71
+ load_html_template
72
+ end
73
+
74
+ ##
75
+ # Build the initial indices and output objects
76
+ # based on an array of TopLevel objects containing
77
+ # the extracted information.
78
+
79
+ def generate(toplevels)
80
+ @toplevels = toplevels
81
+ @files = []
82
+ @classes = []
83
+
84
+ write_style_sheet
85
+ gen_sub_directories()
86
+ build_indices
87
+ generate_html
88
+ end
89
+
90
+ private
91
+
92
+ ##
93
+ # Load up the HTML template specified in the options.
94
+ # If the template name contains a slash, use it literally
95
+
96
+ def load_html_template
97
+ template = @options.template
98
+
99
+ unless template =~ %r{/|\\} then
100
+ template = ::File.join('rdoc-f95', 'generator', @options.generator.key,
101
+ template)
102
+ end
103
+
104
+ require template
105
+
106
+ @template = self.class.const_get @options.template.upcase
107
+ @options.template_class = @template
108
+
109
+ rescue LoadError
110
+ $stderr.puts "Could not find HTML template '#{template}'"
111
+ exit 99
112
+ end
113
+
114
+ ##
115
+ # Write out the style sheet used by the main frames
116
+
117
+ def write_style_sheet
118
+ return unless @template.constants.include? :STYLE or
119
+ @template.constants.include? 'STYLE'
120
+
121
+ template = RDocF95::TemplatePage.new @template::STYLE
122
+
123
+ unless @options.css then
124
+ open RDocF95::Generator::CSS_NAME, 'w' do |f|
125
+ values = {}
126
+
127
+ if @template.constants.include? :FONTS or
128
+ @template.constants.include? 'FONTS' then
129
+ values["fonts"] = @template::FONTS
130
+ end
131
+
132
+ template.write_html_on(f, values)
133
+ end
134
+ end
135
+ end
136
+
137
+ ##
138
+ # See the comments at the top for a description of the directory structure
139
+
140
+ def gen_sub_directories
141
+ FileUtils.mkdir_p RDocF95::Generator::FILE_DIR
142
+ FileUtils.mkdir_p RDocF95::Generator::CLASS_DIR
143
+ rescue
144
+ $stderr.puts $!.message
145
+ exit 1
146
+ end
147
+
148
+ def build_indices
149
+ @files, @classes = RDocF95::Generator::Context.build_indicies(@toplevels,
150
+ @options)
151
+ end
152
+
153
+ ##
154
+ # Generate all the HTML
155
+
156
+ def generate_html
157
+ # the individual descriptions for files and classes
158
+ gen_into(@files)
159
+ gen_into(@classes)
160
+ # and the index files
161
+ gen_file_index
162
+ gen_class_index
163
+ gen_method_index
164
+ gen_main_index
165
+
166
+ # this method is defined in the template file
167
+ write_extra_pages if defined? write_extra_pages
168
+ end
169
+
170
+ def gen_into(list)
171
+ list.each do |item|
172
+ if item.document_self
173
+ op_file = item.path
174
+ FileUtils.mkdir_p(::File.dirname(op_file))
175
+ open(op_file, "w") { |file| item.write_on(file) }
176
+ end
177
+ end
178
+
179
+ end
180
+
181
+ def gen_file_index
182
+ gen_an_index @files, 'Files', @template::FILE_INDEX, "fr_file_index.html"
183
+ end
184
+
185
+ def gen_class_index
186
+ gen_an_index(@classes, 'Classes', @template::CLASS_INDEX,
187
+ "fr_class_index.html")
188
+ end
189
+
190
+ def gen_method_index
191
+ gen_an_index(RDocF95::Generator::Method.all_methods, 'Methods',
192
+ @template::METHOD_INDEX, "fr_method_index.html")
193
+ end
194
+
195
+ def gen_an_index(collection, title, template, filename)
196
+ template = RDocF95::TemplatePage.new @template::FR_INDEX_BODY, template
197
+ res = []
198
+ collection.sort.each do |f|
199
+ if f.document_self
200
+ res << { "href" => f.path, "name" => f.index_name }
201
+ end
202
+ end
203
+
204
+ values = {
205
+ "entries" => res,
206
+ 'list_title' => CGI.escapeHTML(title),
207
+ 'index_url' => main_url,
208
+ 'charset' => @options.charset,
209
+ 'style_url' => style_url('', @options.css),
210
+ }
211
+
212
+ open filename, 'w' do |f|
213
+ template.write_html_on(f, values)
214
+ end
215
+ end
216
+
217
+ ##
218
+ # The main index page is mostly a template frameset, but includes the
219
+ # initial page. If the <tt>--main</tt> option was given, we use this as
220
+ # our main page, otherwise we use the first file specified on the command
221
+ # line.
222
+
223
+ def gen_main_index
224
+ template = RDocF95::TemplatePage.new @template::INDEX
225
+
226
+ open 'index.html', 'w' do |f|
227
+ classes = @classes.sort.map { |klass| klass.value_hash }
228
+
229
+ values = {
230
+ 'main_page' => @main_page,
231
+ 'initial_page' => main_url,
232
+ 'style_url' => style_url('', @options.css),
233
+ 'title' => CGI.escapeHTML(@options.title),
234
+ 'charset' => @options.charset,
235
+ 'classes' => classes,
236
+ }
237
+
238
+ values['inline_source'] = @options.inline_source
239
+
240
+ template.write_html_on f, values
241
+ end
242
+ end
243
+
244
+ ##
245
+ # Returns the url of the main page
246
+
247
+ def main_url
248
+ @main_page = @options.main_page
249
+ @main_page_ref = nil
250
+ if @main_page
251
+ @main_page_ref = AllReferences[@main_page]
252
+ if @main_page_ref then
253
+ @main_page_path = @main_page_ref.path
254
+ else
255
+ $stderr.puts "Could not find main page #{@main_page}"
256
+ end
257
+ end
258
+
259
+ unless @main_page_path then
260
+ file = @files.find { |file| file.document_self }
261
+ @main_page_path = file.path if file
262
+ end
263
+
264
+ unless @main_page_path then
265
+ $stderr.puts "Couldn't find anything to document"
266
+ $stderr.puts "Perhaps you've used :stopdoc: in all classes"
267
+ exit 1
268
+ end
269
+
270
+ @main_page_path
271
+ end
272
+
273
+ end
274
+
275
+ class RDocF95::Generator::HTMLInOne < RDocF95::Generator::HTML
276
+
277
+ def initialize(*args)
278
+ super
279
+ end
280
+
281
+ ##
282
+ # Build the initial indices and output objects
283
+ # based on an array of TopLevel objects containing
284
+ # the extracted information.
285
+
286
+ def generate(info)
287
+ @toplevels = info
288
+ @hyperlinks = {}
289
+
290
+ build_indices
291
+ generate_xml
292
+ end
293
+
294
+ ##
295
+ # Generate:
296
+ #
297
+ # * a list of RDocF95::Generator::File objects for each TopLevel object.
298
+ # * a list of RDocF95::Generator::Class objects for each first level
299
+ # class or module in the TopLevel objects
300
+ # * a complete list of all hyperlinkable terms (file,
301
+ # class, module, and method names)
302
+
303
+ def build_indices
304
+ @files, @classes = RDocF95::Generator::Context.build_indices(@toplevels,
305
+ @options)
306
+ end
307
+
308
+ ##
309
+ # Generate all the HTML. For the one-file case, we generate
310
+ # all the information in to one big hash
311
+
312
+ def generate_xml
313
+ values = {
314
+ 'charset' => @options.charset,
315
+ 'files' => gen_into(@files),
316
+ 'classes' => gen_into(@classes),
317
+ 'title' => CGI.escapeHTML(@options.title),
318
+ }
319
+
320
+ # this method is defined in the template file
321
+ write_extra_pages if defined? write_extra_pages
322
+
323
+ template = RDocF95::TemplatePage.new @template::ONE_PAGE
324
+
325
+ if @options.op_name
326
+ opfile = open @options.op_name, 'w'
327
+ else
328
+ opfile = $stdout
329
+ end
330
+ template.write_html_on(opfile, values)
331
+ end
332
+
333
+ def gen_into(list)
334
+ res = []
335
+ list.each do |item|
336
+ res << item.value_hash
337
+ end
338
+ res
339
+ end
340
+
341
+ def gen_file_index
342
+ gen_an_index(@files, 'Files')
343
+ end
344
+
345
+ def gen_class_index
346
+ gen_an_index(@classes, 'Classes')
347
+ end
348
+
349
+ def gen_method_index
350
+ gen_an_index(RDocF95::Generator::Method.all_methods, 'Methods')
351
+ end
352
+
353
+ def gen_an_index(collection, title)
354
+ res = []
355
+ collection.sort.each do |f|
356
+ if f.document_self
357
+ res << { "href" => f.path, "name" => f.index_name }
358
+ end
359
+ end
360
+
361
+ return {
362
+ "entries" => res,
363
+ 'list_title' => title,
364
+ 'index_url' => main_url,
365
+ }
366
+ end
367
+
368
+ end
369
+
370
+