Add WordPress documentation

pull/773/head
Szabolcs Légrádi 7 years ago
parent 1be7a8f37d
commit 330e337b7b

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

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

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

@ -0,0 +1,27 @@
module Docs
class Wordpress
class CleanHtmlFilter < Filter
def call
if root_page?
doc.inner_html = '<h1>WordPress</h1>'
return doc
end
css('hr', '.screen-reader-text', '.table-of-contents',
'.anchor', '.toc-jump', '.source-code-links', '.related',
'.user-notes').remove
# Add PHP code highlighting
br = /<br\s?\/?>/i
css('.source-code-container', '.syntaxhighlighter').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,23 @@
module Docs
class Wordpress
class EntriesFilter < Docs::EntriesFilter
def breadcrumbs
@breadcrumbs ||= css('.breadcrumbs .trail-inner a')
.map(&:content)
.map(&:strip)
end
def get_name
at_css('.breadcrumbs .trail-end').content
end
def get_type
if breadcrumbs.size > 1
breadcrumbs.drop(1).join(': ')
else
at_css('.breadcrumbs .trail-end').content
end
end
end
end
end

@ -0,0 +1,39 @@
module Docs
class Wordpress < UrlScraper
self.name = 'WordPress'
self.type = 'wordpress'
self.release = '4.9.4'
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/clean_html', 'wordpress/entries'
options[:container] = '#content-area'
options[:trailing_slash] = true
options[:only_patterns] = [
/\Afunctions\//,
/\Ahooks\//,
/\Aclasses\//
]
options[:skip_patterns] = [
/\Afunctions\/page\/\d+/,
/\Ahooks\/page\/\d+/,
/\Aclasses\/page\/\d+/
]
options[:attribution] = <<-HTML
&copy; 2003&ndash;2018 WordPress Foundation<br>
Licensed under the GNU GPLv2+ License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

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