diff --git a/lib/docs/filters/yarn/entries.rb b/lib/docs/filters/yarn/entries.rb index 8e242723..ebd65838 100644 --- a/lib/docs/filters/yarn/entries.rb +++ b/lib/docs/filters/yarn/entries.rb @@ -4,13 +4,16 @@ module Docs def get_name 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 end def get_type type = at_css('.guide-nav a').content.strip - type.sub! 'CLI Introduction', 'CLI Commands' - type + type.sub 'CLI Introduction', 'CLI Commands' end end end diff --git a/lib/docs/filters/yarn/entries_berry.rb b/lib/docs/filters/yarn/entries_berry.rb index d70608af..da6a9ea5 100644 --- a/lib/docs/filters/yarn/entries_berry.rb +++ b/lib/docs/filters/yarn/entries_berry.rb @@ -2,24 +2,31 @@ module Docs class Yarn class EntriesBerryFilter < Docs::EntriesFilter 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 - # TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved - if slug.start_with?('sdks') || slug.start_with?('pnpify') - name.prepend('yarn ') + if slug.start_with?('getting-started') + name.remove! /\d - / + + active_link = at_css('main .active') + links = active_link.parent.children.to_a + name.prepend "#{links.index(active_link) + 1}. " end + # TODO: remove when https://github.com/yarnpkg/berry/issues/3809 is resolved + name.prepend('yarn ') if slug.start_with?('sdks', 'pnpify') + name end def get_type - if slug.start_with?('sdks') || slug.start_with?('pnpify') - 'CLI' - else - type = at_css('header div:nth-child(2) .active').content.strip - type.remove! 'Home' - type - end + return 'CLI' if slug.start_with?('sdks', 'pnpify') + at_css('header .active').content end end end diff --git a/lib/docs/scrapers/yarn.rb b/lib/docs/scrapers/yarn.rb index 9ce03a51..90a2a1c7 100644 --- a/lib/docs/scrapers/yarn.rb +++ b/lib/docs/scrapers/yarn.rb @@ -20,6 +20,7 @@ module Docs code: 'https://github.com/yarnpkg/berry' } html_filters.push 'yarn/entries_berry', 'yarn/clean_html_berry', 'title' + options[:skip] = ['features', 'cli', 'configuration', 'advanced'] options[:skip_patterns] = [/\Aapi/, /\Apackage/] end