Unified · Split
| @@ -10,6 +10,9 @@ · 9 unmodified lines | ||
| 10 | 10 | > h4 { @extend %block-label; } |
| 11 | 11 | > h2 + h2, > h3 + h3 { margin-top: 0; } |
| 12 | 12 | |
| 13 | + h3 { @extend %block-label, %label-blue} | |
| 14 | + h4 { @extend %block-label } | |
| 15 | + | |
| 13 | 16 | p > code, li > code, .type { |
| 14 | 17 | white-space: normal; |
| 15 | 18 | @extend %label; |
| @@ -24,4 +27,3 @@ · 8 unmodified lines | ||
| 24 | 27 | .srclink { float: right; } |
| 25 | 28 | details > table { margin: 0; } |
| 26 | 29 | } |
| 27 | − | |
| @@ -15,6 +15,8 @@ module Docs · 14 unmodified lines | ||
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | css('pre').each do |node| |
| 18 | + next unless node.at_css('code') | |
| 19 | + | |
| 18 | 20 | if lang = node.at_css('code')['class'] |
| 19 | 21 | node['data-language'] = lang.remove(%r{lang(uage)?-}) |
| 20 | 22 | end |
| @@ -22,6 +24,19 @@ module Docs · 1 unmodified line | ||
| 22 | 24 | node.content = node.content |
| 23 | 25 | end |
| 24 | 26 | |
| 27 | + css('h3 > code, h4 > code, h5 > code').each do |node| | |
| 28 | + tmp = node.content | |
| 29 | + has_parethesis = true if tmp =~ /\(/ | |
| 30 | + tmp.gsub!(/\(.*\)/, '') | |
| 31 | + | |
| 32 | + if has_parethesis | |
| 33 | + tmp << '()' | |
| 34 | + end | |
| 35 | + | |
| 36 | + node.parent['id'] = tmp | |
| 37 | + | |
| 38 | + end | |
| 39 | + | |
| 25 | 40 | doc |
| 26 | 41 | end |
| 27 | 42 | end |
| @@ -1,104 +1,38 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Node |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | − REPLACE_NAMES = { | |
| 5 | − 'addons' => 'C/C++ Addons', | |
| 6 | − 'debugger' => 'Debugger', | |
| 7 | − 'deprecations' => 'Deprecated APIs', | |
| 8 | − 'modules' => 'module' } | |
| 9 | − | |
| 10 | − REPLACE_TYPES = { | |
| 11 | − 'C++ Addons' => 'Miscellaneous', | |
| 12 | − 'C/C++ Addons' => 'Miscellaneous', | |
| 13 | − 'Debugger' => 'Miscellaneous', | |
| 14 | − 'Deprecated APIs' => 'Miscellaneous', | |
| 15 | − 'Tracing' => 'Miscellaneous', | |
| 16 | − 'os' => 'OS', | |
| 17 | − 'StringDecoder' => 'String Decoder', | |
| 18 | − 'TLS (SSL)' => 'TLS/SSL', | |
| 19 | − 'UDP / Datagram Sockets' => 'UDP/Datagram', | |
| 20 | − 'VM (Executing JavaScript)' => 'VM', | |
| 21 | − 'Executing JavaScript' => 'VM' } | |
| 22 | 4 | |
| 23 | 5 | def get_name |
| 24 | − REPLACE_NAMES[slug] || slug | |
| 6 | + type | |
| 25 | 7 | end |
| 26 | 8 | |
| 27 | 9 | def get_type |
| 28 | − type = at_css('h1').content.strip | |
| 29 | − type.remove! %r{\[.*\]} | |
| 30 | − REPLACE_TYPES[type] || "#{type.first.upcase}#{type[1..-1]}" | |
| 10 | + at_css('h2').content.strip | |
| 31 | 11 | end |
| 32 | 12 | |
| 33 | 13 | def additional_entries |
| 34 | − return [] if type == 'Miscellaneous' | |
| 35 | − | |
| 36 | − klass = nil | |
| 37 | 14 | entries = [] |
| 38 | 15 | |
| 39 | − css('> [id]').each do |node| | |
| 40 | − next if node.name == 'h1' | |
| 41 | − | |
| 42 | − klass = nil if node.name == 'h2' | |
| 43 | − name = node.content.strip | |
| 44 | − name.remove! %r{\s*\[src\]} | |
| 45 | − | |
| 46 | − # Skip constructors | |
| 47 | − if name.start_with? 'new ' | |
| 48 | − next | |
| 49 | − end | |
| 50 | − | |
| 51 | − # Ignore most global objects (found elsewhere) | |
| 52 | − if type == 'Global Objects' | |
| 53 | − entries << [name, node['id']] if name.start_with?('_') || name == 'global' | |
| 54 | − next | |
| 55 | − end | |
| 16 | + css('h3 > code, h4 > code, h5 > code').each do |node| | |
| 56 | 17 | |
| 57 | − # Classes | |
| 58 | − if name.gsub! 'Class: ', '' | |
| 59 | − name.remove! 'events.' # EventEmitter | |
| 60 | − klass = name | |
| 61 | − entries << [name, node['id']] | |
| 62 | − next | |
| 18 | + case node.parent.child.content | |
| 19 | + when /Class/ | |
| 20 | + entries << ["Class #{node.parent['id']}", node.parent['id'], type] | |
| 21 | + when /Event/ | |
| 22 | + entries << ["Event #{node.parent['id']}", node.parent['id'], type] | |
| 63 | 23 | end |
| 64 | 24 | |
| 65 | − # Events | |
| 66 | − if name.sub! %r{\AEvent: '(.+)'\z}, '\1' | |
| 67 | − name << " event (#{klass || type})" | |
| 68 | − entries << [name, node['id']] | |
| 25 | + if node.parent.child.is_a?(Nokogiri::XML::Text) | |
| 69 | 26 | next |
| 27 | + else | |
| 28 | + entries << [node.parent['id'], node.parent['id'], type] | |
| 70 | 29 | end |
| 71 | 30 | |
| 72 | − name.gsub! %r{\(.*?\);?}, '()' | |
| 73 | − name.gsub! %r{\[.+?\]}, '[]' | |
| 74 | − name.remove! 'assert(), ' # assert/assert.ok | |
| 75 | − | |
| 76 | − # Skip all that start with an uppercase letter ("Example") or include a space ("exports alias") | |
| 77 | − next unless (name.first.upcase! && !name.include?(' ')) || name.start_with?('Class Method') | |
| 78 | − | |
| 79 | − # Differentiate server classes (http, https, net, etc.) | |
| 80 | − name.sub!('server.') { "#{(klass || 'https').sub('.', '_').downcase}." } | |
| 81 | − # Differentiate socket classes (net, dgram, etc.) | |
| 82 | − name.sub!('socket.') { "#{klass.sub('.', '_').downcase}." } | |
| 83 | − | |
| 84 | − name.remove! 'Class Method:' | |
| 85 | − name.sub! 'buf.', 'buffer.' | |
| 86 | − name.sub! 'buf[', 'buffer[' | |
| 87 | − name.sub! 'child.', 'childprocess.' | |
| 88 | − name.sub! 'decoder.', 'stringdecoder.' | |
| 89 | − name.sub! 'emitter.', 'eventemitter.' | |
| 90 | − name.sub! %r{\Arl\.}, 'interface.' | |
| 91 | − name.sub! 'rs.', 'readstream.' | |
| 92 | − name.sub! 'ws.', 'writestream.' | |
| 93 | − | |
| 94 | − # Skip duplicates (listen, connect, etc.) | |
| 95 | − unless name == entries[-1].try(:first) || name == entries[-2].try(:first) | |
| 96 | − entries << [name, node['id']] | |
| 97 | − end | |
| 98 | 31 | end |
| 99 | 32 | |
| 100 | 33 | entries |
| 101 | 34 | end |
| 35 | + | |
| 102 | 36 | end |
| 103 | 37 | end |
| 104 | 38 | end |
| @@ -0,0 +1,104 @@ | ||
| 1 | +module Docs | |
| 2 | + class Node | |
| 3 | + class OldEntriesFilter < Docs::EntriesFilter | |
| 4 | + REPLACE_NAMES = { | |
| 5 | + 'addons' => 'C/C++ Addons', | |
| 6 | + 'debugger' => 'Debugger', | |
| 7 | + 'deprecations' => 'Deprecated APIs', | |
| 8 | + 'modules' => 'module' } | |
| 9 | + | |
| 10 | + REPLACE_TYPES = { | |
| 11 | + 'C++ Addons' => 'Miscellaneous', | |
| 12 | + 'C/C++ Addons' => 'Miscellaneous', | |
| 13 | + 'Debugger' => 'Miscellaneous', | |
| 14 | + 'Deprecated APIs' => 'Miscellaneous', | |
| 15 | + 'Tracing' => 'Miscellaneous', | |
| 16 | + 'os' => 'OS', | |
| 17 | + 'StringDecoder' => 'String Decoder', | |
| 18 | + 'TLS (SSL)' => 'TLS/SSL', | |
| 19 | + 'UDP / Datagram Sockets' => 'UDP/Datagram', | |
| 20 | + 'VM (Executing JavaScript)' => 'VM', | |
| 21 | + 'Executing JavaScript' => 'VM' } | |
| 22 | + | |
| 23 | + def get_name | |
| 24 | + REPLACE_NAMES[slug] || slug | |
| 25 | + end | |
| 26 | + | |
| 27 | + def get_type | |
| 28 | + type = at_css('h1').content.strip | |
| 29 | + type.remove! %r{\[.*\]} | |
| 30 | + REPLACE_TYPES[type] || "#{type.first.upcase}#{type[1..-1]}" | |
| 31 | + end | |
| 32 | + | |
| 33 | + def additional_entries | |
| 34 | + return [] if type == 'Miscellaneous' | |
| 35 | + | |
| 36 | + klass = nil | |
| 37 | + entries = [] | |
| 38 | + | |
| 39 | + css('> [id]').each do |node| | |
| 40 | + next if node.name == 'h1' | |
| 41 | + | |
| 42 | + klass = nil if node.name == 'h2' | |
| 43 | + name = node.content.strip | |
| 44 | + name.remove! %r{\s*\[src\]} | |
| 45 | + | |
| 46 | + # Skip constructors | |
| 47 | + if name.start_with? 'new ' | |
| 48 | + next | |
| 49 | + end | |
| 50 | + | |
| 51 | + # Ignore most global objects (found elsewhere) | |
| 52 | + if type == 'Global Objects' | |
| 53 | + entries << [name, node['id']] if name.start_with?('_') || name == 'global' | |
| 54 | + next | |
| 55 | + end | |
| 56 | + | |
| 57 | + # Classes | |
| 58 | + if name.gsub! 'Class: ', '' | |
| 59 | + name.remove! 'events.' # EventEmitter | |
| 60 | + klass = name | |
| 61 | + entries << [name, node['id']] | |
| 62 | + next | |
| 63 | + end | |
| 64 | + | |
| 65 | + # Events | |
| 66 | + if name.sub! %r{\AEvent: '(.+)'\z}, '\1' | |
| 67 | + name << " event (#{klass || type})" | |
| 68 | + entries << [name, node['id']] | |
| 69 | + next | |
| 70 | + end | |
| 71 | + | |
| 72 | + name.gsub! %r{\(.*?\);?}, '()' | |
| 73 | + name.gsub! %r{\[.+?\]}, '[]' | |
| 74 | + name.remove! 'assert(), ' # assert/assert.ok | |
| 75 | + | |
| 76 | + # Skip all that start with an uppercase letter ("Example") or include a space ("exports alias") | |
| 77 | + next unless (name.first.upcase! && !name.include?(' ')) || name.start_with?('Class Method') | |
| 78 | + | |
| 79 | + # Differentiate server classes (http, https, net, etc.) | |
| 80 | + name.sub!('server.') { "#{(klass || 'https').sub('.', '_').downcase}." } | |
| 81 | + # Differentiate socket classes (net, dgram, etc.) | |
| 82 | + name.sub!('socket.') { "#{klass.sub('.', '_').downcase}." } | |
| 83 | + | |
| 84 | + name.remove! 'Class Method:' | |
| 85 | + name.sub! 'buf.', 'buffer.' | |
| 86 | + name.sub! 'buf[', 'buffer[' | |
| 87 | + name.sub! 'child.', 'childprocess.' | |
| 88 | + name.sub! 'decoder.', 'stringdecoder.' | |
| 89 | + name.sub! 'emitter.', 'eventemitter.' | |
| 90 | + name.sub! %r{\Arl\.}, 'interface.' | |
| 91 | + name.sub! 'rs.', 'readstream.' | |
| 92 | + name.sub! 'ws.', 'writestream.' | |
| 93 | + | |
| 94 | + # Skip duplicates (listen, connect, etc.) | |
| 95 | + unless name == entries[-1].try(:first) || name == entries[-2].try(:first) | |
| 96 | + entries << [name, node['id']] | |
| 97 | + end | |
| 98 | + end | |
| 99 | + | |
| 100 | + entries | |
| 101 | + end | |
| 102 | + end | |
| 103 | + end | |
| 104 | +end | |
| @@ -14,6 +14,7 @@ module Docs · 13 unmodified lines | ||
| 14 | 14 | options[:root_title] = 'Node.js' |
| 15 | 15 | options[:container] = '#apicontent' |
| 16 | 16 | options[:skip] = %w(index.html all.html documentation.html synopsis.html) |
| 17 | + # options[:only] = ['addons.html'] | |
| 17 | 18 | |
| 18 | 19 | options[:attribution] = <<-HTML |
| 19 | 20 | © Joyent, Inc. and other Node contributors<br> |
| @@ -23,38 +24,43 @@ module Docs · 3 unmodified lines | ||
| 23 | 24 | HTML |
| 24 | 25 | |
| 25 | 26 | version do |
| 26 | − self.release = '15.5.0' | |
| 27 | − self.base_url = 'https://nodejs.org/dist/latest-v15.x/docs/api/' | |
| 27 | + self.release = '16.1.0' | |
| 28 | + self.base_url = 'https://nodejs.org/api/' | |
| 28 | 29 | end |
| 29 | 30 | |
| 30 | 31 | version '14 LTS' do |
| 31 | − self.release = '14.15.3' | |
| 32 | + self.release = '14.17.0' | |
| 32 | 33 | self.base_url = 'https://nodejs.org/dist/latest-v14.x/docs/api/' |
| 33 | 34 | end |
| 34 | 35 | |
| 35 | 36 | version '12 LTS' do |
| 36 | − self.release = '12.19.0' | |
| 37 | + self.release = '12.22.1' | |
| 37 | 38 | self.base_url = 'https://nodejs.org/dist/latest-v12.x/docs/api/' |
| 39 | + html_filters.replace('node/entries', 'node/old_entries') | |
| 38 | 40 | end |
| 39 | 41 | |
| 40 | 42 | version '10 LTS' do |
| 41 | − self.release = '10.16.3' | |
| 43 | + self.release = '10.24.1' | |
| 42 | 44 | self.base_url = 'https://nodejs.org/dist/latest-v10.x/docs/api/' |
| 45 | + html_filters.replace('node/entries', 'node/old_entries') | |
| 43 | 46 | end |
| 44 | 47 | |
| 45 | 48 | version '8 LTS' do |
| 46 | − self.release = '8.16.1' | |
| 49 | + self.release = '8.17.0' | |
| 47 | 50 | self.base_url = 'https://nodejs.org/dist/latest-v8.x/docs/api/' |
| 51 | + html_filters.replace('node/entries', 'node/old_entries') | |
| 48 | 52 | end |
| 49 | 53 | |
| 50 | 54 | version '6 LTS' do |
| 51 | − self.release = '6.14.4' | |
| 55 | + self.release = '6.17.1' | |
| 52 | 56 | self.base_url = 'https://nodejs.org/dist/latest-v6.x/docs/api/' |
| 57 | + html_filters.replace('node/entries', 'node/old_entries') | |
| 53 | 58 | end |
| 54 | 59 | |
| 55 | 60 | version '4 LTS' do |
| 56 | 61 | self.release = '4.9.1' |
| 57 | 62 | self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/' |
| 63 | + html_filters.replace('node/entries', 'node/old_entries') | |
| 58 | 64 | end |
| 59 | 65 | |
| 60 | 66 | def get_latest_version(opts) |