| @@ -4,11 +4,7 @@ module Docs · 3 unmodified lines |
| 4 | 4 | def call |
| 5 | 5 | |
| 6 | 6 | # remove unwanted elements |
| 7 | | − css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.show .empty', '.package').remove |
| 8 | | − |
| 9 | | − css('pre').each do |node| |
| 10 | | − node.add_css_class('example') |
| 11 | | − end |
| 7 | + css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.package').remove |
| 12 | 8 | |
| 13 | 9 | # cpations in tables are h3 |
| 14 | 10 | css('table .caption').each do |node| |
| @@ -20,6 +16,7 @@ module Docs · 5 unmodified lines |
| 20 | 16 | node.name = 'h1' |
| 21 | 17 | end |
| 22 | 18 | |
| 19 | + # section |
| 23 | 20 | css('.top > .caption').each do |node| |
| 24 | 21 | node.name = 'h2' |
| 25 | 22 | end |
| @@ -34,39 +31,79 @@ module Docs · 8 unmodified lines |
| 34 | 31 | node.name = 'h4' |
| 35 | 32 | end |
| 36 | 33 | |
| 34 | + # ... |
| 37 | 35 | css('.top > .subs > .subs > .subs > .caption').each do |node| |
| 38 | 36 | node.name = 'h5' |
| 39 | 37 | end |
| 40 | 38 | |
| 39 | + # ...... |
| 41 | 40 | css('.top > .subs > .subs > .subs > .subs > .caption').each do |node| |
| 42 | 41 | node.name = 'h6' |
| 43 | 42 | end |
| 44 | 43 | |
| 44 | + # all pre's are examples |
| 45 | + css('pre').each do |node| |
| 46 | + node.add_css_class('example') |
| 47 | + end |
| 48 | + |
| 45 | 49 | # turn source listing in to pre |
| 46 | 50 | css('.src').each do |node| |
| 47 | | − if node.name == "td" |
| 48 | | − # pre = doc.create_element 'pre' |
| 49 | | − # pre.children = node.children |
| 50 | | − # node.children = [pre] |
| 51 | | − else |
| 51 | + if node.name != "td" |
| 52 | 52 | node.name = 'pre' |
| 53 | 53 | end |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | | − if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries' |
| 57 | | − css('h1').remove |
| 56 | + # check if second column of table is totally empty. |
| 57 | + # and remove it if it is |
| 58 | + css('table').each do |table| |
| 59 | + empty = true |
| 60 | + table.css('td + td').each do |snd| |
| 61 | + empty = empty && snd['class'] =~ /empty/ |
| 62 | + end |
| 63 | + if empty |
| 64 | + # remove empty column |
| 65 | + table.css('td + td').remove |
| 66 | + end |
| 58 | 67 | end |
| 59 | 68 | |
| 69 | + # move table captions into the tables |
| 70 | + css(".caption + table").each do |table| |
| 71 | + caption = table.previous |
| 72 | + caption.name = "caption" |
| 73 | + caption.parent = table |
| 74 | + end |
| 75 | + |
| 76 | + css(".caption + .show table").each do |table| |
| 77 | + caption = table.parent.parent.css('.caption')[0] |
| 78 | + caption.name = 'caption' |
| 79 | + caption.parent = table |
| 80 | + end |
| 81 | + |
| 82 | + # better arguments display: |
| 83 | + css('.src + .arguments table').each do |table| |
| 84 | + src = table.parent.previous # the function name |
| 85 | + row = doc.document.create_element('tr') |
| 86 | + table.css('tr')[0].before(row) |
| 87 | + src.parent = row |
| 88 | + src.name = "th" |
| 89 | + src['colspan'] = 2 |
| 90 | + end |
| 91 | + |
| 92 | + # remove root page title |
| 93 | + if root_page? |
| 94 | + at_css('h1').remove |
| 95 | + end |
| 96 | + |
| 97 | + # add id to links (based on name) |
| 60 | 98 | css('a').each do |node| |
| 61 | 99 | if node['name'] |
| 62 | 100 | node['id'] = node['name'] |
| 63 | 101 | end |
| 64 | 102 | end |
| 65 | 103 | |
| 66 | | − css('.caption').each do |node| |
| 67 | | − if node.content == 'Arguments' |
| 68 | | − node.remove |
| 69 | | − end |
| 104 | + # make code in description into proper pre |
| 105 | + css('dd > code').each do |node| |
| 106 | + node.name = 'pre' |
| 70 | 107 | end |
| 71 | 108 | |
| 72 | 109 | # add some informational boxes |
| @@ -86,8 +123,8 @@ module Docs · 13 unmodified lines |
| 86 | 123 | # </p> |
| 87 | 124 | if node.previous == nil |
| 88 | 125 | node.add_css_class('complexity') # add css class |
| 89 | | − node.name="span" # just make it div |
| 90 | | − node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em |
| 126 | + node.name="span" # just make it div |
| 127 | + node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em |
| 91 | 128 | node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em |
| 92 | 129 | |
| 93 | 130 | # reparent the nodes |
| @@ -100,7 +137,11 @@ module Docs · 6 unmodified lines |
| 100 | 137 | end |
| 101 | 138 | elsif node.content =~ /Since: .*/ |
| 102 | 139 | # add box to 'Since:' annotations |
| 103 | | − node.add_css_class('added') |
| 140 | + if node.parent.parent.name == "td" |
| 141 | + node.parent.parent.add_css_class('added-cell') |
| 142 | + else |
| 143 | + node.add_css_class('added') |
| 144 | + end |
| 104 | 145 | end |
| 105 | 146 | end |
| 106 | 147 | |