summaryrefslogtreecommitdiff
path: root/jni/ruby/lib/rdoc/markup/to_test.rb
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/lib/rdoc/markup/to_test.rb
Fresh start
Diffstat (limited to 'jni/ruby/lib/rdoc/markup/to_test.rb')
-rw-r--r--jni/ruby/lib/rdoc/markup/to_test.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/jni/ruby/lib/rdoc/markup/to_test.rb b/jni/ruby/lib/rdoc/markup/to_test.rb
new file mode 100644
index 0000000..c51f64b
--- /dev/null
+++ b/jni/ruby/lib/rdoc/markup/to_test.rb
@@ -0,0 +1,69 @@
+##
+# This Markup outputter is used for testing purposes.
+
+class RDoc::Markup::ToTest < RDoc::Markup::Formatter
+
+ # :stopdoc:
+
+ ##
+ # :section: Visitor
+
+ def start_accepting
+ @res = []
+ @list = []
+ end
+
+ def end_accepting
+ @res
+ end
+
+ def accept_paragraph(paragraph)
+ @res << convert_flow(@am.flow(paragraph.text))
+ end
+
+ def accept_raw raw
+ @res << raw.parts.join
+ end
+
+ def accept_verbatim(verbatim)
+ @res << verbatim.text.gsub(/^(\S)/, ' \1')
+ end
+
+ def accept_list_start(list)
+ @list << case list.type
+ when :BULLET then
+ '*'
+ when :NUMBER then
+ '1'
+ else
+ list.type
+ end
+ end
+
+ def accept_list_end(list)
+ @list.pop
+ end
+
+ def accept_list_item_start(list_item)
+ @res << "#{' ' * (@list.size - 1)}#{@list.last}: "
+ end
+
+ def accept_list_item_end(list_item)
+ end
+
+ def accept_blank_line(blank_line)
+ @res << "\n"
+ end
+
+ def accept_heading(heading)
+ @res << "#{'=' * heading.level} #{heading.text}"
+ end
+
+ def accept_rule(rule)
+ @res << '-' * rule.weight
+ end
+
+ # :startdoc:
+
+end
+