From 1fda4fcb0cf6f345cd1b543755e7de83180ed552 Mon Sep 17 00:00:00 2001 From: edno Date: Sun, 4 Dec 2016 00:40:08 +0100 Subject: [PATCH] CodeceptJS documentation --- .../javascripts/views/pages/codeceptjs.coffee | 9 ++++++ assets/stylesheets/application-dark.css.scss | 1 + assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_codeceptjs.scss | 3 ++ lib/docs/filters/codeceptjs/clean_html.rb | 19 ++++++++++++ lib/docs/filters/codeceptjs/entries.rb | 27 ++++++++++++++++++ lib/docs/scrapers/codeceptjs.rb | 25 ++++++++++++++++ public/icons/docs/codeceptjs/16.png | Bin 0 -> 855 bytes public/icons/docs/codeceptjs/16@2x.png | Bin 0 -> 2162 bytes public/icons/docs/codeceptjs/SOURCE | 1 + 10 files changed, 86 insertions(+) create mode 100644 assets/javascripts/views/pages/codeceptjs.coffee create mode 100644 assets/stylesheets/pages/_codeceptjs.scss create mode 100644 lib/docs/filters/codeceptjs/clean_html.rb create mode 100644 lib/docs/filters/codeceptjs/entries.rb create mode 100644 lib/docs/scrapers/codeceptjs.rb create mode 100644 public/icons/docs/codeceptjs/16.png create mode 100644 public/icons/docs/codeceptjs/16@2x.png create mode 100644 public/icons/docs/codeceptjs/SOURCE diff --git a/assets/javascripts/views/pages/codeceptjs.coffee b/assets/javascripts/views/pages/codeceptjs.coffee new file mode 100644 index 00000000..18bb626e --- /dev/null +++ b/assets/javascripts/views/pages/codeceptjs.coffee @@ -0,0 +1,9 @@ +#= require views/pages/base + +class app.views.CodeceptjsPage extends app.views.BasePage + + prepare: -> + for el in @findAll('pre > code') + if /js/i.test(el.className) + @highlightCode(el, 'javascript') + return diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 23884a92..68c6350d 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -40,6 +40,7 @@ 'pages/cakephp', 'pages/clojure', 'pages/codeception', + 'pages/codeceptjs', 'pages/coffeescript', 'pages/cordova', 'pages/crystal', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index bfa6cf8c..90ffb5c0 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -40,6 +40,7 @@ 'pages/cakephp', 'pages/clojure', 'pages/codeception', + 'pages/codeceptjs', 'pages/coffeescript', 'pages/cordova', 'pages/crystal', diff --git a/assets/stylesheets/pages/_codeceptjs.scss b/assets/stylesheets/pages/_codeceptjs.scss new file mode 100644 index 00000000..a3916d90 --- /dev/null +++ b/assets/stylesheets/pages/_codeceptjs.scss @@ -0,0 +1,3 @@ +._codeceptjs { + @extend %simple; +} diff --git a/lib/docs/filters/codeceptjs/clean_html.rb b/lib/docs/filters/codeceptjs/clean_html.rb new file mode 100644 index 00000000..4d1d8485 --- /dev/null +++ b/lib/docs/filters/codeceptjs/clean_html.rb @@ -0,0 +1,19 @@ +module Docs + class Codeceptjs + class CleanHtmlFilter < Filter + def call + root_page? ? root : other + doc + end + + def root + doc.inner_html = ' ' + end + + def other + @doc = doc.at_css('div.reference').xpath('//div[@role="main"]') + doc + end + end + end +end diff --git a/lib/docs/filters/codeceptjs/entries.rb b/lib/docs/filters/codeceptjs/entries.rb new file mode 100644 index 00000000..2927d094 --- /dev/null +++ b/lib/docs/filters/codeceptjs/entries.rb @@ -0,0 +1,27 @@ +module Docs + class Codeceptjs + class EntriesFilter < Docs::EntriesFilter + def get_name + (at_css('h1') || at_css('h2')).content + end + + def get_type + return "Reference" if %w(commands configuration reports translation).include? subpath.scan(/\w+/).first + return "Guides" unless slug.camelize =~ /Helpers::.+/ + "Helpers::" + (at_css('h1') || at_css('h2')).content + end + + def additional_entries + return [] unless type =~ /Helpers::.*/ + + helper = type.sub(/Helpers::/, '')+ '::' + + css('h2').map do |node| + next if node['id'] == 'access-from-helpers' + [helper + node.content, node['id']] + end.compact + end + + end + end +end diff --git a/lib/docs/scrapers/codeceptjs.rb b/lib/docs/scrapers/codeceptjs.rb new file mode 100644 index 00000000..8aa2a562 --- /dev/null +++ b/lib/docs/scrapers/codeceptjs.rb @@ -0,0 +1,25 @@ +module Docs + class Codeceptjs < UrlScraper + self.name = 'CodeceptJS' + self.type = 'codeceptjs' + self.root_path = 'index.html' + self.release = '0.4' + self.base_url = 'http://codecept.io/' + self.links = { + home: 'http://codecept.io/', + code: 'https://github.com/codeception/codeceptjs' + } + + html_filters.push 'codeceptjs/clean_html', 'codeceptjs/entries', 'title' + + options[:root_title] = 'CodeceptJS' + options[:title] = false + options[:skip_links] = ->(filter) { !filter.initial_page? } + options[:skip_patterns] = [/changelog/, /quickstart$/] + + options[:attribution] = <<-HTML + © 2015–2016 Michael Bodnarchuk and Contributors
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/codeceptjs/16.png b/public/icons/docs/codeceptjs/16.png new file mode 100644 index 0000000000000000000000000000000000000000..4be32d5e220a17327d389036c025ed240a5540cf GIT binary patch literal 855 zcmV-d1E~CoP)qy`Born9ni2#CA_3MeFmq$!C&ekG-VATB@3 zi0~s*GW$SNDL&L%A?ifoy?T4wT(u6nxBKMTb^V@e&vOyP{~CbUhqca=_-@aozTC4S zuAM=&a$z%K3D(){>6RXM%0Ct00@D5eFyjEQdpfNY%H8@fy!df9N8Ss3%=qsuOT&zIMn zAU4-mzP@}~&zPQgb?En6u`njU)}jQ>586@PWP$FE1j1?|$eL1gG;@&nAVgqPL0wm> zrNl-eoE{(6GJrlC2ZN6-2)((F^++48s_N0+Wk5+)1q_A)JfIUy4&(t*5(}?nC|0S1 z#7^>kCKxa?0FUhg7A8pyjXr|SVTV{}gtMy*t&Kb=wZ*7V3oz{~X8_B=O3(?m2x@&W z5?vgFw<8bUwu?xHgxL6Ggr>CvrnUy=VH@lDFw+pRN&x?ei~-Dz%TQFMP7;~8!JOHc zqUI*sF=*!_IWJ-a$%qxt25OjOdVL|PZVBLaNs$VZ$V5nZ`xVHoRQm{oE6!1|x@aab zf|aEqY^^wfH7lr96Jm1)40ZDvh~LS@_R_ET-$Ep6?P zb8z=c(?^?Uhp%8KEWzd?iNOImawIj&Y_aO>pOp?39ZY|cu)fceBk@^L>fLA|UbuJ| z?&iSp^LyPwG+LB9^vzG%mtah-) h%JbRRM8|$N`~a_0Y+!)9C@la0002ovPDHLkV1f`hmdXGC literal 0 HcmV?d00001 diff --git a/public/icons/docs/codeceptjs/16@2x.png b/public/icons/docs/codeceptjs/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..119b2df2d12261bd0a9d2a64f361d0884e5e7ef2 GIT binary patch literal 2162 zcmV-&2#xoNP)|bWte!FE4*izpS*S>FfAna!qW+${yzU-n zAvmXI901<^uMAH+!hYx)R{aHIDi-6+J&dbY3D}8^seB}5nh>B&6cDOQ#h`PtiwJ!G zn|nQ}|0U*2O<1gRV)=mwtDV4dE3jw-W{ZKz)E5Ne@$_*OP9qmfCe+Ss`1-G){@o;dvU09lT!ug~bgS~g)9BdJu-L4IIrZeD~OhKi!S~MP_J%^_I zR#>tQq5S%XlcqEuspO#K+h5iAuL-#xk7s>xZWukCMYvlWDJa{Cnj6P3)OrewBUwn! zDiR5>8F{F$NfqVH8B#7a^>{(3Qu(fgVZQZc#(zU-;yAZwWWWwv*_k~JZ%1{G4+aN2 z5Ege{Fn&axg5nA@YD=QLQlr(fi{GAET?a7?y15F4@9sew@r88$5W%@Xk)-Z@S&?Ncvt|U4DkTvRL6jWlq2= z3G{YVB3yq#Bv5wOiiS$%zVcaDjv-W?FhnGNv7NvlIgV@Qz3*$y+ePCaC8lAZ*G~WW>?vQ7O*-q3BP}ZqesW_$KqT{{Edo)5_2+8~sLBlz4~$KW zpryH7D7Kx-8g2$+xH}8Fv`mpexvhx`_Qbw~@80mkYmrASGQfF?0oK=Qc= z6khSA>v#xl)ghn`D)f%jt9tk;jDlm_gpQ1zj}Qnm>)IMVU3_*(V35w>|(+D@PrGv zU0aOQO9~uTvM`>DMA0=ViU~RCfhf4@ho-W_a645Zf&LCHg4ISy6^3IHaL-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