From 330e337b7b071e745fd332763839d2a3bba4ceb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20L=C3=A9gr=C3=A1di?= Date: Sun, 25 Mar 2018 22:01:48 +0200 Subject: [PATCH] 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(+) create mode 100644 assets/stylesheets/pages/_wordpress.scss create mode 100644 lib/docs/filters/wordpress/clean_html.rb create mode 100644 lib/docs/filters/wordpress/entries.rb create mode 100644 lib/docs/scrapers/wordpress.rb create mode 100644 public/icons/docs/wordpress/16.png create mode 100644 public/icons/docs/wordpress/16@2x.png create mode 100644 public/icons/docs/wordpress/SOURCE 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 = '

WordPress

' + 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 = //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 + © 2003–2018 WordPress Foundation
+ 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 0000000000000000000000000000000000000000..13f3fa64dd7aee3835861516bd4a5e51de297ac7 GIT binary patch literal 958 zcmV;v13~$dbKQO*@ZEgH%pcb<}T*4%`BNe6J0dK zFh~cw0i`ieDg8CpgV1)grBK>)_I^h$%ue#0obUaf=Q;2DeecWJ&-CGcPcz{o!d}9b zwb%qL}N`Q_PZT$+iPaJ`)(=mR5nQb zw+VT{xa%!u@Rg(5@XD2s4_nV)9X1a>3}YdagRB4?$0LfYI^|7O6aZfZ+Quu9^QpoGy`NsSrGUV=cTzuuo!*W=N7Fb&f(1G~Gf+CCDRM|2^B z7PAq$GA%ek1J6txilSiOCJP+~k60?J8Vm>K(6phlfj(>1BB>@$)U3n6^b=?V9($V1 zfFi?IrBwxO^(K@H3f5O>5t&aTG?#?Hb8Jgs2GK`SB4{<~;fW;a^AYD;R&AqV)85)n>v(AcEhA z{sH^f8(SQ3+AJ6to5G$}E0~7DcbP%&ZC}XUUSIjhT2&5DIH9Kf$?I+SJ2Z!2VhPD? z4x6nT@GP5$QLn>+t*w5hA=)Ko;G?_$`TgFTnKS#EGV#S_S$7w^56InmdjCC!ga%dgEu&y19sJNEU}*vV~{KtTqkrA6qC>rrE=gOrn5OQOSW z3LO9TW`uD`bCwC!SzyETQ}=c>oc&H6rh`tK_ucju-A>2LHb(LUo`ioHonE}{3%l7c z1uuMf@%ZHj&xeWi4xya&3&B|7-0iAxbsiB7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ev478D%j95_9JhA_RYx;E_i7Da4~ysb&sr5RPpDm#Lm0_;PAgxxc%H$0BrWs#%139` ze*T6lhQAv?p^O-qLISV^EUxQ(2(G!m=105I+nH)(_{RjGL=%5%d~2jMuc-_I-E|^e zV1XN>^a#?!nVYfGC+Z$&1z0LFw6!@OMi+Nx<9vE?w<`t*lZ^JME(V5y2kI<>tJWrY zI#msdmp|Xq6+vUv@H-c~9$1b9+w#{{&8&*z?6j4>SuZ4?iiCOXc2sBxt6U zy5ErCmg%iK3lp+_nYhxA=FGkCFPM_I4;Vepr7REMhQE;Y+n;hX>m7)Z7bV8Vs5dVy zDO65%To&4AJCU3y{2KY`dAt18=zzNLn!hxNKqpGYiAw96e;PLe*$qZq9wEGHnS2d{ zR1|ad3NZ7_*igB`aT@ym1mul1||jVtZ=vlAVpnKI1ODwDPOr4ZW+z+m%~N z=NzrdjT+bVPPAp+T|X1~e!SGm1^eRSF~#gI$*6qS>+-w2K)*#en%Mp8u)h`VFGG!y zLgLDtV8qH(TdJeRlU(iKXTSf|8{-t9>`KKrT_>|ycg@8u1j&ssHtgShQP9r6!7gzWPl+WDp zURpm5&DZe-P*dBecbX;|Nd6N=nhAHur^(UWW|H)lgo-2SOw*^{Uqeb>*4^&M_2sMN tt53>4{%xmS%S_yChvl^|A7`O_LZHMPRuh>`*WdilFvD1(OH5s({|%@}uC4$8 literal 0 HcmV?d00001 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