[devdocsgjs/main: 166/239] First community review version for Tailwind CSS




commit 25e621b52256872855ece5e35cbb3c1d599f27ef
Author: Damilola Olowookere <damms005 gmail com>
Date:   Fri Feb 26 18:00:02 2021 +0100

    First community review version for Tailwind CSS

 lib/docs/filters/tailwindcss/clean_html.rb | 76 ++++--------------------------
 lib/docs/filters/tailwindcss/entries.rb    | 33 -------------
 lib/docs/scrapers/tailwindcss.rb           | 13 +++--
 3 files changed, 19 insertions(+), 103 deletions(-)
---
diff --git a/lib/docs/filters/tailwindcss/clean_html.rb b/lib/docs/filters/tailwindcss/clean_html.rb
index fda174a2..017d1a62 100644
--- a/lib/docs/filters/tailwindcss/clean_html.rb
+++ b/lib/docs/filters/tailwindcss/clean_html.rb
@@ -2,75 +2,17 @@ module Docs
   class Tailwindcss
     class CleanHtmlFilter < Filter
       def call
-          clean_up
-
-        # Remove code highlighting
-        css('pre').each do |node|
-          node.content = node.content
-          node['data-language'] = 'php'
-        end
-
-        doc
-      end
-
-      def clean_up
-        @doc = doc.at_css('#content-wrapper')
-
-        css('.location').remove
-
-        # Replace .header with <h1>
-        css('.page-header > h1').each do |node|
-          node.content = 'Tailwind' if root_page?
-          node.parent.before(node).remove
-        end
-
-        css('.container-fluid').each do |node|
-          node.name = 'table'
-          node.css('.row').each { |n| n.name = 'tr' }
-          node.css('div[class^="col"]').each { |n| n.name = 'td' }
-        end
-
-        css('> div').each do |node|
-          node.before(node.children).remove
-        end
-
-        # Remove <abbr>
-        css('a > abbr').each do |node|
-          node.parent['title'] = node['title']
-          node.before(node.children).remove
-        end
-
-        # Clean up headings
-        css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node|
-          node.before(node.children).remove
-        end
-
-        # Remove empty <td>
-        css('td').each do |node|
-          node.remove if node.content =~ /\A\s+\z/
-        end
-
-        # @doc = at_css('.docs_body')
-
-        # Clean up headings
-        css('h2 > a').each do |node|
-          node.before(node.children).remove
-        end
-
-        css('p > a[name]').each do |node|
-          node.parent.next_element['id'] = node['name']
-        end
-
-        css('blockquote').each do |node|
-          node['class'] = 'tip' if node.inner_html.include?('{tip}')
-          node.inner_html = node.inner_html.remove(/\{(tip|note)\}\s?/)
-        end
-
-        css('blockquote').each do |node|
-          if node.inner_html.include?('You\'re browsing the documentation for an old version of Laravel.')
-            node.remove
+        css('div.sticky.top-0').remove
+        css('.sr-only').remove
+        css('#sidebar').remove
+
+        css('#nav ul li').each do |node|
+          link = node.css("a").attr('href').to_s
+          if link.include? "https://";
+            node.remove()
           end
         end
+        doc
       end
     end
   end
diff --git a/lib/docs/filters/tailwindcss/entries.rb b/lib/docs/filters/tailwindcss/entries.rb
index 2fc2af2b..4e8e8786 100644
--- a/lib/docs/filters/tailwindcss/entries.rb
+++ b/lib/docs/filters/tailwindcss/entries.rb
@@ -1,16 +1,6 @@
 module Docs
   class Tailwindcss
     class EntriesFilter < Docs::EntriesFilter
-      # def get_name
-      #   if api_page?
-      #     name = at_css('h1').content.strip.remove('Illuminate\\')
-      #     name << " (#{type})" unless name.start_with?(self.type)
-      #     name
-      #   else
-      #     at_css('h1').content
-      #   end
-      # end
-
       def get_type
         # /customizing-colors rediects to /colors, hence making css
         # selector below not to match the href
@@ -23,29 +13,6 @@ module Docs
         check = at_css(selector).parent.parent.parent.css('h5').inner_text
         check
       end
-
-      # def additional_entries
-      #   return [] if root_page? || !api_page?
-      #   base_name = self.name.remove(/\(.+\)/).strip
-
-      #   css('h3[id^="method_"]').each_with_object [] do |node, entries|
-      #     next if node.at_css('.location').content.start_with?('in')
-
-      #     name = node['id'].remove('method_')
-      #     name.prepend "#{base_name}::"
-      #     name << '()'
-
-      #     entries << [name, node['id']]
-      #   end
-      # end
-
-      # def api_page?
-      #   subpath.start_with?('/api')
-      # end
-
-      # def include_default_entry?
-      #   true
-      # end
     end
   end
 end
diff --git a/lib/docs/scrapers/tailwindcss.rb b/lib/docs/scrapers/tailwindcss.rb
index d13dfe24..035f55a4 100644
--- a/lib/docs/scrapers/tailwindcss.rb
+++ b/lib/docs/scrapers/tailwindcss.rb
@@ -4,16 +4,23 @@ module Docs
     self.type = 'tailwindcss'
     self.slug = 'tailwindcss'
     self.base_url = 'https://tailwindcss.com/docs'
-    self.root_path = '/installation'
-    self.release = '8.5'
+    self.root_path = '/'
+    self.release = '2.0.3'
 
     html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html'
 
     # options[:container] = 'body';
 
     options[:skip_patterns] = [
+
+        # removed because it focuses on how to use Tailwind with some other niche
+        # technologies and to also align with DevDoc's Vision, which is" to:"
+        # "indexing only the minimum useful to most developers" that use Tailwind
         %r{\/guides\/.*},
+
+        # removed so it is easy to "get_type" (see tailwindcss/entries.rb line #15)
         %r{\/colors\z}
+
       ]
 
     #Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE
@@ -25,7 +32,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://tailwindcss.com/docs/installation', opts)
-      doc.at_css('select option[value=v2]').inner_text
+      doc.at_css('select option[value=v2]').inner_text[1..]
     end
   end
 end


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