230
230
231
231
# :stopdoc:
232
232
233
- TMPFILE = ["rdtmp", $$, 0]
234
-
235
233
MARK_TO_LEVEL = {
236
234
'=' => 1,
237
235
'==' => 2,
@@ -341,15 +339,19 @@ def next_token # :nodoc:
341
339
# non-RD part begin
342
340
when /^=begin\s+(\w+)/
343
341
part = $1
342
+ =begin # not imported to RDoc
344
343
if @in_part # if in non-RD part
345
344
@part_content.push(line)
346
345
else
347
346
@in_part = part if @tree.filter[part] # if filter exists
348
347
# p "BEGIN_PART: #{@in_part}" # DEBUG
349
348
end
349
+ =end
350
+ @in_part = part
350
351
# non-RD part end
351
- when /^=end/
352
+ when /^=end(?:$|[\s\0\C-d\C-z]) /
352
353
if @in_part # if in non-RD part
354
+ =begin # not imported to RDoc
353
355
# p "END_PART: #{@in_part}" # DEBUG
354
356
# make Part-in object
355
357
part = RDoc::RD::Part.new(@part_content.join(""), @tree, "r")
@@ -360,20 +362,22 @@ def next_token # :nodoc:
360
362
if @tree.filter[@in_part].mode == :rd # if output is RD formatted
361
363
subtree = parse_subtree(part_out.to_a)
362
364
else # if output is target formatted
363
- basename = TMPFILE.join('.')
364
- TMPFILE[-1] += 1
365
- tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
366
- tmpfile.print(part_out)
367
- tmpfile.close
365
+ basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
366
+ tmpfile.print(part_out)
367
+ File.basename(tmpfile.path)
368
+ end
368
369
subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
369
370
end
370
371
@in_part = nil
371
372
return [:SUBTREE, subtree]
373
+ =end
372
374
end
373
375
else
376
+ =begin # not imported to RDoc
374
377
if @in_part # if in non-RD part
375
378
@part_content.push(line)
376
379
end
380
+ =end
377
381
end
378
382
end
379
383
0 commit comments