History

Add Vue Router reference (#881)

Add Vue Router reference

Jasper van Merle committed 7 years ago

Commit 58973bf2 parents ee6b195 1c3a9767 files · +118 −-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 +71 −0
  4. lib/docs/scrapers/vue_router.rb +29 −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 +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -734,6 +734,11 @@ credits = [ · 733 unmodified lines
734 '2013-2018 Evan You, Vue.js contributors',734 '2013-2018 Evan You, Vue.js contributors',
735 'MIT',735 'MIT',
736 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'736 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
737 ], [
738 'Vue Router',
739 '2013-present Evan You',
740 'MIT',
741 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE'
737 ], [742 ], [
738 'Vulkan',743 'Vulkan',
739 '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',744 '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+71−0
@@ -0,0 +1,71 @@
1module Docs
2 class VueRouter
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = at_css('h1').content
6 name.remove! '# '
7 name
8 end
9
10 def get_type
11 return 'Other Guides' if subpath.start_with?('guide/advanced')
12 return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation')
13 'API Reference'
14 end
15
16 def include_default_entry?
17 name != 'API Reference'
18 end
19
20 def additional_entries
21 return [] unless subpath.start_with?('api')
22
23 entries = [
24 ['<router-link>', 'router-link', 'API Reference'],
25 ['<router-view>', 'router-view', 'API Reference'],
26 ['$route', 'the-route-object', 'API Reference'],
27 ['Component Injections', 'component-injections', 'API Reference']
28 ]
29
30 css('h3').each do |node|
31 entry_name = node.content.strip
32
33 # Get the previous h2 title
34 title = node
35 title = title.previous_element until title.name == 'h2'
36 title = title.content.strip
37 title.remove! '# '
38
39 entry_name.remove! '# '
40
41 case title
42 when 'Router Construction Options'
43 entry_name = "RouterOptions.#{entry_name}"
44 when '<router-view> Props'
45 entry_name = "<router-view> `#{entry_name}` prop"
46 when '<router-link> Props'
47 entry_name = "<router-link> `#{entry_name}` prop"
48 when 'Router Instance Methods'
49 entry_name = "#{entry_name}()"
50 end
51
52 entry_name = entry_name.split(' API ')[0] if entry_name.start_with?('v-slot')
53
54 unless title == "Component Injections" || node['id'] == 'route-object-properties'
55 entries << [entry_name, node['id'], 'API Reference']
56 end
57 end
58
59 css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
60 entry_name = node.content.strip
61 id = "route-object-#{entry_name.remove('$route.')}"
62
63 node['id'] = id
64 entries << [entry_name, node['id'], 'API Reference']
65 end
66
67 entries
68 end
69 end
70 end
71end
lib/docs/scrapers/vue_router.rb+29−0
@@ -0,0 +1,29 @@
1module Docs
2 class VueRouter < UrlScraper
3 self.name = 'Vue Router'
4 self.slug = 'vue_router'
5 self.type = 'simple'
6 self.release = '3.1.2'
7 self.base_url = 'https://router.vuejs.org/'
8 self.links = {
9 home: 'https://router.vuejs.org',
10 code: 'https://github.com/vuejs/vue-router'
11 }
12
13 html_filters.push 'vue_router/entries', 'vue_router/clean_html'
14
15 options[:skip_patterns] = [
16 # Other languages
17 /^(zh|ja|ru|kr|fr)\//,
18 ]
19
20 options[:attribution] = <<-HTML
21 &copy; 2013&ndash;present Evan You<br>
22 Licensed under the MIT License.
23 HTML
24
25 def get_latest_version(opts)
26 get_latest_github_release('vuejs', 'vue-router', opts)
27 end
28 end
29end
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+1−0
@@ -0,0 +1 @@
1https://github.com/vuejs/vuejs.org/blob/master/assets/logo.ai