Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Mar 11, 2016
1 parent 9401e38 commit 06ccf3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 0 additions & 2 deletions lib/sdoc/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ def generate_class_files
@classes.each do |klass|
debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ]
outfile = @outputdir + klass.path
rel_prefix = @outputdir.relative_path_from( outfile.dirname )

debug_msg " rendering #{outfile}"
self.render_template( templatefile, binding(), outfile ) unless @options.dry_run
Expand All @@ -325,7 +324,6 @@ def generate_file_files
@files.each do |file|
outfile = @outputdir + file.path
debug_msg " working on %s (%s)" % [ file.full_name, outfile ]
rel_prefix = @outputdir.relative_path_from( outfile.dirname )

debug_msg " rendering #{outfile}"
self.render_template( templatefile, binding(), outfile ) unless @options.dry_run
Expand Down
8 changes: 3 additions & 5 deletions lib/sdoc/templatable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'erb'
require "sdoc"

module SDoc::Templatable
### Load and render the erb template in the given +templatefile+ within the
Expand All @@ -18,15 +17,15 @@ def eval_template(templatefile, context)
err.message,
eval( "_erbout[-50,50]", context )
], err.backtrace
end
end
end

### Load and render the erb template with the given +template_name+ within
### current context. Adds all +local_assigns+ to context
def include_template(template_name, local_assigns = {})
source = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join
templatefile = @template_dir + template_name
eval("#{source};eval_template(templatefile, binding)")
eval("#{source};eval_template(#{templatefile}, binding)")
end

### Load and render the erb template in the given +templatefile+ within the
Expand All @@ -43,8 +42,7 @@ def render_template( templatefile, context, outfile )
else
output = output.gsub('<script>', '&lt;script&gt;')
end
rescue Exception => e

rescue Exception
end

unless $dryrun
Expand Down
16 changes: 8 additions & 8 deletions spec/rdoc_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,43 @@
it "should parse github option" do
assert !@options.github

out, err = capture_io do
_, err = capture_io do
@parser.parse %w[--github]
end

err.wont_match /^invalid options/
err.wont_match(/^invalid options/)
@options.github.must_equal true
end

it "should parse github short-hand option" do
assert !@options.github

out, err = capture_io do
_, err = capture_io do
@parser.parse %w[-g]
end

err.wont_match /^invalid options/
err.wont_match(/^invalid options/)
@options.github.must_equal true
end

it "should parse no search engine index option" do
@options.search_index.must_equal true

out, err = capture_io do
_, err = capture_io do
@parser.parse %w[--without-search]
end

err.wont_match /^invalid options/
err.wont_match(/^invalid options/)
@options.search_index.must_equal false
end

it "should parse search-index shorthand option" do
@options.search_index.must_equal true
out, err = capture_io do
_, err = capture_io do
@parser.parse %w[-s]
end

err.wont_match /^invalid options/
err.wont_match(/^invalid options/)
@options.search_index.must_equal false
end

Expand Down

0 comments on commit 06ccf3e

Please sign in to comment.