diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 1139b2a6..f8e51fed 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -388,9 +388,9 @@ credits = [ 'https://raw.githubusercontent.com/Homebrew/brew/master/LICENSE.txt' ], [ 'Immutable.js', - '2014-2016 Facebook, Inc.', + '2014–present Lee Byron and other contributors', 'BSD', - 'https://raw.githubusercontent.com/facebook/immutable-js/master/LICENSE' + 'https://github.com/immutable-js/immutable-js/blob/main/LICENSE' ], [ 'InfluxData', '2015 InfluxData, Inc.', diff --git a/lib/docs/filters/immutable/clean_html.rb b/lib/docs/filters/immutable/clean_html.rb index b1e29e60..00f1f63f 100644 --- a/lib/docs/filters/immutable/clean_html.rb +++ b/lib/docs/filters/immutable/clean_html.rb @@ -2,6 +2,9 @@ module Docs class Immutable class CleanHtmlFilter < Filter def call + @doc = at_css('div') + css('#algolia-autocomplete', '#algolia-docsearch').remove + css('section', 'span', 'div[data-reactid]').each do |node| node.before(node.children).remove end @@ -9,36 +12,11 @@ module Docs css('.codeBlock').each do |node| node.name = 'pre' node.content = node.content - node['data-language'] = 'js' + node['data-language'] = 'ts' end css('*[data-reactid]').remove_attr('data-reactid') css('a[target]').remove_attr('target') - - css('a[href^="#"]').each do |node| - node['href'] = node['href'].sub(/\A#\//, '#').gsub('/', '.').downcase - end - - type = type_id = nil - css('*').each do |node| - if node.name == 'h1' - node['id'] = type_id = node.content.strip.downcase - type = node.content.strip - elsif node.name == 'h3' - node['id'] = node.content.strip.downcase - node['id'] = node['id'].remove('()') unless node['id'] == "#{type_id}()" - - unless node['id'].start_with?(type_id) - node.content = "#{type}##{node.content}" - node['id'] = "#{type_id}.#{node['id']}" unless node['id'].start_with?("#{type_id}.") - end - end - end - - css('h4.groupTitle').each do |node| - node.name = 'h2' - end - css('*[class]').remove_attr('class') doc diff --git a/lib/docs/filters/immutable/entries.rb b/lib/docs/filters/immutable/entries.rb index 0ef05a75..27dd3891 100644 --- a/lib/docs/filters/immutable/entries.rb +++ b/lib/docs/filters/immutable/entries.rb @@ -1,21 +1,24 @@ module Docs class Immutable class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content + end + + def get_type + return 'Util' if slug.match?(/^([a-z]|Range|Repeat)/) + at_css('h1').content + end + def additional_entries + return [] if root_page? entries = [] - type = nil - - css('*').each do |node| - if node.name == 'h1' - name = node.content - type = node.content.split('.').first - entries << [name, node['id'], type] - elsif node.name == 'h3' - name = node.content - entries << [name, node['id'], type] - end + css('h2, h3, h4').each do |node| + name = node.content + id = node.parent['id'] + next unless id + entries << ["#{type}.#{name}", id, type] end - entries end end diff --git a/lib/docs/scrapers/immutable.rb b/lib/docs/scrapers/immutable.rb index 8b1b47a2..1768ac66 100644 --- a/lib/docs/scrapers/immutable.rb +++ b/lib/docs/scrapers/immutable.rb @@ -3,58 +3,31 @@ module Docs self.name = 'Immutable.js' self.slug = 'immutable' self.type = 'simple' - self.release = '3.8.1' - self.base_url = 'https://facebook.github.io/immutable-js/docs/' + self.release = '4.0.0' + self.base_url = 'https://immutable-js.com/docs/v4.0.0/' self.links = { - home: 'https://facebook.github.io/immutable-js/', + home: 'https://immutable-js.com/', code: 'https://github.com/facebook/immutable-js' } - html_filters.push 'immutable/clean_html', 'immutable/entries', 'title' + html_filters.push 'immutable/clean_html', 'immutable/entries' - options[:skip_links] = true options[:container] = '.docContents' options[:root_title] = 'Immutable.js' + options[:trailing_slash] = true + options[:fix_urls] = ->(url) do + url.sub! '/index.html', '' + url.sub! '/index', '' + url + end + + options[:attribution] = <<-HTML - © 2014–2015 Facebook, Inc.
+ © 2014–present, Lee Byron and other contributors
Licensed under the 3-clause BSD License. HTML - stub '' do - capybara = load_capybara_selenium - capybara.app_host = 'https://facebook.github.io' - capybara.visit(URL.parse(self.base_url).path) - capybara.execute_script <<-JS - var content, event, links, link; - - event = document.createEvent('Event'); - event.initEvent('hashchange', false, false); - - content = document.querySelector('.docContents section').cloneNode(true); - links = Array.prototype.slice.call(document.querySelectorAll('.sideBar .scrollContent a')); - - while (link = links.shift()) { - if (!document.body.contains(link)) { - document.body.appendChild(link); - } - - link.click(); - dispatchEvent(event); - content.innerHTML += document.querySelector('.docContents').innerHTML; - - document.querySelectorAll('.sideBar .scrollContent .groupTitle').forEach(function(el) { - if (el.textContent == 'Types') { - Array.prototype.unshift.apply(links, Array.prototype.slice.call(el.parentNode.querySelectorAll('a'))); - } - }); - } - - document.querySelector('.docContents').innerHTML = content.innerHTML; - JS - capybara.html - end - def get_latest_version(opts) get_npm_version('immutable', opts) end