mirror of https://github.com/freeCodeCamp/devdocs
parent
6ecd9d8cc2
commit
57232ce130
@ -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
|
@ -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
|
@ -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<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1 @@
|
||||
http://vuejs.org/
|
Loading…
Reference in new issue