[devdocsgjs/main: 26/239] Fix some issues




commit 7b48eedcb1d889222ce594eb8bb774ee1d9957a7
Author: Kid <44045911+kidonng users noreply github com>
Date:   Mon Nov 29 03:12:14 2021 +0000

    Fix some issues

 lib/docs/filters/yarn/entries.rb       |  7 +++++--
 lib/docs/filters/yarn/entries_berry.rb | 27 +++++++++++++++++----------
 lib/docs/scrapers/yarn.rb              |  1 +
 3 files changed, 23 insertions(+), 12 deletions(-)
---
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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]