Skip to content

Commit

Permalink
Change the IDs in the book slightly, and allow cross-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Aug 4, 2009
1 parent 62ee809 commit 8ca2969
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion extras/rdoc/generator/singledarkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ class RDoc::Generator::SingleDarkfish < RDoc::Generator::Darkfish
end
end
end

RDoc::Generator::Markup.instance_eval do
org = instance_method(:description)
define_method(:description) do
old = org.bind(self).call
if RDoc::Generator::SingleDarkfish.current?
old.gsub(/ href="\d\d_([^"]+)"/) do |m|
id, sub = $1.split("#")
id = File.basename(id, ".html")
id << "-#{sub}" if sub

" href=\"book.html##{id}\""
end
else
old
end
end
end

def self.current?
RDoc::RDoc.current.generator.class.ancestors.include?(self)
Expand Down Expand Up @@ -189,11 +207,11 @@ def chapters

(class << file; self; end).class_eval { attr_accessor :title, :content, :toc, :id }
file.toc = []
file.id = file.base_name[/\d\d_([^.]+)/, 1]
file.content = file.description

file.content.gsub!(%r{<h2>(.*?)</h2>}) do
file.title = $1
file.id = make_id($1)
'<h2 class="ruled" id="%s">%s</h2>' % [file.id, file.title]
end

Expand Down

0 comments on commit 8ca2969

Please sign in to comment.