From 2d98f0c52f618a30733017340e7ed83cfef2c571 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Thu, 12 Sep 2019 00:53:09 +0200 Subject: [PATCH] Update Dart documentation (2.5.0) --- lib/docs/filters/dart/clean_html.rb | 13 +++++++++++-- lib/docs/filters/dart/entries.rb | 4 ++-- lib/docs/scrapers/dart.rb | 8 ++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/docs/filters/dart/clean_html.rb b/lib/docs/filters/dart/clean_html.rb index c0021aae..f27bf093 100644 --- a/lib/docs/filters/dart/clean_html.rb +++ b/lib/docs/filters/dart/clean_html.rb @@ -33,13 +33,22 @@ module Docs # We can't use options[:container] here because the entries filter uses the breadcrumbs node @doc = at_css('.main-content') + # Remove external links + css('#external-links').remove + + # Properly format header in v2 docs + nested_title = at_css('div > h1') + unless nested_title.nil? + nested_title.parent.replace nested_title + end + # Move the features (i.e. "read-only, inherited") into the blue header css('.features').each do |node| header = node.xpath('parent::dd/preceding::dt').last header.add_child node unless header.nil? end - css('section').each do |node| + css('section:not(.multi-line-signature)').each do |node| if node['id'] && node.first_element_child node.first_element_child['id'] ||= node['id'] end @@ -54,7 +63,7 @@ module Docs # Make code blocks detectable by Prism css('pre').each do |node| node['data-language'] = 'dart' - node.content = node.content + node.content = node.content.strip end css('.properties', '.property', '.callables', '.callable').remove_attr('class') diff --git a/lib/docs/filters/dart/entries.rb b/lib/docs/filters/dart/entries.rb index f3c42bbf..86eca477 100644 --- a/lib/docs/filters/dart/entries.rb +++ b/lib/docs/filters/dart/entries.rb @@ -7,7 +7,7 @@ module Docs name = title.element_children.last.content.strip kind = title.at_css('.kind').content else # v2 - title = at_css('.main-content > h1') + title = at_css('.main-content > div > h1') name = title.content[/(.*)( )/, 1].split(' top-level')[0] kind = title.content[/(.*)( )(.+)/, 3] end @@ -15,7 +15,7 @@ module Docs breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a') first_part = '' - if breadcrumbs.length == 2 && !kind.include?('class') + if breadcrumbs.length == 2 && kind.blank? first_part = breadcrumbs[1].content elsif breadcrumbs.length == 3 first_part = breadcrumbs[2].content diff --git a/lib/docs/scrapers/dart.rb b/lib/docs/scrapers/dart.rb index 322bfe2a..a3dc05c1 100644 --- a/lib/docs/scrapers/dart.rb +++ b/lib/docs/scrapers/dart.rb @@ -3,7 +3,7 @@ module Docs self.type = 'dart' self.root_path = 'index.html' self.links = { - home: 'https://www.dartlang.org/', + home: 'https://dart.dev/', code: 'https://github.com/dart-lang/sdk' } @@ -23,13 +23,13 @@ module Docs # Download the documentation from https://www.dartlang.org/tools/sdk/archive version '2' do - self.release = '2.0.0' - self.base_url = "https://api.dartlang.org/stable/#{release}/" + self.release = '2.5.0' + self.base_url = "https://api.dart.dev/stable/#{release}/" end version '1' do self.release = '1.24.3' - self.base_url = "https://api.dartlang.org/stable/#{release}/" + self.base_url = "https://api.dart.dev/stable/#{release}/" end def get_latest_version(opts)