From 8232a0538a9828413e272f258ffc48e26f8a10ed Mon Sep 17 00:00:00 2001 From: Phil Scherer Date: Tue, 8 Dec 2015 19:53:20 -0500 Subject: [PATCH] Add CodeIgniter Documentation --- .../views/pages/codeigniter.coffee | 6 +++ assets/stylesheets/application-dark.css.scss | 1 + assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_codeigniter.scss | 6 +++ assets/stylesheets/pages/_sphinx.scss | 6 ++- lib/docs/filters/codeigniter/clean_html.rb | 24 ++++++++++ lib/docs/filters/codeigniter/entries.rb | 42 ++++++++++++++++++ lib/docs/scrapers/codeigniter.rb | 35 +++++++++++++++ public/icons/docs/codeigniter/16.png | Bin 0 -> 882 bytes public/icons/docs/codeigniter/16@2.png | Bin 0 -> 1679 bytes public/icons/docs/codeigniter/SOURCE | 1 + 11 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 assets/javascripts/views/pages/codeigniter.coffee create mode 100644 assets/stylesheets/pages/_codeigniter.scss create mode 100644 lib/docs/filters/codeigniter/clean_html.rb create mode 100644 lib/docs/filters/codeigniter/entries.rb create mode 100644 lib/docs/scrapers/codeigniter.rb create mode 100644 public/icons/docs/codeigniter/16.png create mode 100644 public/icons/docs/codeigniter/16@2.png create mode 100644 public/icons/docs/codeigniter/SOURCE diff --git a/assets/javascripts/views/pages/codeigniter.coffee b/assets/javascripts/views/pages/codeigniter.coffee new file mode 100644 index 00000000..606ecae4 --- /dev/null +++ b/assets/javascripts/views/pages/codeigniter.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.CodeigniterPage extends app.views.BasePage + prepare: -> + @highlightCode @findAllByTag('pre'), 'php' + return diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 6e9a310f..2ba96e28 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -36,6 +36,7 @@ 'pages/cakephp', 'pages/chai', 'pages/clojure', + 'pages/codeigniter', 'pages/coffeescript', 'pages/d3', 'pages/dojo', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 35e24aac..d3bf5c58 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -36,6 +36,7 @@ 'pages/cakephp', 'pages/chai', 'pages/clojure', + 'pages/codeigniter', 'pages/coffeescript', 'pages/d3', 'pages/dojo', diff --git a/assets/stylesheets/pages/_codeigniter.scss b/assets/stylesheets/pages/_codeigniter.scss new file mode 100644 index 00000000..5cda3059 --- /dev/null +++ b/assets/stylesheets/pages/_codeigniter.scss @@ -0,0 +1,6 @@ +._codeigniter { + @extend %sphinx; + + .important { @extend %note-orange; } + .warning { @extend %note-red; } +} diff --git a/assets/stylesheets/pages/_sphinx.scss b/assets/stylesheets/pages/_sphinx.scss index 44b9f1f3..35351cf1 100644 --- a/assets/stylesheets/pages/_sphinx.scss +++ b/assets/stylesheets/pages/_sphinx.scss @@ -1,4 +1,4 @@ -._sphinx { +%sphinx { h2, h3 { @extend %block-heading; } dl:not(.docutils) > dt { @extend %block-label, %label-blue; } dt + dt { margin-top: -.5em; } @@ -24,3 +24,7 @@ ul.simple { margin: 1em 0; } } + +._sphinx { + @extend %sphinx +} diff --git a/lib/docs/filters/codeigniter/clean_html.rb b/lib/docs/filters/codeigniter/clean_html.rb new file mode 100644 index 00000000..6571f249 --- /dev/null +++ b/lib/docs/filters/codeigniter/clean_html.rb @@ -0,0 +1,24 @@ +module Docs + class Codeigniter + class CleanHtmlFilter < Filter + def call + css('.headerlink').remove + + css('h1', 'h2', 'h3', 'h4', 'h5', 'pre').each do |node| + node.content = node.content + end + + css('table').each do |node| + node.remove_attribute 'border' + end + + css('.section > h2', '.section > h3', '.section > h4', '.section > h5').each do |node| + node['id'] = node.parent['id'] + node.parent.remove_attribute 'id' + end + + doc.children + end + end + end +end diff --git a/lib/docs/filters/codeigniter/entries.rb b/lib/docs/filters/codeigniter/entries.rb new file mode 100644 index 00000000..06e7dfa0 --- /dev/null +++ b/lib/docs/filters/codeigniter/entries.rb @@ -0,0 +1,42 @@ +module Docs + class Codeigniter + class EntriesFilter < Docs::EntriesFilter + def include_default_entry? + not slug.ends_with? 'index' + end + + def get_name + at_css('h1').content.strip + end + + def get_type + slug.split('/')[0].capitalize + end + + def additional_entries + entries = [] + + css('.class').each do |c_node| + c_name = c_node.at_css('dt > .descname').content + c_id = c_node.at_css('dt')['id'] + entries << [c_name, c_id, get_type] + + c_node.css('.method').each do |node| + m_name = node.at_css('.descname').content + name = c_name + '::' + m_name + '()' + id = node.at_css('dt')['id'] + entries << [name, id, get_type] + end + end + + css('.function').each do |node| + name = node.at_css('.descname').content + '()' + id = node.at_css('dt')['id'] + entries << [name, id, get_type] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/codeigniter.rb b/lib/docs/scrapers/codeigniter.rb new file mode 100644 index 00000000..9b8670f4 --- /dev/null +++ b/lib/docs/scrapers/codeigniter.rb @@ -0,0 +1,35 @@ +module Docs + class Codeigniter < UrlScraper + self.name = 'CodeIgniter' + self.type = 'codeigniter' + self.release = '3.0' + self.base_url = 'http://www.codeigniter.com/user_guide/' + self.root_path = 'index.html' + self.links = { + home: 'http://codeigniter.com/', + code: 'https://github.com/bcit-ci/CodeIgniter' + } + + html_filters.push 'codeigniter/clean_html', 'codeigniter/entries' + + options[:container] = '.document' + + options[:only_patterns] = [ + /\Ageneral/, + /\Alibraries/, + /\Adatabase/, + /\Ahelpers/ + ] + + options[:skip] = %w( + general/welcome.html + general/requirements.html + general/credits.html + ) + + options[:attribution] = <<-HTML + © British Columbia Institute of Technology
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/codeigniter/16.png b/public/icons/docs/codeigniter/16.png new file mode 100644 index 0000000000000000000000000000000000000000..a49b9f021090638c155df64e57c3fb55784f9751 GIT binary patch literal 882 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eK!3-ot_ve`cDVB6cUq=Rpjs4tz5?O(Kg=CK) zUj~LMH3o);76yi2K%s^g3=E|P3=FRl7#OT(FffQ0%-I!a!@$635#STz3RG~{Lu3?@ z6axSM|DU72+8Y>lX(d5^!3+#Ov4t09)^mS#w&%+_Eu4WhMd=n_N!PCVtgyXvHxyWe71QC`8#+^=+bUeG9QhS{i zh2H!=$wMXe-+%uPwiUCwji2w878G5R$q>mFasAc5jT={*uVHvB=6l=wz@FrX>q;4K zyx}W4zw>?2k;d8WHlHf`{T1x&B`u!bv}{)7oZRD*{3`B<>cUr_v}SruzCP)puUUEb z?&?pDazCfk*D-RrPFr%uYik(0l<&4BcPo!3-H-krTP6RO@ydV8KT@2>?oXCa`1RZT zu*{=Q`Lvn+4%|SutCqM%l%yn9nO2EgL-EA*oj?r?p00i_>zopr0FMh%k^lez literal 0 HcmV?d00001 diff --git a/public/icons/docs/codeigniter/16@2.png b/public/icons/docs/codeigniter/16@2.png new file mode 100644 index 0000000000000000000000000000000000000000..a202fc8ca62dde54abdd8e98abb48b02438179e3 GIT binary patch literal 1679 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA$!3-oXI4PR|DVB6cUq=Rpjs4tz5?Mi#$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$Ysfq`jXfKP}kP{Cafkx?`n z0z)nY{{R0!M>g^`Fa^IT3GxeOU~rkqr}eas#s1rSSH_lq>pAovzSQAg^CyU-{m;Kh zj;8OwdB4kqZhvuITL563o_1Hy6TB)`oE7p zz8_EV#r<2t#WnxDQ2YN&8Y(B=TZo*x=d5#lE<0oO?*rBlFz(Kw%+;J~1kCg#SrreSLDT;|mx%If0g{AQAFad!X2nVN2-w6w(U z5fD78q^S1q(NS(rPajUrOvwd3Yh>D5_B1I4JZha}w5z3Sm6XS$)?I9~T9!>Si+I%9 zr?;wQ-abZ`N39D5nU$6A`1c%BTNcnMp4P+jOl(?!rJHuP^o%3i(bjI&?C$CvB8xY3 z$2@9XJ$rZi^6A_8J-RMl=T~|m&!EKI+|-!jp%I{_W5c8*EGgQ1L0b6q2?25bM0FK4 zRppeRpvw}Mj1}IT(K+^JPRx#wI6G&?p4f;Z5ivnrkEc#G4mogRYN&&K*!3$;J4<=K z7BEXmH3s>f)fI@-W^T#LW*3s3>)>Bf`rV;L!Dw&oUx%VYE)$Nc`_5w$n#DD7rdjQ= zGvb@m&NH^3yi=*L@Fx#AoFVzpvzP zc5CyU9lz(srm2jYQ4-s8fkMaq+G2MDg*J<;Dt&)jU-&>lnfdX;!}@(Pu3ocxj`!`i zC=^mTQ1R+Zw{iMIH^X_>^$#DZZn)UfGktx`-ZELKgFWVX_jc8?i{0%he}A|BgTR@( zFF#IRPCtK8h~c57vAjj(6$fA(tCqM%l%yn