[前][次][番号順一覧][スレッド一覧]

ruby-changes:68480

From: Mike <ko1@a...>
Date: Sat, 16 Oct 2021 01:39:19 +0900 (JST)
Subject: [ruby-changes:68480] fbd0516afc (master): [ruby/rdoc] fix: comments in C files use the global markup option

https://git.ruby-lang.org/ruby.git/commit/?id=fbd0516afc

From fbd0516afc2bb7219716aa4f810f83af8112ca49 Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@g...>
Date: Mon, 11 Oct 2021 17:01:52 -0400
Subject: [ruby/rdoc] fix: comments in C files use the global markup option

Previously, Parser::C comments all defaulted to "rdoc" format, even
when the user had set a different default with the `--markup=<choice>`
option.

https://github.com/ruby/rdoc/commit/4643b08a26
---
 lib/rdoc/parser/c.rb            |  6 +++++-
 test/rdoc/test_rdoc_parser_c.rb | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index ee24a271cf..111f6e2091 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -173,6 +173,8 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L173
     @classes           = load_variable_map :c_class_variables
     @singleton_classes = load_variable_map :c_singleton_class_variables
 
+    @markup = @options.markup
+
     # class_variable => { function => [method, ...] }
     @methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }
 
@@ -1223,6 +1225,8 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L1225
   end
 
   def new_comment text = nil, location = nil, language = nil
-    RDoc::Comment.new(text, location, language)
+    RDoc::Comment.new(text, location, language).tap do |comment|
+      comment.format = @markup
+    end
   end
 end
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index 41001be22c..93d19dd26f 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -1946,6 +1946,23 @@ void Init_Blah(void) { https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser_c.rb#L1946
     assert_equal("rdoc", klass.attributes.find {|a| a.name == "default_format"}.comment.format)
   end
 
+  def test_markup_format_override
+    content = <<-EOF
+void Init_Blah(void) {
+  cBlah = rb_define_class("Blah", rb_cObject);
+
+  /*
+   * This should be interpreted in the default format.
+   */
+  rb_attr(cBlah, rb_intern("default_format"), 1, 1, Qfalse);
+}
+    EOF
+
+    @options.markup = "markdown"
+    klass = util_get_class content, 'cBlah'
+    assert_equal("markdown", klass.attributes.find {|a| a.name == "default_format"}.comment.format)
+  end
+
   def util_get_class content, name = nil
     @parser = util_parser content
     @parser.scan
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]