From c0438ac2237085bdfbfe5e958ee68f3b2eb2cf23 Mon Sep 17 00:00:00 2001 From: Petrik Date: Thu, 1 May 2025 10:22:16 +0200 Subject: [PATCH] Set language in HTML Setting the language helps with search engines, screen readers and text rendering. The language defaults to `en` as that is probably most common (it's also the default for navigation in Darkfish). Setting the `locale` option will override the language to the locale. Co-authored-by: Vinicius Stock --- lib/rdoc/generator/darkfish.rb | 2 +- test/rdoc/rdoc_generator_darkfish_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 9dede3aaff..7fec36500f 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -595,7 +595,7 @@ def assemble_template(body_file) <<-TEMPLATE - + #{head_file.read} diff --git a/test/rdoc/rdoc_generator_darkfish_test.rb b/test/rdoc/rdoc_generator_darkfish_test.rb index 580d25b360..7fc6328fea 100644 --- a/test/rdoc/rdoc_generator_darkfish_test.rb +++ b/test/rdoc/rdoc_generator_darkfish_test.rb @@ -388,6 +388,21 @@ def test_template_stylesheets assert_include File.binread('index.html'), %Q[href="./#{base}"] end + def test_html_lang + @g.generate + + content = File.binread("index.html") + assert_include(content, '') + end + + def test_html_lang_from_locale + @options.locale = RDoc::I18n::Locale.new 'ja' + @g.generate + + content = File.binread("index.html") + assert_include(content, '') + end + def test_title title = "RDoc Test".freeze @options.title = title