Skip to content

Commit

Permalink
Update WordPress documentation (6.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Nov 18, 2024
1 parent b741457 commit 7e8c19d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
32 changes: 23 additions & 9 deletions lib/docs/filters/wordpress/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@ def call
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|
Expand Down
6 changes: 4 additions & 2 deletions lib/docs/filters/wordpress/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions lib/docs/scrapers/wordpress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -17,7 +17,7 @@ class Wordpress < UrlScraper

html_filters.push 'wordpress/entries', 'wordpress/clean_html'

options[:container] = '#content-area'
options[:container] = 'main'
options[:trailing_slash] = false
options[:only_patterns] = [
/\Afunctions\//,
Expand All @@ -32,7 +32,7 @@ class Wordpress < UrlScraper
]

options[:attribution] = <<-HTML
&copy; 2003&ndash;2022 WordPress Foundation<br>
&copy; 2003&ndash;2024 WordPress Foundation<br>
Licensed under the GNU GPLv2+ License.
HTML

Expand Down

0 comments on commit 7e8c19d

Please sign in to comment.