Unified · Split
| @@ -4,14 +4,17 @@ module Docs · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | PKG_INDEX_ENTRIES = Hash.new [] | 5 | PKG_INDEX_ENTRIES = Hash.new [] |
| 6 | 6 | ||
| 7 | def initialize(*) | 7 | def call |
| 8 | super | ||
| 9 | |||
| 10 | if slug_parts[-1] == '00Index' | 8 | if slug_parts[-1] == '00Index' |
| 9 | dir = File.dirname(result[:subpath]) | ||
| 11 | css('tr a').each do |link| | 10 | css('tr a').each do |link| |
| 12 | PKG_INDEX_ENTRIES[link['href']] += [link.text] | 11 | PKG_INDEX_ENTRIES[link['href']] += [link.text] |
| 12 | next if link['href'] == link.text | ||
| 13 | context[:replace_paths][File.join(dir, "#{link.text}.html")] = File.join(dir, "#{link['href']}.html") | ||
| 13 | end | 14 | end |
| 14 | end | 15 | end |
| 16 | |||
| 17 | super | ||
| 15 | end | 18 | end |
| 16 | 19 | ||
| 17 | def slug_parts | 20 | def slug_parts |
| @@ -29,14 +29,12 @@ module Docs · 28 unmodified lines | |||
| 29 | /\.pdf$/ | 29 | /\.pdf$/ |
| 30 | ] | 30 | ] |
| 31 | 31 | ||
| 32 | ## We want to fix links like so − but only if the targets don’t exist, | 32 | options[:replace_paths] = { |
| 33 | ## as these target packages or keywords that do not have their own file, | 33 | ## We want to fix links like so − but only if the targets don’t exist: |
| 34 | ## but exist on another page, and we properly record it. | 34 | # 'library/MASS/html/cov.mve.html' => 'library/MASS/html/cov.rob.html' |
| 35 | # | 35 | ## Paths for target packages or keywords that do not have their own file |
| 36 | #options[:fix_urls] = ->(url) do | 36 | ## are generated in the entries filter from 00Index.html files |
| 37 | # url.sub!(%r'/library/([^/]+)/doc/index.html$') { |m| "/r-#{$1.parameterize.downcase}/" } | 37 | } |
| 38 | # url.sub!(%r'/library/([^/]+)/html/([^/]+).html$') { |m| "/library/#{$1.parameterize.downcase}/html/#{$2.parameterize.downcase}" } | ||
| 39 | #end | ||
| 40 | 38 | ||
| 41 | options[:skip] = %w( | 39 | options[:skip] = %w( |
| 42 | doc/html/packages-head-utf8.html | 40 | doc/html/packages-head-utf8.html |