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 | # others | 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 | css('a[name]').each do |node| | 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 | node.before(node.children).remove | 40 | node.before(node.children).remove |
| 38 | end | 41 | end |
| 39 | 42 | ||
| 40 | css('h3').each do |node| | 43 | css('h3').each do |node| |
| 41 | node.name = 'h2' | ||
| 42 | content = node.content | 44 | content = node.content |
| 43 | node.content = content.capitalize if content == content.upcase | 45 | node.content = content.capitalize if content == content.upcase |
| 44 | end | 46 | end |
| 45 | 47 | ||
| 46 | css('p > .bold_code:first-child ~ br:last-child').each do |node| | 48 | # Subsume "Types" heading under function head heading |
| 47 | parent = node.parent | 49 | css('h4.func-head + .fun-types > h3.func-types-title') |
| 48 | parent.name = 'h3' | 50 | .each { |node| node.name = 'h5' } |
| 49 | parent.css('> br').remove | 51 | |
| 50 | parent.css('> code').each do |code| | 52 | css('h3', 'h4', 'h5').each do |node| |
| 51 | code.css('*:not(a):not(br)').each { |n| n.before(n.children).remove } | 53 | node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } |
| 52 | code.inner_html = code.inner_html.gsub('<br>', "\n").strip | ||
| 53 | end | ||
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | css('pre:not(.REFTYPES) *:not(a)', 'a[href^=javascript]').each do |node| | 56 | # Convert <span/> code blocks to <code/> if inline otherwise |
| 57 | node.before(node.children).remove | 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 | end | 71 | end |
| 59 | 72 | ||
| 60 | css('pre:not(.REFTYPES)').each do |node| | 73 | css('*:not(.REFTYPES) > pre').each do |node| |
| 61 | node['data-language'] = 'erlang' | 74 | node['data-language'] = 'erlang' |
| 62 | node.inner_html = node.inner_html.strip_heredoc | 75 | node.inner_html = node.inner_html.strip_heredoc |
| 63 | end | 76 | end |
| @@ -70,23 +83,7 @@ module Docs · 6 unmodified lines | |||
| 70 | end | 83 | end |
| 71 | end | 84 | end |
| 72 | 85 | ||
| 73 | css('.REFTYPES').each do |node| | 86 | css('a[href^=javascript]').each { |n| n.before(n.children).remove } |
| 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 | ||
| 90 | 87 | ||
| 91 | css('table').each do |node| | 88 | css('table').each do |node| |
| 92 | node.remove_attribute('border') | 89 | node.remove_attribute('border') |
| @@ -99,8 +96,6 @@ module Docs · 6 unmodified lines | |||
| 99 | node.remove_attribute('valign') | 96 | node.remove_attribute('valign') |
| 100 | end | 97 | end |
| 101 | 98 | ||
| 102 | css('.bold_code').remove_attr('class') | ||
| 103 | |||
| 104 | doc | 99 | doc |
| 105 | end | 100 | end |
| 106 | end | 101 | end |
| @@ -44,10 +44,9 @@ module Docs · 43 unmodified lines | |||
| 44 | if subpath.start_with?('lib/') | 44 | if subpath.start_with?('lib/') |
| 45 | names = Set.new | 45 | names = Set.new |
| 46 | entry_nodes.each_with_object [] do |node, entries| | 46 | entry_nodes.each_with_object [] do |node, entries| |
| 47 | id = node['name'] | 47 | id = node['id'] |
| 48 | name = id.remove %r{\-\d*\z} | 48 | name = id.remove %r{\-\d*\z} |
| 49 | name << ' (type)' if name.sub!(/\Atype-/, '') | 49 | name << ' (type)' if name.sub!(/\Atype-/, '') |
| 50 | name.remove! 'Module:' | ||
| 51 | name.prepend "#{self.name}:" | 50 | name.prepend "#{self.name}:" |
| 52 | entries << [name, id] if names.add?(name) | 51 | entries << [name, id] if names.add?(name) |
| 53 | end | 52 | end |
| @@ -67,9 +66,7 @@ module Docs · 13 unmodified lines | |||
| 67 | 66 | ||
| 68 | def entry_nodes | 67 | def entry_nodes |
| 69 | @entry_nodes ||= if subpath.start_with?('lib/') | 68 | @entry_nodes ||= if subpath.start_with?('lib/') |
| 70 | css('p + div.REFBODY').each_with_object [] do |node, result| | 69 | css('article.func > h4', 'article.data-types-body > h4').entries |
| 71 | result.concat(node.previous_element.css('a[name]').to_a) | ||
| 72 | end | ||
| 73 | elsif subpath.start_with?('erts') | 70 | elsif subpath.start_with?('erts') |
| 74 | link = at_css(".flipMenu a[href='#{File.basename(subpath, '.html')}']") | 71 | link = at_css(".flipMenu a[href='#{File.basename(subpath, '.html')}']") |
| 75 | list = link.parent.parent | 72 | list = link.parent.parent |
| @@ -4,15 +4,6 @@ module Docs · 3 unmodified lines | |||
| 4 | def call | 4 | def call |
| 5 | css('.flipMenu li[title] > a').remove unless subpath.start_with?('erts') # perf | 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 | doc | 7 | doc |
| 17 | end | 8 | end |
| 18 | end | 9 | end |