From 6faab8bcc8e5c6d523e9b4cd12b4675ecbee4c9b Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Wed, 9 Feb 2022 22:29:48 +0100 Subject: [PATCH] Update Vue.js documentation (3.2.30) https://blog.vuejs.org/posts/vue-3-as-the-new-default.html --- lib/docs/filters/vue/clean_html.rb | 4 +++- lib/docs/filters/vue/entries_v3.rb | 14 +++++++------- lib/docs/scrapers/vue.rb | 15 +++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/docs/filters/vue/clean_html.rb b/lib/docs/filters/vue/clean_html.rb index 754d3789..288e7bf3 100644 --- a/lib/docs/filters/vue/clean_html.rb +++ b/lib/docs/filters/vue/clean_html.rb @@ -6,7 +6,8 @@ module Docs return '

Vite

' if root_page? @doc = at_css('.content > div') else - @doc = at_css(version == '3' ? 'main' : '.content') + return '

Vue.js

' if root_page? + @doc = at_css(version == '3' ? 'main > div > div' : '.content') end at_css('h1').content = 'Vue.js' if root_page? @@ -14,6 +15,7 @@ module Docs css('.demo', '.guide-links', '.footer', '#ad').remove css('.header-anchor', '.page-edit', '.page-nav').remove + css('.next-steps').remove css('.custom-block-title').each do |node| node.name = 'strong' diff --git a/lib/docs/filters/vue/entries_v3.rb b/lib/docs/filters/vue/entries_v3.rb index f92fc7b7..948e72e1 100644 --- a/lib/docs/filters/vue/entries_v3.rb +++ b/lib/docs/filters/vue/entries_v3.rb @@ -9,9 +9,9 @@ module Docs else name = at_css('h1').content name = _fix_name(name) - subtype = at_css('.sidebar-heading.open, .sidebar-heading.active, .sidebar-link.active') - index = css('.sidebar-link').to_a.index(at_css('.sidebar-link.active')) - name.prepend "#{index + 1}. " if index && !slug.start_with?('api') + subtype = at_css('.title-text.active') + index = css('aside nav .link').to_a.index(at_css('aside nav .link.active')) + name.prepend "#{index + 1}. " if index && !slug.start_with?('api') && !slug.start_with?('style-guide') name.concat " (#{subtype.content.strip})" if subtype && slug.start_with?('guide') name end @@ -26,12 +26,12 @@ module Docs def get_type if slug.start_with?('guide/migration') 'Migration' - elsif slug.start_with?('guide') + elsif slug.start_with?('guide') or root_page? 'Guide' - elsif slug == 'style-guide/' + elsif slug.start_with?('style-guide') 'Style Guide' else - title = at_css('.sidebar-heading.open, .sidebar-heading.active, .sidebar-link.active').content.strip + title = at_css('.title-text.active').content.strip title = _fix_name(title) "API: #{title}" end @@ -41,7 +41,7 @@ module Docs return [] if slug.start_with?('guide') type = nil - css('h2, h3').each_with_object [] do |node, entries| + at_css('main').css('h2, h3').each_with_object [] do |node, entries| if node.name == 'h2' type = node.content.strip type = _fix_name(type) diff --git a/lib/docs/scrapers/vue.rb b/lib/docs/scrapers/vue.rb index b42a4b60..eeeaabea 100644 --- a/lib/docs/scrapers/vue.rb +++ b/lib/docs/scrapers/vue.rb @@ -5,10 +5,10 @@ module Docs self.type = 'vue' self.links = { home: 'https://vuejs.org/', - code: 'https://github.com/vuejs/vue' + code: 'https://github.com/vuejs/core' } - options[:only_patterns] = [/guide\//, /api\//] + options[:only_patterns] = [/^$/ ,/guide\//, /api\//] options[:skip] = %w(guide/team.html) options[:skip_patterns] = [/guide\/contributing/] options[:replace_paths] = { 'guide/' => 'guide/index.html' } @@ -19,16 +19,15 @@ module Docs HTML version '3' do - self.release = '3.2.26' - self.base_url = 'https://v3.vuejs.org/' - self.root_path = 'guide/introduction.html' - self.initial_paths = %w(api/) + self.release = '3.2.30' + self.base_url = 'https://vuejs.org/' + self.initial_paths = %w(guide/introduction.html) html_filters.push 'vue/entries_v3', 'vue/clean_html' end version '2' do self.release = '2.6.12' - self.base_url = 'https://vuejs.org/v2/' + self.base_url = 'https://v2.vuejs.org/' self.root_path = 'guide/index.html' self.initial_paths = %w(api/) html_filters.push 'vue/entries', 'vue/clean_html' @@ -43,7 +42,7 @@ module Docs end def get_latest_version(opts) - get_npm_version('vue', opts, 'next') + get_npm_version('vue', opts) end end end