Browse Source

Update WordPress documentation (6.7)

Simon Legner 1 year ago
parent
commit
7e8c19d2c7

+ 23 - 9
lib/docs/filters/wordpress/clean_html.rb

@@ -8,15 +8,29 @@ module Docs
         end
 
         article = at_css('article[id^="post-"]')
-        @doc = at_css('article[id^="post-"]') unless article.nil?
-
-        css('hr', '.screen-reader-text', '.table-of-contents',
-            '.anchor', '.toc-jump', '.source-code-links', '.user-notes',
-            '.show-more', '.hide-more').remove
-
-        header = at_css('h1')
-        header.content = header.content.strip
-        doc.prepend_child header
+        @doc = article unless article.nil?
+
+        css(
+          'hr',
+          '.screen-reader-text',
+          '.table-of-contents',
+          '.anchor',
+          '.toc-jump',
+          '.source-code-links',
+          '.user-notes',
+          '.show-more',
+          '.hide-more',
+          '.wp-block-wporg-sidebar-container',
+          'section[data-nosnippet="true"]',
+          # 'section:contains("before being able to contribute a note or feedback")',
+          ).remove
+
+        if at_css('.entry-content')
+          header = at_css('h1')
+          header.remove_attribute('style')
+          @doc = at_css('.entry-content')
+          doc.prepend_child header
+        end
 
         # Remove permalink
         css('h2 > a, h3 > a').each do |node|

+ 4 - 2
lib/docs/filters/wordpress/entries.rb

@@ -2,11 +2,13 @@ module Docs
   class Wordpress
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        at_css('.breadcrumbs .trail-end').content
+        at_css('h1').content
       end
 
       def get_type
-        if subpath.starts_with?('classes')
+        if subpath.starts_with?('classes') and subpath.count('/') == 3
+          'Methods'
+        elsif subpath.starts_with?('classes')
           'Classes'
         elsif subpath.starts_with?('hooks')
           'Hooks'

+ 3 - 3
lib/docs/scrapers/wordpress.rb

@@ -2,7 +2,7 @@ module Docs
   class Wordpress < UrlScraper
     self.name = 'WordPress'
     self.type = 'wordpress'
-    self.release = '6.1'
+    self.release = '6.7'
     self.base_url = 'https://developer.wordpress.org/reference/'
     self.initial_paths = %w(
       functions/
@@ -17,7 +17,7 @@ module Docs
 
     html_filters.push 'wordpress/entries', 'wordpress/clean_html'
 
-    options[:container] = '#content-area'
+    options[:container] = 'main'
     options[:trailing_slash] = false
     options[:only_patterns] = [
       /\Afunctions\//,
@@ -32,7 +32,7 @@ module Docs
     ]
 
     options[:attribution] = <<-HTML
-      &copy; 2003&ndash;2022 WordPress Foundation<br>
+      &copy; 2003&ndash;2024 WordPress Foundation<br>
       Licensed under the GNU GPLv2+ License.
     HTML