History

Add Vuex reference

Nicolas Ettlin committed 8 years ago

Commit 57232ce1 parent 6ecd9d87 files · +112 −-2Browse files

Showing the changes to lib/docs (3 of 7 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/vuex/clean_html.rb +14 −0
  2. lib/docs/filters/vuex/entries.rb +68 −0
  3. lib/docs/scrapers/vuex.rb +26 −0
lib/docs/filters/vuex/clean_html.rb+14−0
@@ -0,0 +1,14 @@
1module Docs
2 class Vuex
3 class CleanHtmlFilter < Filter
4 def call
5 @doc = at_css('.content')
6
7 # Remove unneeded elements
8 css('.header-anchor').remove
9
10 doc
11 end
12 end
13 end
14end
lib/docs/filters/vuex/entries.rb+68−0
@@ -0,0 +1,68 @@
1module Docs
2 class Vuex
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = at_css('h1').content
6
7 name.remove! '# '
8
9 # Add index on guides
10 unless subpath.start_with?('api')
11 sidebarLink = at_css('.sidebar-link.active')
12 allLinks = css('.sidebar-link:not([href="/"]):not([href="../index"])')
13
14 index = allLinks.index(sidebarLink)
15
16 name.prepend "#{index + 1}. " if index
17 end
18
19 name
20 end
21
22 def get_type
23 'Guide'
24 end
25
26 def include_default_entry?
27 name != 'API Reference'
28 end
29
30 def additional_entries
31 return [] unless subpath.start_with?('api')
32
33 entries = [
34 ['Component Binding Helpers', 'component-binding-helpers', 'API Reference'],
35 ['Store', 'vuex-store', 'API Reference'],
36 ]
37
38 css('h3').each do |node|
39 entryName = node.content.strip
40
41 # Get the previous h2 title
42 title = node
43 title = title.previous_element until title.name == 'h2'
44 title = title.content.strip
45 title.remove! '# '
46
47 entryName.remove! '# '
48
49 unless entryName.start_with?('router.')
50 if title == "Vuex.Store Constructor Options"
51 entryName = "StoreOptions.#{entryName}"
52 elsif title == "Vuex.Store Instance Properties"
53 entryName = "Vuex.Store.#{entryName}"
54 elsif title == "Vuex.Store Instance Methods"
55 entryName = "Vuex.Store.#{entryName}()"
56 elsif title == "Component Binding Helpers"
57 entryName = "#{entryName}()"
58 end
59 end
60
61 entries << [entryName, node['id'], 'API Reference']
62 end
63
64 entries
65 end
66 end
67 end
68end
lib/docs/scrapers/vuex.rb+26−0
@@ -0,0 +1,26 @@
1module Docs
2 class Vuex < UrlScraper
3 self.name = 'Vuex'
4 self.type = 'simple'
5
6 self.links = {
7 home: 'https://vuex.vuejs.org',
8 code: 'https://github.com/vuejs/vuex'
9 }
10
11 html_filters.push 'vuex/entries', 'vuex/clean_html'
12
13 self.release = '3.0.1'
14 self.base_url = 'https://vuex.vuejs.org/'
15
16 options[:skip_patterns] = [
17 # Other languages
18 /^(zh|ja|ru|kr|fr|ptbr)\//,
19 ]
20
21 options[:attribution] = <<-HTML
22 &copy; 2015&ndash;2018 Evan You, Vue.js contributors<br>
23 Licensed under the MIT License.
24 HTML
25 end
26end