Add WordPress documentation (#773)

Add WordPress documentation

Co-authored-by: Jasper van Merle <jaspervmerle@gmail.com>
pull/1053/head
Jasper van Merle 6 years ago committed by GitHub
commit b9b454a272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -728,6 +728,12 @@ credits = [
'CC BY',
'https://creativecommons.org/licenses/by/4.0/'
], [
'Wordpress',
'2003-2019 WordPress Foundation',
'GPLv2+',
'https://wordpress.org/about/license/'
],
[
'Yarn',
'2016-present Yarn Contributors',
'BSD',

@ -106,5 +106,6 @@
'pages/underscore',
'pages/vue',
'pages/webpack',
'pages/wordpress',
'pages/yard',
'pages/yii';

@ -0,0 +1,15 @@
._wordpress {
@extend %simple;
.breadcrumbs {
display: none;
}
.callout-warning {
@extend %note, %note-red;
}
.callout-alert {
@extend %note, %note-orange;
}
}

@ -0,0 +1,39 @@
module Docs
class Wordpress
class CleanHtmlFilter < Filter
def call
if root_page?
doc.inner_html = '<h1>WordPress</h1>'
return doc
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
br = /<br\s?\/?>/i
header = at_css('h1')
header.content = header.content.strip
doc.prepend_child header
# Add PHP code highlighting
css('pre').each do |node|
node['data-language'] = 'php'
end
css('.source-code-container').each do |node|
node.name = 'pre'
node.inner_html = node.inner_html.gsub(br, "\n")
node.content = node.content.strip
node['data-language'] = 'php'
end
doc
end
end
end
end

@ -0,0 +1,19 @@
module Docs
class Wordpress
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('.breadcrumbs .trail-end').content
end
def get_type
if subpath.starts_with?('classes')
'Classes'
elsif subpath.starts_with?('hooks')
'Hooks'
elsif subpath.starts_with?('functions')
'Functions'
end
end
end
end
end

@ -0,0 +1,39 @@
module Docs
class Wordpress < UrlScraper
self.name = 'WordPress'
self.type = 'wordpress'
self.release = '5.2.2'
self.base_url = 'https://developer.wordpress.org/reference/'
self.initial_paths = %w(
functions/
hooks/
classes/
)
self.links = {
home: 'https://wordpress.org/',
code: 'https://github.com/WordPress/WordPress'
}
html_filters.push 'wordpress/entries', 'wordpress/clean_html'
options[:container] = '#content-area'
options[:trailing_slash] = false
options[:only_patterns] = [
/\Afunctions\//,
/\Ahooks\//,
/\Aclasses\//
]
options[:skip_patterns] = [
/\Afunctions\/page\/\d+/,
/\Ahooks\/page\/\d+/,
/\Aclasses\/page\/\d+/
]
options[:attribution] = <<-HTML
&copy; 2003&ndash;2019 WordPress Foundation<br>
Licensed under the GNU GPLv2+ License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1 @@
https://wordpress.org/about/logos/
Loading…
Cancel
Save