Add Vuex reference

This commit is contained in:
Nicolas Ettlin 2018-10-17 21:21:21 +02:00
parent 6ecd9d8cc2
commit 57232ce130
7 changed files with 114 additions and 0 deletions

View file

@ -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.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',

View file

@ -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

View file

@ -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

26
lib/docs/scrapers/vuex.rb Normal file
View file

@ -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
&copy; 2015&ndash;2018 Evan You, Vue.js contributors<br>
Licensed under the MIT License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1 @@
http://vuejs.org/