Przeglądaj źródła

octave: finish scraper and filters

Jasper van Merle 6 lat temu
rodzic
commit
4da5ae7e73

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -516,6 +516,11 @@ credits = [
     '2008-2017 NumPy Developers',
     'NumPy',
     'https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt'
+  ], [
+    'Octave',
+    '1996-2018 John W. Eaton',
+    'Custom',
+    'https://octave.org/doc/interpreter/'
   ], [
     'OpenJDK',
     '1993-2017, Oracle and/or its affiliates. All rights reserved.<br>Licensed under the GNU General Public License, version 2, with the Classpath Exception.<br>Various third party code in OpenJDK is licensed under different licenses.<br>Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.',

Plik diff jest za duży
+ 1102 - 905
assets/javascripts/vendor/prism.js


+ 4 - 3
lib/docs/filters/octave/clean_html.rb

@@ -22,11 +22,11 @@ module Docs
         css('.example').each do |node|
           node.name = 'pre'
           node['data-language'] = 'matlab'
-          node.content = node.content
+          node.content = node.content.strip
         end
 
-        css('a[name] + dl').each do |node|
-          node['id'] = node.previous['name']
+        css('a[name] + dl, a[name] + h4').each do |node|
+          node['id'] = node.previous_element['name']
         end
 
         css('dt > a[name]', 'th > a[name]').each do |node|
@@ -39,6 +39,7 @@ module Docs
           node.parent.content = node.content
         end
 
+        xpath('//td[text()=" " and not(descendant::*)]').remove
       end
     end
   end

+ 5 - 3
lib/docs/filters/octave/entries.rb

@@ -2,17 +2,19 @@ module Docs
   class Octave
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        at_css('h1').content
+        at_css('h1').content.sub(/(A?[0-9.]+ )/, '')
       end
 
       def get_type
+        return 'Manual: Appendices' if name.start_with?('Appendix')
+        return 'Manual: Indexes' if name.end_with?('Index')
         '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']
+          name = node.content.gsub(/[A-z0-9\,… ]*\=/, '').strip.split(' ')[0]
+          entries << [name, node['id'], 'Functions'] unless node['id'] =~ /-\d+\Z/
         end
       end
     end

+ 1 - 1
lib/docs/scrapers/octave.rb

@@ -27,7 +27,7 @@ module Docs
       &copy; 1996&ndash;2018 John W. Eaton<br>
       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.<br/>
 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.</br>
-Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.</br>
+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)

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików