[devdocsgjs/main: 231/1867] Add WordPress documentation




commit 330e337b7b071e745fd332763839d2a3bba4ceb3
Author: Szabolcs Légrádi <szabolcs legradi gmail com>
Date:   Sun Mar 25 22:01:48 2018 +0200

    Add WordPress documentation

 assets/stylesheets/application-dark.css.scss |   1 +
 assets/stylesheets/application.css.scss      |   1 +
 assets/stylesheets/pages/_wordpress.scss     |  11 ++++++++
 lib/docs/filters/wordpress/clean_html.rb     |  27 +++++++++++++++++++
 lib/docs/filters/wordpress/entries.rb        |  23 ++++++++++++++++
 lib/docs/scrapers/wordpress.rb               |  39 +++++++++++++++++++++++++++
 public/icons/docs/wordpress/16.png           | Bin 0 -> 958 bytes
 public/icons/docs/wordpress/16 2x png        | Bin 0 -> 3284 bytes
 public/icons/docs/wordpress/SOURCE           |   1 +
 9 files changed, 103 insertions(+)
---
diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss
index c8dc1f8f..fd92bdd3 100644
--- a/assets/stylesheets/application-dark.css.scss
+++ b/assets/stylesheets/application-dark.css.scss
@@ -98,5 +98,6 @@
         'pages/underscore',
         'pages/vue',
         'pages/webpack',
+        'pages/wordpress',
         'pages/yard',
         'pages/yii';
diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss
index 26e0b885..4d59a29c 100644
--- a/assets/stylesheets/application.css.scss
+++ b/assets/stylesheets/application.css.scss
@@ -98,5 +98,6 @@
         'pages/underscore',
         'pages/vue',
         'pages/webpack',
+        'pages/wordpress',
         'pages/yard',
         'pages/yii';
diff --git a/assets/stylesheets/pages/_wordpress.scss b/assets/stylesheets/pages/_wordpress.scss
new file mode 100644
index 00000000..78124652
--- /dev/null
+++ b/assets/stylesheets/pages/_wordpress.scss
@@ -0,0 +1,11 @@
+._wordpress {
+  @extend %simple;
+
+  .breadcrumbs {
+    display: none;
+  }
+
+  .callout-warning {
+    @extend %note, %note-red;
+  }
+}
\ No newline at end of file
diff --git a/lib/docs/filters/wordpress/clean_html.rb b/lib/docs/filters/wordpress/clean_html.rb
new file mode 100644
index 00000000..dcc4f397
--- /dev/null
+++ b/lib/docs/filters/wordpress/clean_html.rb
@@ -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
\ No newline at end of file
diff --git a/lib/docs/filters/wordpress/entries.rb b/lib/docs/filters/wordpress/entries.rb
new file mode 100644
index 00000000..012db134
--- /dev/null
+++ b/lib/docs/filters/wordpress/entries.rb
@@ -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
\ No newline at end of file
diff --git a/lib/docs/scrapers/wordpress.rb b/lib/docs/scrapers/wordpress.rb
new file mode 100644
index 00000000..472013ac
--- /dev/null
+++ b/lib/docs/scrapers/wordpress.rb
@@ -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
\ No newline at end of file
diff --git a/public/icons/docs/wordpress/16.png b/public/icons/docs/wordpress/16.png
new file mode 100644
index 00000000..13f3fa64
Binary files /dev/null and b/public/icons/docs/wordpress/16.png differ
diff --git a/public/icons/docs/wordpress/16 2x png b/public/icons/docs/wordpress/16 2x png
new file mode 100644
index 00000000..dd7147c7
Binary files /dev/null and b/public/icons/docs/wordpress/16 2x png differ
diff --git a/public/icons/docs/wordpress/SOURCE b/public/icons/docs/wordpress/SOURCE
new file mode 100644
index 00000000..1c817d62
--- /dev/null
+++ b/public/icons/docs/wordpress/SOURCE
@@ -0,0 +1 @@
+https://wordpress.org/about/logos/
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]