[ruby/rdoc] Add tests for --template-stylesheets
option
Also flattens `@options.template_stylesheets` when parsing the command lines. Fixes #205 Fixes #828 too https://github.com/ruby/rdoc/commit/857002a763
This commit is contained in:
parent
33676a7aa6
commit
76c7388c1f
@ -220,8 +220,8 @@ class RDoc::Generator::Darkfish
|
|||||||
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
||||||
end
|
end
|
||||||
|
|
||||||
@options.template_stylesheets.each do |stylesheet|
|
unless @options.template_stylesheets.empty?
|
||||||
FileUtils.cp stylesheet, '.', options
|
FileUtils.cp @options.template_stylesheets, '.', **options
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
<link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
|
<link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
|
||||||
<link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
|
<link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
|
||||||
<%- if @options.template_stylesheets.flatten.any? then -%>
|
<%- @options.template_stylesheets.each do |stylesheet| -%>
|
||||||
<%- @options.template_stylesheets.flatten.each do |stylesheet| -%>
|
|
||||||
<link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
|
<link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
|
||||||
|
@ -971,7 +971,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|||||||
opt.on("--template-stylesheets=FILES", PathArray,
|
opt.on("--template-stylesheets=FILES", PathArray,
|
||||||
"Set (or add to) the list of files to",
|
"Set (or add to) the list of files to",
|
||||||
"include with the html template.") do |value|
|
"include with the html template.") do |value|
|
||||||
@template_stylesheets << value
|
@template_stylesheets.concat value
|
||||||
end
|
end
|
||||||
|
|
||||||
opt.separator nil
|
opt.separator nil
|
||||||
|
@ -220,6 +220,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
|
|||||||
assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }'
|
assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_template_stylesheets
|
||||||
|
css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.'))
|
||||||
|
File.write(css, '')
|
||||||
|
base = File.basename(css)
|
||||||
|
refute_file(base)
|
||||||
|
|
||||||
|
@options.template_stylesheets << css
|
||||||
|
|
||||||
|
@g.generate
|
||||||
|
|
||||||
|
assert_file base
|
||||||
|
assert_include File.read('index.html'), %Q[href="./#{base}"]
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Asserts that +filename+ has a link count greater than 1 if hard links to
|
# Asserts that +filename+ has a link count greater than 1 if hard links to
|
||||||
# @tmpdir are supported.
|
# @tmpdir are supported.
|
||||||
|
@ -632,6 +632,21 @@ rdoc_include:
|
|||||||
$LOAD_PATH.replace orig_LOAD_PATH
|
$LOAD_PATH.replace orig_LOAD_PATH
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parse_template_stylesheets
|
||||||
|
css = nil
|
||||||
|
Dir.mktmpdir do |dir|
|
||||||
|
css = File.join(dir, "hoge.css")
|
||||||
|
File.write(css, "")
|
||||||
|
out, err = capture_output do
|
||||||
|
@options.parse %W[--template-stylesheets #{css}]
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_empty out
|
||||||
|
assert_empty err
|
||||||
|
end
|
||||||
|
assert_include @options.template_stylesheets, css
|
||||||
|
end
|
||||||
|
|
||||||
def test_parse_visibility
|
def test_parse_visibility
|
||||||
@options.parse %w[--visibility=public]
|
@options.parse %w[--visibility=public]
|
||||||
assert_equal :public, @options.visibility
|
assert_equal :public, @options.visibility
|
||||||
|
Loading…
x
Reference in New Issue
Block a user