Fix some issues

pull/1667/head
Kid 3 years ago committed by GitHub
parent b39bebd27a
commit 7b48eedcb1

@ -4,13 +4,16 @@ module Docs
def get_name def get_name
name = at_css('h1').content name = at_css('h1').content
unless type == 'CLI'
name.prepend "#{css('.guide-nav a').to_a.index(at_css('.guide-nav a.active')) + 1}. "
end
name name
end end
def get_type def get_type
type = at_css('.guide-nav a').content.strip type = at_css('.guide-nav a').content.strip
type.sub! 'CLI Introduction', 'CLI Commands' type.sub 'CLI Introduction', 'CLI Commands'
type
end end
end end
end end

@ -2,24 +2,31 @@ module Docs
class Yarn class Yarn
class EntriesBerryFilter < Docs::EntriesFilter class EntriesBerryFilter < Docs::EntriesFilter
def get_name def get_name
if slug.start_with?('configuration')
filename = at_css('main .active code')
content = filename.content
return filename.parent.content.sub content, " (#{content})"
end
name = at_css('h1').content name = at_css('h1').content
# TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved if slug.start_with?('getting-started')
if slug.start_with?('sdks') || slug.start_with?('pnpify') name.remove! /\d - /
name.prepend('yarn ')
active_link = at_css('main .active')
links = active_link.parent.children.to_a
name.prepend "#{links.index(active_link) + 1}. "
end end
# TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved
name.prepend('yarn ') if slug.start_with?('sdks', 'pnpify')
name name
end end
def get_type def get_type
if slug.start_with?('sdks') || slug.start_with?('pnpify') return 'CLI' if slug.start_with?('sdks', 'pnpify')
'CLI' at_css('header .active').content
else
type = at_css('header div:nth-child(2) .active').content.strip
type.remove! 'Home'
type
end
end end
end end
end end

@ -20,6 +20,7 @@ module Docs
code: 'https://github.com/yarnpkg/berry' code: 'https://github.com/yarnpkg/berry'
} }
html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title' html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title'
options[:skip] = ['features', 'cli', 'configuration', 'advanced']
options[:skip_patterns] = [/\Aapi/, /\Apackage/] options[:skip_patterns] = [/\Aapi/, /\Apackage/]
end end

Loading…
Cancel
Save