From ad9e7a62692e07b43853e8c1d90a54230c171ca1 Mon Sep 17 00:00:00 2001 From: Phil Scherer Date: Thu, 8 Aug 2019 21:44:41 -0500 Subject: [PATCH] Add Octave Documentation --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_octave.scss | 9 +++++ lib/docs/filters/octave/clean_html.rb | 45 ++++++++++++++++++++++++ lib/docs/filters/octave/entries.rb | 20 +++++++++++ lib/docs/scrapers/octave.rb | 38 ++++++++++++++++++++ public/icons/docs/octave/16.png | Bin 0 -> 1310 bytes public/icons/docs/octave/16@2x.png | Bin 0 -> 1940 bytes public/icons/docs/octave/SOURCE | 1 + 8 files changed, 114 insertions(+) create mode 100644 assets/stylesheets/pages/_octave.scss create mode 100644 lib/docs/filters/octave/clean_html.rb create mode 100644 lib/docs/filters/octave/entries.rb create mode 100644 lib/docs/scrapers/octave.rb create mode 100644 public/icons/docs/octave/16.png create mode 100644 public/icons/docs/octave/16@2x.png create mode 100644 public/icons/docs/octave/SOURCE diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 85d1134f..7a09dd97 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -75,6 +75,7 @@ 'pages/nginx', 'pages/node', 'pages/npm', + 'pages/octave', 'pages/openjdk', 'pages/perl', 'pages/phalcon', diff --git a/assets/stylesheets/pages/_octave.scss b/assets/stylesheets/pages/_octave.scss new file mode 100644 index 00000000..1dfc3f8c --- /dev/null +++ b/assets/stylesheets/pages/_octave.scss @@ -0,0 +1,9 @@ +._octave { + @extend %simple; + + dl:not([compact]) > dt { @extend %block-label, %label-blue; } + + dl[compact] > dt { @extend %block-label; } + + .footnotes-heading { @extend %block-heading; } +} diff --git a/lib/docs/filters/octave/clean_html.rb b/lib/docs/filters/octave/clean_html.rb new file mode 100644 index 00000000..cae7ec1c --- /dev/null +++ b/lib/docs/filters/octave/clean_html.rb @@ -0,0 +1,45 @@ +module Docs + class Octave + class CleanHtmlFilter < Filter + def call + root_page? ? root : other + doc + end + + def root + @doc = at_css('.contents') + end + + def other + css('.header', 'hr').remove + + css('.footnote > h3').each do |node| + node.name = 'h5' + end + + at_css('h2, h3, h4').name = 'h1' + + css('.example').each do |node| + node.name = 'pre' + node['data-language'] = 'matlab' + node.content = node.content + end + + css('a[name] + dl').each do |node| + node['id'] = node.previous['name'] + end + + css('dt > a[name]', 'th > a[name]').each do |node| + node.parent['id'] = node['name'] + node.parent.content = node.parent.content.strip + end + + css('h5 > a').each do |node| + node.parent['id'] = node['name'] + node.parent.content = node.content + end + + end + end + end +end diff --git a/lib/docs/filters/octave/entries.rb b/lib/docs/filters/octave/entries.rb new file mode 100644 index 00000000..70b29df1 --- /dev/null +++ b/lib/docs/filters/octave/entries.rb @@ -0,0 +1,20 @@ +module Docs + class Octave + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content + end + + def get_type + 'Manual' + end + + def additional_entries + css('dl:not([compact]) > dt').each_with_object [] do |node, entries| + name = node.content.gsub(/[A-z0-9\,… ]*\=/,'').strip + entries << [name, node['id'], 'Functions'] + end + end + end + end +end diff --git a/lib/docs/scrapers/octave.rb b/lib/docs/scrapers/octave.rb new file mode 100644 index 00000000..1b8e70c0 --- /dev/null +++ b/lib/docs/scrapers/octave.rb @@ -0,0 +1,38 @@ +module Docs + class Octave < UrlScraper + self.name = 'Octave' + self.type = 'octave' + self.release = '5.1.0' + self.base_url = 'https://octave.org/doc/interpreter/' + self.root_path = 'index.html' + self.links = { + home: 'http://www.octave.org/', + code: 'http://www.octave.org/hg/octave' + } + + html_filters.push 'octave/clean_html', 'octave/entries', 'title' + + options[:skip] = %w( + Copying.html + Preface.html + Acknowledgements.html + Citing-Octave-in-Publications.html + How-You-Can-Contribute-to-Octave.html + Distribution.html) + + options[:title] = false + options[:root_title] = 'GNU Octave' + + options[:attribution] = <<-HTML + © 1996–2018 John W. Eaton
+ Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
+Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
+Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
+ HTML + + def get_latest_version(opts) + doc = fetch_doc('https://octave.org/doc/interpreter/', opts) + doc.at_css('h1').content.scan(/([0-9.]+)/)[0][0] + end + end +end diff --git a/public/icons/docs/octave/16.png b/public/icons/docs/octave/16.png new file mode 100644 index 0000000000000000000000000000000000000000..bef5229f9dbf701d066cb7f642d7600307f8b190 GIT binary patch literal 1310 zcmb7CdsLEV7=MA#BD|yy)5@qVwF`!LTg;i39;AdJkVnc3re@BxQnJ*RWS4Wyl}=}A zsB^0vWjQ;wnKwj%@)8(c$WYO8c5J8V$}%yFJ)ZvBpZm`9J@4~=&*l65e(#&hVKXcU zjs%2|1v5C13#;|QyBG)Fm14z%Wl=%^D*&O}`Ag?x@USPx26I^mWjZ4yK8?^Ed=gI} zbcBk~UqXcFB?#FcDr*S!MF<Apf$yEZZFM?f=TnbcTA$x~IJ#NNbj=UXt}%fK%wZ1ual z0E5vm5Ynsf^BIq|017Tu>J3s2u=D@D9}vzS`}~b)wSG4qxVV)y zx?fTF{!~94wdC()dqbK_QEATe1e=FPeN>rS$C4Ze1z4b|WuW4`L(%Pq$d0G4Q&+t^ zy4Da)0M=kI4Fm!1V4q@uw@WcRb`E?04X@~L8zaIBT7U&lTM@wPUWo6zX{3& z%Z4#Uow!1!MX}QQq7oz>k6F^3;eYZ{E(ir?S*%!gNlChVA7IaT#&N5 zs00}u${sjXcGydwlzt}wU`SktyU=1@AYWS4W-qzFvZ9@QMa}!M{875ctHUcN679?i z5O9us464@w}gHCipOe_+zi65p+Mv9Qvxk zIR9qG^itbso6z=px_-xJR!Nq1=K(He?@mTw$G6Q15wI~AFmpHwC04GD}ywS z85qD{-Ww|v#`X02P(5kh?q0F`5SA2{mUrZ0n9lo;^cl+o{+M*euWvPOH7msx z3=za3KiP`;`3y0)33D=_^*C|O&npydM!XoCv+RdZ?KYzOZOOA|wx>^G*XA-i)?X(k zO6m@(bgbH>=@;16ykvP)o1R>|Ze&2zqMI*q*YhEAIyt!`vQZogAEb!aQ6 zTz5LR=t4*Z?TG%310!F(=tWqJ4}qPQ4QJUuow9u`ESx^JOSJt$O9K8;2Pqk2-PUUVuoi8O2epN8av naf$mf78;;}Mxpuesh)Hw_3-}GKyJEh2MvfB#15?4Cd~O4_VGD3 literal 0 HcmV?d00001 diff --git a/public/icons/docs/octave/16@2x.png b/public/icons/docs/octave/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3f6c9700b3254e8b5619ebc0a53db6ac5dfca41f GIT binary patch literal 1940 zcmV;F2W$9=P)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Re0|f&X7$L~owg3PIm`OxIR9M5kmwSv=)fL8n z-`eNCW}E@aOCF^>jG`b=v86nU6i8aIRBdTQ!T!-ltg&hOP&7?!|Ijv#Hrm#vS7A3NdFB+*-W`$>Tl9GlV+P~W)Q8I-SbY* z-pjJ3Qu&Edy-rVH?6R#SL8OtJO)N4~eK&Yj?gM7JH<*^-yc<38?Ceq93thi%4|N&C zovayGnc3H~mE!afdsaVs?aJF%Iv~-O$FU{Zm^I4CMe0$d|jg=#9fQrT9-lIp`=Sl3W5l8?= zKK>6Ji0;>UWSk4!z#||^zduMIkTm+3=uYZR8lBWVO{4#|R7u~d#52M^Mv4`e^e{0JLK+mu3Suz25Wk>AM>*n<}YGEm4=Yw~lY#@W;^c?w``gQ)ZNF=6S!^ zG^;w6D`argvju9vlIjuF{h4&1vw|9%`^XZz8zr*U`LVeHED zRKOt!V(N`9lB8HH-nMW5{;y?{WDwvTmdn4MAADIV%Lu3t*j)dy;_9KFc&k^bmEO}Q za_H8{=S(1tPNlPw4M9TfeWT3o zG<>^9Z#f?YQU^x^h+Kg@J-+sfULjXJfGd1b?n@Bih1s#PCEK0M5eeW?}?#F8Z1;_6L?lMWWhSa2zN%u?q;7mxo^m#Bd z+l00Tu(-R@*ZO)vmZxrbQ<1b?0D` z1P*>>;wcGi+Ki@7&MY1{aNrm6`8*DoM`BuG|AFR~lYR#x5Zznc{f_AVLh4S8-Azi) z-EVj2ag#nS_t59j4JRcaU_d`4vqC15AtVV&2w0NAvUwCj;iLr8Z%*s#5qa62ug2(G zYb0WXG-A=2>G1pL{;)}t2K;Jc{nNgi!N1-Jz_{gGSv>Ym9{cPMv!#&B)r`;`UGvjl zZ$DatNjQF`(8FfBCYWlapf)#CTaf-~rp>{$JDA#nDHBXXGQbB^PF0o{7=`?QL0dv%l0=hHAu6}^wD4%YEpd{aC05UK!IV~_VEig1xGBP?c zGCD9cEig4YFfeNt_y+(003~!qSaf7zbY(hiZ)9m^c>ppnF*GeOGA%MUR4_C;Ff}?e aHZ3qUIxsLGyqXjM0000a0 literal 0 HcmV?d00001 diff --git a/public/icons/docs/octave/SOURCE b/public/icons/docs/octave/SOURCE new file mode 100644 index 00000000..917586bc --- /dev/null +++ b/public/icons/docs/octave/SOURCE @@ -0,0 +1 @@ +https://www.gnu.org/software/octave/img/octave-logo.svg