Skip to content

Commit b9b454a

Browse files
authored
Add WordPress documentation (#773)
Add WordPress documentation Co-authored-by: Jasper van Merle <[email protected]>
2 parents e566036 + 7816836 commit b9b454a

File tree

9 files changed

+120
-0
lines changed

9 files changed

+120
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,12 @@ credits = [
728728
'CC BY',
729729
'https://creativecommons.org/licenses/by/4.0/'
730730
], [
731+
'Wordpress',
732+
'2003-2019 WordPress Foundation',
733+
'GPLv2+',
734+
'https://wordpress.org/about/license/'
735+
],
736+
[
731737
'Yarn',
732738
'2016-present Yarn Contributors',
733739
'BSD',

assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,6 @@
106106
'pages/underscore',
107107
'pages/vue',
108108
'pages/webpack',
109+
'pages/wordpress',
109110
'pages/yard',
110111
'pages/yii';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
._wordpress {
2+
@extend %simple;
3+
4+
.breadcrumbs {
5+
display: none;
6+
}
7+
8+
.callout-warning {
9+
@extend %note, %note-red;
10+
}
11+
12+
.callout-alert {
13+
@extend %note, %note-orange;
14+
}
15+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
class Wordpress
3+
class CleanHtmlFilter < Filter
4+
def call
5+
if root_page?
6+
doc.inner_html = '<h1>WordPress</h1>'
7+
return doc
8+
end
9+
10+
article = at_css('article[id^="post-"]')
11+
@doc = at_css('article[id^="post-"]') unless article.nil?
12+
13+
css('hr', '.screen-reader-text', '.table-of-contents',
14+
'.anchor', '.toc-jump', '.source-code-links', '.user-notes',
15+
'.show-more', '.hide-more').remove
16+
17+
br = /<br\s?\/?>/i
18+
19+
header = at_css('h1')
20+
header.content = header.content.strip
21+
doc.prepend_child header
22+
23+
# Add PHP code highlighting
24+
css('pre').each do |node|
25+
node['data-language'] = 'php'
26+
end
27+
28+
css('.source-code-container').each do |node|
29+
node.name = 'pre'
30+
node.inner_html = node.inner_html.gsub(br, "\n")
31+
node.content = node.content.strip
32+
node['data-language'] = 'php'
33+
end
34+
35+
doc
36+
end
37+
end
38+
end
39+
end

lib/docs/filters/wordpress/entries.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Docs
2+
class Wordpress
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
at_css('.breadcrumbs .trail-end').content
6+
end
7+
8+
def get_type
9+
if subpath.starts_with?('classes')
10+
'Classes'
11+
elsif subpath.starts_with?('hooks')
12+
'Hooks'
13+
elsif subpath.starts_with?('functions')
14+
'Functions'
15+
end
16+
end
17+
end
18+
end
19+
end

lib/docs/scrapers/wordpress.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
class Wordpress < UrlScraper
3+
self.name = 'WordPress'
4+
self.type = 'wordpress'
5+
self.release = '5.2.2'
6+
self.base_url = 'https://developer.wordpress.org/reference/'
7+
self.initial_paths = %w(
8+
functions/
9+
hooks/
10+
classes/
11+
)
12+
13+
self.links = {
14+
home: 'https://wordpress.org/',
15+
code: 'https://github.com/WordPress/WordPress'
16+
}
17+
18+
html_filters.push 'wordpress/entries', 'wordpress/clean_html'
19+
20+
options[:container] = '#content-area'
21+
options[:trailing_slash] = false
22+
options[:only_patterns] = [
23+
/\Afunctions\//,
24+
/\Ahooks\//,
25+
/\Aclasses\//
26+
]
27+
28+
options[:skip_patterns] = [
29+
/\Afunctions\/page\/\d+/,
30+
/\Ahooks\/page\/\d+/,
31+
/\Aclasses\/page\/\d+/
32+
]
33+
34+
options[:attribution] = <<-HTML
35+
&copy; 2003&ndash;2019 WordPress Foundation<br>
36+
Licensed under the GNU GPLv2+ License.
37+
HTML
38+
end
39+
end

public/icons/docs/wordpress/16.png

1.48 KB
Loading
1.66 KB
Loading

public/icons/docs/wordpress/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://wordpress.org/about/logos/

0 commit comments

Comments
 (0)