History

Add Vue Router reference

Nicolas Ettlin committed 8 years ago

Commit 2d6c1be1 parent 6ecd9d87 files · +119 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. lib/docs/filters/vue_router/clean_html.rb +14 −0
  3. lib/docs/filters/vue_router/entries.rb +73 −0
  4. lib/docs/scrapers/vue_router.rb +27 −0
  5. public/icons/docs/vue_router/16.png +0 −0
  6. public/icons/docs/vue_router/16@2x.png +0 −0
  7. public/icons/docs/vue_router/SOURCE +2 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -680,6 +680,11 @@ credits = [ · 679 unmodified lines
680 '2013-2018 Evan You, Vue.js contributors',680 '2013-2018 Evan You, Vue.js contributors',
681 'MIT',681 'MIT',
682 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'682 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
683 ], [
684 'Vue Router',
685 '2013-2018 Evan You, Vue.js contributors',
686 'MIT',
687 'https://github.com/vuejs/vue-router/blob/dev/LICENSE'
683 ], [688 ], [
684 'Vulkan',689 'Vulkan',
685 '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',690 '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',
lib/docs/filters/vue_router/clean_html.rb+14−0
@@ -0,0 +1,14 @@
1module Docs
2 class VueRouter
3 class CleanHtmlFilter < Filter
4 def call
5 @doc = at_css('.content')
6
7 # Remove unneeded elements
8 css('.bit-sponsor, .header-anchor').remove
9
10 doc
11 end
12 end
13 end
14end
lib/docs/filters/vue_router/entries.rb+73−0
@@ -0,0 +1,73 @@
1module Docs
2 class VueRouter
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = at_css('h1').content
6
7 name.remove! '# '
8
9 name
10 end
11
12 def get_type
13 return 'Other Guides' if subpath.start_with?('guide/advanced')
14 return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation')
15
16 'API Reference'
17 end
18
19 def include_default_entry?
20 name != 'API Reference'
21 end
22
23 def additional_entries
24 return [] unless subpath.start_with?('api')
25
26 entries = [
27 ['<router-link>', 'router-link', 'API Reference'],
28 ['<router-view>', 'router-view', 'API Reference'],
29 ['$route', 'the-route-object', 'API Reference'],
30 ['Component Injections', 'component-injections', 'API Reference']
31 ]
32
33 css('h3').each do |node|
34 entryName = node.content.strip
35
36 # Get the previous h2 title
37 title = node
38 title = title.previous_element until title.name == 'h2'
39 title = title.content.strip
40 title.remove! '# '
41
42 entryName.remove! '# '
43
44 unless entryName.start_with?('router.')
45 if title == "Router Construction Options"
46 entryName = "RouterOptions.#{entryName}"
47 elsif title == "<router-view> Props"
48 entryName = "<router-view> `#{entryName}` prop"
49 elsif title == "<router-link> Props"
50 entryName = "<router-link> `#{entryName}` prop"
51 else
52 entryName = "> #{entryName} (in: #{title})"
53 end
54 end
55
56 unless title == "Component Injections" || node['id'] == 'applying-active-class-to-outer-element' || node['id'] == 'route-object-properties'
57 entries << [entryName, node['id'], 'API Reference']
58 end
59 end
60
61 css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
62 entryName = node.content.strip
63 id = "route-object-#{entryName.remove('$route.')}"
64
65 node['id'] = id
66 entries << [entryName, node['id'], 'API Reference']
67 end
68
69 entries
70 end
71 end
72 end
73end
lib/docs/scrapers/vue_router.rb+27−0
@@ -0,0 +1,27 @@
1module Docs
2 class VueRouter < UrlScraper
3 self.slug = 'vue_router'
4 self.name = 'Vue Router'
5 self.type = 'simple'
6
7 self.links = {
8 home: 'https://router.vuejs.org',
9 code: 'https://github.com/vuejs/vue-router'
10 }
11
12 html_filters.push 'vue_router/entries', 'vue_router/clean_html'
13
14 self.release = '3.0.1'
15 self.base_url = 'https://router.vuejs.org/'
16
17 options[:skip_patterns] = [
18 # Other languages
19 /^(zh|ja|ru|kr)\//,
20 ]
21
22 options[:attribution] = <<-HTML
23 &copy; 2013&ndash;2018 Evan You, Vue.js contributors<br>
24 Licensed under the MIT License.
25 HTML
26 end
27end
public/icons/docs/vue_router/16.png+0−0

Binary file not shown.

public/icons/docs/vue_router/16@2x.png+0−0

Binary file not shown.

public/icons/docs/vue_router/SOURCE+2−0
@@ -0,0 +1,2 @@
1http://vuejs.org/
2(Edited from the original logo to distinguish Vue Router from Vue)