| @@ -4,11 +4,7 @@ module Docs · 3 unmodified lines |
| 4 | def call | 4 | def call |
| 5 | | 5 | |
| 6 | # remove unwanted elements | 6 | # remove unwanted elements |
| 7 | css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.show .empty', '.package').remove | 7 | css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.package').remove |
| 8 | | | |
| 9 | css('pre').each do |node| | | |
| 10 | node.add_css_class('example') | | |
| 11 | end | | |
| 12 | | 8 | |
| 13 | # cpations in tables are h3 | 9 | # cpations in tables are h3 |
| 14 | css('table .caption').each do |node| | 10 | css('table .caption').each do |node| |
| @@ -20,6 +16,7 @@ module Docs · 5 unmodified lines |
| 20 | node.name = 'h1' | 16 | node.name = 'h1' |
| 21 | end | 17 | end |
| 22 | | 18 | |
| | 19 | # section |
| 23 | css('.top > .caption').each do |node| | 20 | css('.top > .caption').each do |node| |
| 24 | node.name = 'h2' | 21 | node.name = 'h2' |
| 25 | end | 22 | end |
| @@ -34,39 +31,79 @@ module Docs · 8 unmodified lines |
| 34 | node.name = 'h4' | 31 | node.name = 'h4' |
| 35 | end | 32 | end |
| 36 | | 33 | |
| | 34 | # ... |
| 37 | css('.top > .subs > .subs > .subs > .caption').each do |node| | 35 | css('.top > .subs > .subs > .subs > .caption').each do |node| |
| 38 | node.name = 'h5' | 36 | node.name = 'h5' |
| 39 | end | 37 | end |
| 40 | | 38 | |
| | 39 | # ...... |
| 41 | css('.top > .subs > .subs > .subs > .subs > .caption').each do |node| | 40 | css('.top > .subs > .subs > .subs > .subs > .caption').each do |node| |
| 42 | node.name = 'h6' | 41 | node.name = 'h6' |
| 43 | end | 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 | # turn source listing in to pre | 49 | # turn source listing in to pre |
| 46 | css('.src').each do |node| | 50 | css('.src').each do |node| |
| 47 | if node.name == "td" | 51 | if node.name != "td" |
| 48 | # pre = doc.create_element 'pre' | | |
| 49 | # pre.children = node.children | | |
| 50 | # node.children = [pre] | | |
| 51 | else | | |
| 52 | node.name = 'pre' | 52 | node.name = 'pre' |
| 53 | end | 53 | end |
| 54 | end | 54 | end |
| 55 | | 55 | |
| 56 | if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries' | 56 | # check if second column of table is totally empty. |
| 57 | css('h1').remove | 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 | end | 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 | css('a').each do |node| | 98 | css('a').each do |node| |
| 61 | if node['name'] | 99 | if node['name'] |
| 62 | node['id'] = node['name'] | 100 | node['id'] = node['name'] |
| 63 | end | 101 | end |
| 64 | end | 102 | end |
| 65 | | 103 | |
| 66 | css('.caption').each do |node| | 104 | # make code in description into proper pre |
| 67 | if node.content == 'Arguments' | 105 | css('dd > code').each do |node| |
| 68 | node.remove | 106 | node.name = 'pre' |
| 69 | end | | |
| 70 | end | 107 | end |
| 71 | | 108 | |
| 72 | # add some informational boxes | 109 | # add some informational boxes |
| @@ -86,8 +123,8 @@ module Docs · 13 unmodified lines |
| 86 | # </p> | 123 | # </p> |
| 87 | if node.previous == nil | 124 | if node.previous == nil |
| 88 | node.add_css_class('complexity') # add css class | 125 | node.add_css_class('complexity') # add css class |
| 89 | node.name="span" # just make it div | 126 | node.name="span" # just make it div |
| 90 | node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em | 127 | node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em |
| 91 | node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em | 128 | node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em |
| 92 | | 129 | |
| 93 | # reparent the nodes | 130 | # reparent the nodes |
| @@ -100,7 +137,11 @@ module Docs · 6 unmodified lines |
| 100 | end | 137 | end |
| 101 | elsif node.content =~ /Since: .*/ | 138 | elsif node.content =~ /Since: .*/ |
| 102 | # add box to 'Since:' annotations | 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 | end | 145 | end |
| 105 | end | 146 | end |
| 106 | | 147 | |