From 57232ce130a64eceded02b89fb38e64523e4db3a Mon Sep 17 00:00:00 2001 From: Nicolas Ettlin Date: Wed, 17 Oct 2018 21:21:21 +0200 Subject: [PATCH 1/2] Add Vuex reference --- .../templates/pages/about_tmpl.coffee | 5 ++ lib/docs/filters/vuex/clean_html.rb | 14 ++++ lib/docs/filters/vuex/entries.rb | 68 ++++++++++++++++++ lib/docs/scrapers/vuex.rb | 26 +++++++ public/icons/docs/vuex/16.png | Bin 0 -> 534 bytes public/icons/docs/vuex/16@2x.png | Bin 0 -> 1244 bytes public/icons/docs/vuex/SOURCE | 1 + 7 files changed, 114 insertions(+) create mode 100644 lib/docs/filters/vuex/clean_html.rb create mode 100644 lib/docs/filters/vuex/entries.rb create mode 100644 lib/docs/scrapers/vuex.rb create mode 100644 public/icons/docs/vuex/16.png create mode 100644 public/icons/docs/vuex/16@2x.png create mode 100644 public/icons/docs/vuex/SOURCE diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index fef9a024..72fb74cd 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -680,6 +680,11 @@ credits = [ '2013-2018 Evan You, Vue.js contributors', 'MIT', 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' + ], [ + 'Vuex', + '2015-2018 Evan You, Vue.js contributors', + 'MIT', + 'https://raw.githubusercontent.com/vuejs/vuex/master/LICENSE' ], [ 'Vulkan', '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', diff --git a/lib/docs/filters/vuex/clean_html.rb b/lib/docs/filters/vuex/clean_html.rb new file mode 100644 index 00000000..f62870cc --- /dev/null +++ b/lib/docs/filters/vuex/clean_html.rb @@ -0,0 +1,14 @@ +module Docs + class Vuex + class CleanHtmlFilter < Filter + def call + @doc = at_css('.content') + + # Remove unneeded elements + css('.header-anchor').remove + + doc + end + end + end +end \ No newline at end of file diff --git a/lib/docs/filters/vuex/entries.rb b/lib/docs/filters/vuex/entries.rb new file mode 100644 index 00000000..72c8486e --- /dev/null +++ b/lib/docs/filters/vuex/entries.rb @@ -0,0 +1,68 @@ +module Docs + class Vuex + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content + + name.remove! '# ' + + # Add index on guides + unless subpath.start_with?('api') + sidebarLink = at_css('.sidebar-link.active') + allLinks = css('.sidebar-link:not([href="/"]):not([href="../index"])') + + index = allLinks.index(sidebarLink) + + name.prepend "#{index + 1}. " if index + end + + name + end + + def get_type + 'Guide' + end + + def include_default_entry? + name != 'API Reference' + end + + def additional_entries + return [] unless subpath.start_with?('api') + + entries = [ + ['Component Binding Helpers', 'component-binding-helpers', 'API Reference'], + ['Store', 'vuex-store', 'API Reference'], + ] + + css('h3').each do |node| + entryName = node.content.strip + + # Get the previous h2 title + title = node + title = title.previous_element until title.name == 'h2' + title = title.content.strip + title.remove! '# ' + + entryName.remove! '# ' + + unless entryName.start_with?('router.') + if title == "Vuex.Store Constructor Options" + entryName = "StoreOptions.#{entryName}" + elsif title == "Vuex.Store Instance Properties" + entryName = "Vuex.Store.#{entryName}" + elsif title == "Vuex.Store Instance Methods" + entryName = "Vuex.Store.#{entryName}()" + elsif title == "Component Binding Helpers" + entryName = "#{entryName}()" + end + end + + entries << [entryName, node['id'], 'API Reference'] + end + + entries + end + end + end +end \ No newline at end of file diff --git a/lib/docs/scrapers/vuex.rb b/lib/docs/scrapers/vuex.rb new file mode 100644 index 00000000..774e989f --- /dev/null +++ b/lib/docs/scrapers/vuex.rb @@ -0,0 +1,26 @@ +module Docs + class Vuex < UrlScraper + self.name = 'Vuex' + self.type = 'simple' + + self.links = { + home: 'https://vuex.vuejs.org', + code: 'https://github.com/vuejs/vuex' + } + + html_filters.push 'vuex/entries', 'vuex/clean_html' + + self.release = '3.0.1' + self.base_url = 'https://vuex.vuejs.org/' + + options[:skip_patterns] = [ + # Other languages + /^(zh|ja|ru|kr|fr|ptbr)\//, + ] + + options[:attribution] = <<-HTML + © 2015–2018 Evan You, Vue.js contributors
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/vuex/16.png b/public/icons/docs/vuex/16.png new file mode 100644 index 0000000000000000000000000000000000000000..153c58cdefe476e6738e7123d9c35a56d482a1ef GIT binary patch literal 534 zcmV+x0_pvUP)*H1M-xUw)lk~@0;(RckjKZ%G3U_T6BNH-SSH(m0NOKtx~PF zGNB4U!y`kM4qc_=?qhEw_@YPQ`^wt2kCXPL4|aX&vpv^pQ3P-_JTheI&{Z>W;8b7r zrMlf09d+e&V_BxpUlw~IFVx#d88{jq8M1WfD&QsE2eaD)(Jy=7orl-QR=M$`e4#B< z^UaWfqv4SuOGg3V#Ni2Vqw`H~_AtiND_1hB(vYe8(wKpx;b}5)=PMlr@&`H0n%`%2 z_VqpSHp8E1p4`YRcQLc)n!>=*yiqSDL-tQsxWp+M!i${F;o3K6z^HE!@$w-Oty%>kClJv&bc>h{39s?M>Cn-;ER8d zwHEouy`=Lgzqc@OG?Ovd>lAUY%&RkSP!N>M_w{Ifz&K=Wd>0{;Yv*xpw2ZdX@IH6y{x445yCHs4yy>o2 zn*(2*Y+Bi3Gd*5vS|d|8t!FXz_x8az;8U3+zD!^O^;58*#0710VmvO zpoJ#dJ#ORFNdDS6J$(6NJ$&g*_%Q`gK zg4h}f{0;)?u~N-!8!pBeIclf{0~QXr;Dj3uw9qu0=Pr4VOY$#wrNSh(CDsDa&Z@8b z=HJq(Y*AZ>OUinFS_%1fW_(tsCuX0E@WhOfqlQ{AVBvrZPPjz_@juZF_wQ0U*gx5m z_j8-)Bn{6+;VWmu3DkF1VZ~SWlBY5=b1G#|Dr+pnDV$KTYcgULz6#U)3L0vihBAs3u(z4DCF zYGWoLpwIF@oCowz*u6Uq`OOE)%1v<^qK3qY86!tcPzxr&3I|+p?kbKIYT>0abg}ZN z0Dg1VssQgsr-G*H_udX0GCYSaj-|P#v+ult z6PpW%8fw9SHC+3(hNgWg}uiL&k)IF>(@LO<+5;Lzu*mnE6TK%8mY6Ye@!GCTV6fpoCPII>tE_~77nhhx z{7$Y*6G(1_-SFn4&o`Wyu`Voq`}YKYDCEh19$G)Gabm_yP4~>a(fE9Ok*>#yW4W$d z^w*7sye^l{_1Kf+-8a*aOAAlqoituY*L1u1f1gCB;{O6E4`2-|#LHj+0000 Date: Tue, 13 Aug 2019 23:52:21 +0200 Subject: [PATCH 2/2] vuex: finish scraper and filters --- .../templates/pages/about_tmpl.coffee | 14 ++++---- lib/docs/filters/vuex/clean_html.rb | 5 ++- lib/docs/filters/vuex/entries.rb | 35 ++++++++++--------- lib/docs/scrapers/vuex.rb | 13 +++---- public/icons/docs/vuex/SOURCE | 2 +- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 51d76c61..07c92ad8 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -729,6 +729,11 @@ credits = [ '2010-2018 Mitchell Hashimoto', 'MPL', 'https://raw.githubusercontent.com/mitchellh/vagrant/master/website/LICENSE.md' + ], [ + 'Vue Router', + '2013-present Evan You', + 'MIT', + 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE' ], [ 'Vue.js', '2013-2018 Evan You, Vue.js contributors', @@ -736,14 +741,9 @@ credits = [ 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' ], [ 'Vuex', - '2015-2018 Evan You, Vue.js contributors', + '2015-present Evan You', 'MIT', - 'https://raw.githubusercontent.com/vuejs/vuex/master/LICENSE' - ], [ - 'Vue Router', - '2013-present Evan You', - 'MIT', - 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE' + 'https://raw.githubusercontent.com/vuejs/vuex/dev/LICENSE' ], [ 'Vulkan', '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', diff --git a/lib/docs/filters/vuex/clean_html.rb b/lib/docs/filters/vuex/clean_html.rb index f62870cc..4aad55a9 100644 --- a/lib/docs/filters/vuex/clean_html.rb +++ b/lib/docs/filters/vuex/clean_html.rb @@ -4,6 +4,9 @@ module Docs def call @doc = at_css('.content') + # Remove video from root page + css('a[href="#"]').remove if root_page? + # Remove unneeded elements css('.header-anchor').remove @@ -11,4 +14,4 @@ module Docs end end end -end \ No newline at end of file +end diff --git a/lib/docs/filters/vuex/entries.rb b/lib/docs/filters/vuex/entries.rb index 72c8486e..04846fd2 100644 --- a/lib/docs/filters/vuex/entries.rb +++ b/lib/docs/filters/vuex/entries.rb @@ -8,10 +8,10 @@ module Docs # Add index on guides unless subpath.start_with?('api') - sidebarLink = at_css('.sidebar-link.active') - allLinks = css('.sidebar-link:not([href="/"]):not([href="../index"])') + sidebar_link = at_css('.sidebar-link.active') + all_links = css('.sidebar-link:not([href="/"]):not([href="../index"])') - index = allLinks.index(sidebarLink) + index = all_links.index(sidebar_link) name.prepend "#{index + 1}. " if index end @@ -28,7 +28,7 @@ module Docs end def additional_entries - return [] unless subpath.start_with?('api') + return [] unless subpath.start_with?('api') entries = [ ['Component Binding Helpers', 'component-binding-helpers', 'API Reference'], @@ -36,7 +36,7 @@ module Docs ] css('h3').each do |node| - entryName = node.content.strip + entry_name = node.content.strip # Get the previous h2 title title = node @@ -44,25 +44,26 @@ module Docs title = title.content.strip title.remove! '# ' - entryName.remove! '# ' + entry_name.remove! '# ' - unless entryName.start_with?('router.') - if title == "Vuex.Store Constructor Options" - entryName = "StoreOptions.#{entryName}" - elsif title == "Vuex.Store Instance Properties" - entryName = "Vuex.Store.#{entryName}" - elsif title == "Vuex.Store Instance Methods" - entryName = "Vuex.Store.#{entryName}()" - elsif title == "Component Binding Helpers" - entryName = "#{entryName}()" + unless entry_name.start_with?('router.') + case title + when "Vuex.Store Constructor Options" + entry_name = "StoreOptions.#{entry_name}" + when "Vuex.Store Instance Properties" + entry_name = "Vuex.Store.#{entry_name}" + when "Vuex.Store Instance Methods" + entry_name = "Vuex.Store.#{entry_name}()" + when "Component Binding Helpers" + entry_name = "#{entry_name}()" end end - entries << [entryName, node['id'], 'API Reference'] + entries << [entry_name, node['id'], 'API Reference'] end entries end end end -end \ No newline at end of file +end diff --git a/lib/docs/scrapers/vuex.rb b/lib/docs/scrapers/vuex.rb index 774e989f..57e761ce 100644 --- a/lib/docs/scrapers/vuex.rb +++ b/lib/docs/scrapers/vuex.rb @@ -1,8 +1,8 @@ module Docs class Vuex < UrlScraper - self.name = 'Vuex' self.type = 'simple' - + self.release = '3.1.1' + self.base_url = 'https://vuex.vuejs.org/' self.links = { home: 'https://vuex.vuejs.org', code: 'https://github.com/vuejs/vuex' @@ -10,17 +10,18 @@ module Docs html_filters.push 'vuex/entries', 'vuex/clean_html' - self.release = '3.0.1' - self.base_url = 'https://vuex.vuejs.org/' - options[:skip_patterns] = [ # Other languages /^(zh|ja|ru|kr|fr|ptbr)\//, ] options[:attribution] = <<-HTML - © 2015–2018 Evan You, Vue.js contributors
+ © 2015–present Evan You
Licensed under the MIT License. HTML + + def get_latest_version(opts) + get_npm_version('vuex', opts) + end end end diff --git a/public/icons/docs/vuex/SOURCE b/public/icons/docs/vuex/SOURCE index 97bd9e03..6999e8c5 100644 --- a/public/icons/docs/vuex/SOURCE +++ b/public/icons/docs/vuex/SOURCE @@ -1 +1 @@ -http://vuejs.org/ +https://github.com/vuejs/vuejs.org/blob/master/assets/logo.ai