Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def self.home
autoload :Context, "#{__dir__}/rdoc/code_object/context"
autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level"

autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class"
autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module"
autoload :NormalClass, "#{__dir__}/rdoc/code_object/normal_class"
autoload :NormalModule, "#{__dir__}/rdoc/code_object/normal_module"
Expand Down
1 change: 0 additions & 1 deletion lib/rdoc/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# * RDoc::Context
# * RDoc::TopLevel
# * RDoc::ClassModule
# * RDoc::AnonClass (never used so far)
# * RDoc::NormalClass
# * RDoc::NormalModule
# * RDoc::SingleClass
Expand Down
10 changes: 0 additions & 10 deletions lib/rdoc/code_object/anon_class.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/rdoc/code_object/context/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def legacy_aref
#
# # :section: The title
# # The body
#
#--
# TODO Remove when the ripper parser has been removed

def extract_comment(comment)
case comment
Expand Down
5 changes: 0 additions & 5 deletions lib/rdoc/generator/darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ class RDoc::Generator::Darkfish
css/rdoc.css
]

##
# Release Version

VERSION = '3'

##
# Description of this generator

Expand Down
7 changes: 0 additions & 7 deletions lib/rdoc/markup/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@

class RDoc::Markup::Formatter

##
# Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
# +off+ triggers.

InlineTag = Struct.new(:bit, :on, :off)


##
# Converts a target url to one that is relative to a given path

Expand Down
2 changes: 0 additions & 2 deletions lib/rdoc/markup/to_html_crossref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml

# :stopdoc:
ALL_CROSSREF_REGEXP = RDoc::CrossReference::ALL_CROSSREF_REGEXP
CLASS_REGEXP_STR = RDoc::CrossReference::CLASS_REGEXP_STR
CROSSREF_REGEXP = RDoc::CrossReference::CROSSREF_REGEXP
METHOD_REGEXP_STR = RDoc::CrossReference::METHOD_REGEXP_STR
# :startdoc:

##
Expand Down
17 changes: 15 additions & 2 deletions lib/rdoc/parser/prism_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,28 @@ def parse_comment_text_to_directives(comment_text, start_line) # :nodoc:
comment.line = start_line
markup, = directives['markup']
comment.format = markup&.downcase || @markup
if (section, = directives['section'])
if (section, directive_line = directives['section'])
# If comment has :section:, it is not a documentable comment for a code object
@container.set_current_section(section, comment.dup)
comment.text = extract_section_comment(comment_text, directive_line - start_line)
@container.set_current_section(section, comment)
return
end
@preprocess.run_post_processes(comment, @container)
[comment, directives]
end

# Extracts the comment for this section from the normalized comment block.
# Removes all lines before the line that contains :section:
# If the comment also ends with the same content, remove it as well

def extract_section_comment(comment_text, prefix_line_count) # :nodoc:
prefix = comment_text.lines[0...prefix_line_count].join
comment_text.delete_prefix!(prefix)
# Comment is already normalized and doesn't end with a newline
comment_text.delete_suffix!(prefix.chomp)
comment_text
end

def slice_tokens(start_pos, end_pos) # :nodoc:
start_index = @tokens.bsearch_index { |t| ([t.line_no, t.char_no] <=> start_pos) >= 0 }
end_index = @tokens.bsearch_index { |t| ([t.line_no, t.char_no] <=> end_pos) >= 0 }
Expand Down
35 changes: 35 additions & 0 deletions test/rdoc/parser/prism_ruby_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,41 @@ def test_look_for_directives_in_section
assert_equal 'new section', section.title
end

def test_section_with_divider
util_parser <<~RUBY
# DIVIDER
# :section: section 1
# foo
# DIVIDER

# DIVIDER 1
# DIVIDER 2
# :section: section 2
# foo
# DIVIDER 1
# DIVIDER 2

# DIVIDER TOP ONLY
# :section: section 3
# foo

# DIVIDER TOP ONLY
# :section: section 4
RUBY

section = @top_level.sections_hash['section 1']
assert_equal "\n<p>foo</p>\n", section.description

section = @top_level.sections_hash['section 2']
assert_equal "\n<p>foo</p>\n", section.description

section = @top_level.sections_hash['section 3']
assert_equal "\n<p>foo</p>\n", section.description

section = @top_level.sections_hash['section 4']
assert_equal '', section.description
end

def test_look_for_directives_in_commented
util_parser <<~RUBY
# how to make a section:
Expand Down
Loading