This commit * Makes lib/ entries get indexed correctly; * Stops the types associated with functions from being filtered away, and orders their "Types" heading under the function heading; and * Cleans out onmouseover/onmouseout attributes.
Showing the changes to lib/docs (3 of 4 files). Show all
Unified · Split
| @@ -30,34 +30,47 @@ module Docs · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | # others |
| 32 | 32 | |
| 33 | + # Remove JS on-hover highlighting | |
| 34 | + css('h3.title-link', 'h4.data-type-name', 'h4.func-head').each do |node| | |
| 35 | + node.remove_attribute('onmouseover') | |
| 36 | + node.remove_attribute('onmouseout') | |
| 37 | + end | |
| 38 | + | |
| 33 | 39 | css('a[name]').each do |node| |
| 34 | − # parent = node.parent | |
| 35 | − # parent = parent.parent while parent.name == 'span' | |
| 36 | − (node.next_element || node.parent)['id'] ||= node['name'] | |
| 37 | 40 | node.before(node.children).remove |
| 38 | 41 | end |
| 39 | 42 | |
| 40 | 43 | css('h3').each do |node| |
| 41 | − node.name = 'h2' | |
| 42 | 44 | content = node.content |
| 43 | 45 | node.content = content.capitalize if content == content.upcase |
| 44 | 46 | end |
| 45 | 47 | |
| 46 | − css('p > .bold_code:first-child ~ br:last-child').each do |node| | |
| 47 | − parent = node.parent | |
| 48 | − parent.name = 'h3' | |
| 49 | − parent.css('> br').remove | |
| 50 | − parent.css('> code').each do |code| | |
| 51 | − code.css('*:not(a):not(br)').each { |n| n.before(n.children).remove } | |
| 52 | − code.inner_html = code.inner_html.gsub('<br>', "\n").strip | |
| 53 | − end | |
| 48 | + # Subsume "Types" heading under function head heading | |
| 49 | + css('h4.func-head + .fun-types > h3.func-types-title') | |
| 50 | + .each { |node| node.name = 'h5' } | |
| 51 | + | |
| 52 | + css('h3', 'h4', 'h5').each do |node| | |
| 53 | + node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } | |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | − css('pre:not(.REFTYPES) *:not(a)', 'a[href^=javascript]').each do |node| | |
| 57 | − node.before(node.children).remove | |
| 56 | + # Convert <span/> code blocks to <code/> if inline otherwise | |
| 57 | + # <pre><code/></pre>. | |
| 58 | + css('span.bold_code', 'span.code', '.func-head > span.title-name').each do |node| | |
| 59 | + node.remove_attribute('class') | |
| 60 | + node.css('span.bold_code', 'span.code') | |
| 61 | + .each { |n| n.before(n.children).remove } | |
| 62 | + if node.at_css('br') then | |
| 63 | + node.name = 'pre' | |
| 64 | + node.inner_html = "<code>" + | |
| 65 | + node.inner_html.remove(/\n/).gsub('<br>', "\n").strip + | |
| 66 | + "</code>" | |
| 67 | + else | |
| 68 | + node.name = 'code' | |
| 69 | + node.inner_html = node.inner_html.strip.gsub(/\s+/, ' ') | |
| 70 | + end | |
| 58 | 71 | end |
| 59 | 72 | |
| 60 | − css('pre:not(.REFTYPES)').each do |node| | |
| 73 | + css('*:not(.REFTYPES) > pre').each do |node| | |
| 61 | 74 | node['data-language'] = 'erlang' |
| 62 | 75 | node.inner_html = node.inner_html.strip_heredoc |
| 63 | 76 | end |
| @@ -70,23 +83,7 @@ module Docs · 6 unmodified lines | ||
| 70 | 83 | end |
| 71 | 84 | end |
| 72 | 85 | |
| 73 | − css('.REFTYPES').each do |node| | |
| 74 | − next unless node.parent | |
| 75 | − html = "<pre>" | |
| 76 | − while node['class'] == 'REFTYPES' | |
| 77 | − node.inner_html = node.inner_html.remove(/\n/).gsub('<br>', "\n") | |
| 78 | − node.css('*:not(a)').each { |n| n.before(n.children).remove } | |
| 79 | − html << node.inner_html.strip + "\n" | |
| 80 | − node = node.next_element | |
| 81 | − node.previous_element.remove | |
| 82 | − end | |
| 83 | − html.gsub! %r{\n{2,}}, "\n" | |
| 84 | − html.strip! | |
| 85 | − html << "</pre>" | |
| 86 | − node.before(html) | |
| 87 | − end | |
| 88 | − | |
| 89 | − css('.REFTYPES').remove | |
| 86 | + css('a[href^=javascript]').each { |n| n.before(n.children).remove } | |
| 90 | 87 | |
| 91 | 88 | css('table').each do |node| |
| 92 | 89 | node.remove_attribute('border') |
| @@ -99,8 +96,6 @@ module Docs · 6 unmodified lines | ||
| 99 | 96 | node.remove_attribute('valign') |
| 100 | 97 | end |
| 101 | 98 | |
| 102 | − css('.bold_code').remove_attr('class') | |
| 103 | − | |
| 104 | 99 | doc |
| 105 | 100 | end |
| 106 | 101 | end |
| @@ -44,10 +44,9 @@ module Docs · 43 unmodified lines | ||
| 44 | 44 | if subpath.start_with?('lib/') |
| 45 | 45 | names = Set.new |
| 46 | 46 | entry_nodes.each_with_object [] do |node, entries| |
| 47 | − id = node['name'] | |
| 47 | + id = node['id'] | |
| 48 | 48 | name = id.remove %r{\-\d*\z} |
| 49 | 49 | name << ' (type)' if name.sub!(/\Atype-/, '') |
| 50 | − name.remove! 'Module:' | |
| 51 | 50 | name.prepend "#{self.name}:" |
| 52 | 51 | entries << [name, id] if names.add?(name) |
| 53 | 52 | end |
| @@ -67,9 +66,7 @@ module Docs · 13 unmodified lines | ||
| 67 | 66 | |
| 68 | 67 | def entry_nodes |
| 69 | 68 | @entry_nodes ||= if subpath.start_with?('lib/') |
| 70 | − css('p + div.REFBODY').each_with_object [] do |node, result| | |
| 71 | − result.concat(node.previous_element.css('a[name]').to_a) | |
| 72 | − end | |
| 69 | + css('article.func > h4', 'article.data-types-body > h4').entries | |
| 73 | 70 | elsif subpath.start_with?('erts') |
| 74 | 71 | link = at_css(".flipMenu a[href='#{File.basename(subpath, '.html')}']") |
| 75 | 72 | list = link.parent.parent |
| @@ -4,15 +4,6 @@ module Docs · 3 unmodified lines | ||
| 4 | 4 | def call |
| 5 | 5 | css('.flipMenu li[title] > a').remove unless subpath.start_with?('erts') # perf |
| 6 | 6 | |
| 7 | − css('.REFTYPES').each do |node| | |
| 8 | − node.name = 'pre' | |
| 9 | − end | |
| 10 | − | |
| 11 | − css('span.bold_code', 'span.code').each do |node| | |
| 12 | − node.name = 'code' | |
| 13 | − node.inner_html = node.inner_html.strip.gsub(/\s+/, ' ') | |
| 14 | − end | |
| 15 | − | |
| 16 | 7 | doc |
| 17 | 8 | end |
| 18 | 9 | end |