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 00000000..bef5229f Binary files /dev/null and b/public/icons/docs/octave/16.png differ diff --git a/public/icons/docs/octave/16@2x.png b/public/icons/docs/octave/16@2x.png new file mode 100644 index 00000000..3f6c9700 Binary files /dev/null and b/public/icons/docs/octave/16@2x.png differ 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