History

Fix some issues

Kid committed 4 years ago

Commit 7b48eed1 parent b39bebd3 files · +23 −12Browse files

Unified · Split

3 files
  1. lib/docs/filters/yarn/entries.rb +5 −2
  2. lib/docs/filters/yarn/entries_berry.rb +17 −10
  3. lib/docs/scrapers/yarn.rb +1 −0
lib/docs/filters/yarn/entries.rb+5−2
@@ -4,13 +4,16 @@ module Docs · 3 unmodified lines
4 def get_name4 def get_name
5 name = at_css('h1').content5 name = at_css('h1').content
6 6
7 unless type == 'CLI'
8 name.prepend "#{css('.guide-nav a').to_a.index(at_css('.guide-nav a.active')) + 1}. "
9 end
10
7 name11 name
8 end12 end
9 13
10 def get_type14 def get_type
11 type = at_css('.guide-nav a').content.strip15 type = at_css('.guide-nav a').content.strip
12 type.sub! 'CLI Introduction', 'CLI Commands'16 type.sub 'CLI Introduction', 'CLI Commands'
13 type
14 end17 end
15 end18 end
16 end19 end
lib/docs/filters/yarn/entries_berry.rb+17−10
@@ -2,24 +2,31 @@ module Docs · 1 unmodified line
2 class Yarn2 class Yarn
3 class EntriesBerryFilter < Docs::EntriesFilter3 class EntriesBerryFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if slug.start_with?('configuration')
6 filename = at_css('main .active code')
7 content = filename.content
8 return filename.parent.content.sub content, " (#{content})"
9 end
10
5 name = at_css('h1').content11 name = at_css('h1').content
6 12
7 # TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved13 if slug.start_with?('getting-started')
8 if slug.start_with?('sdks') || slug.start_with?('pnpify')14 name.remove! /\d - /
9 name.prepend('yarn ')15
16 active_link = at_css('main .active')
17 links = active_link.parent.children.to_a
18 name.prepend "#{links.index(active_link) + 1}. "
10 end19 end
11 20
21 # TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved
22 name.prepend('yarn ') if slug.start_with?('sdks', 'pnpify')
23
12 name24 name
13 end25 end
14 26
15 def get_type27 def get_type
16 if slug.start_with?('sdks') || slug.start_with?('pnpify')28 return 'CLI' if slug.start_with?('sdks', 'pnpify')
17 'CLI'29 at_css('header .active').content
18 else
19 type = at_css('header div:nth-child(2) .active').content.strip
20 type.remove! 'Home'
21 type
22 end
23 end30 end
24 end31 end
25 end32 end
lib/docs/scrapers/yarn.rb+1−0
@@ -20,6 +20,7 @@ module Docs · 19 unmodified lines
20 code: 'https://github.com/yarnpkg/berry'20 code: 'https://github.com/yarnpkg/berry'
21 }21 }
22 html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title'22 html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title'
23 options[:skip] = ['features', 'cli', 'configuration', 'advanced']
23 options[:skip_patterns] = [/\Aapi/, /\Apackage/]24 options[:skip_patterns] = [/\Aapi/, /\Apackage/]
24 end25 end
25 26