mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
5 changed files with 33 additions and 6 deletions
|
@ -220,8 +220,8 @@ class RDoc::Generator::Darkfish
|
|||
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
||||
end
|
||||
|
||||
@options.template_stylesheets.each do |stylesheet|
|
||||
FileUtils.cp stylesheet, '.', options
|
||||
unless @options.template_stylesheets.empty?
|
||||
FileUtils.cp @options.template_stylesheets, '.', **options
|
||||
end
|
||||
|
||||
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/rdoc.css" rel="stylesheet">
|
||||
<%- if @options.template_stylesheets.flatten.any? then -%>
|
||||
<%- @options.template_stylesheets.flatten.each do |stylesheet| -%>
|
||||
<%- @options.template_stylesheets.each do |stylesheet| -%>
|
||||
<link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
|
|
|
@ -971,7 +971,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|||
opt.on("--template-stylesheets=FILES", PathArray,
|
||||
"Set (or add to) the list of files to",
|
||||
"include with the html template.") do |value|
|
||||
@template_stylesheets << value
|
||||
@template_stylesheets.concat value
|
||||
end
|
||||
|
||||
opt.separator nil
|
||||
|
|
|
@ -220,6 +220,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
|
|||
assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }'
|
||||
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
|
||||
# @tmpdir are supported.
|
||||
|
|
|
@ -632,6 +632,21 @@ rdoc_include:
|
|||
$LOAD_PATH.replace orig_LOAD_PATH
|
||||
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
|
||||
@options.parse %w[--visibility=public]
|
||||
assert_equal :public, @options.visibility
|
||||
|
|
Loading…
Reference in a new issue