Przeglądaj źródła

Add Fortran documentation

Phil Scherer 9 lat temu
rodzic
commit
56d9398148

+ 1 - 0
assets/stylesheets/pages/_base.scss

@@ -17,6 +17,7 @@
 }
 }
 
 
 ._cordova,
 ._cordova,
+._fortran,
 ._grunt,
 ._grunt,
 ._haxe,
 ._haxe,
 ._influxdata,
 ._influxdata,

+ 18 - 0
lib/docs/filters/fortran/clean_html.rb

@@ -0,0 +1,18 @@
+module Docs
+  class Fortran
+    class CleanHtmlFilter < Filter
+      def call
+        css('h2', 'h3', 'h4').each do |node|
+          node.name = 'h1'
+        end
+
+        # Move page anchor to page title
+        at_css('h1')['id'] = at_css('.node > a')['name']
+
+        css('.node', 'br').remove
+
+        doc
+      end
+    end
+  end
+end

+ 34 - 0
lib/docs/filters/fortran/entries.rb

@@ -0,0 +1,34 @@
+module Docs
+  class Fortran
+    class EntriesFilter < Docs::EntriesFilter
+      REPLACE_TYPES = {
+        1 => 'Introduction',
+        2 => 'GNU Fortran Command Options',
+        3 => 'Runtime Environment Variables',
+        4 => 'Fortran 2003 and 2008 Status',
+        5 => 'Compiler Characteristics',
+        6 => 'Extensions',
+        7 => 'Mixed Language Programming',
+        8 => 'Coarray Programming',
+        9 => 'Intrinsic Procedures',
+        10 => 'Intrinsic Modules' }
+
+      def chapter_number
+        at_css('h1').content.to_i
+      end
+
+      def include_default_entry?
+        REPLACE_TYPES[chapter_number] and not at_css('ul.menu')
+      end
+
+      def get_name
+        at_css('h1').content.split(' ').drop(1).join(' ').split('—').first
+      end
+
+      def get_type
+        REPLACE_TYPES[chapter_number]
+      end
+
+    end
+  end
+end

+ 32 - 0
lib/docs/scrapers/fortran.rb

@@ -0,0 +1,32 @@
+module Docs
+  class Fortran < FileScraper
+    self.name = 'GNU Fortran'
+    self.slug = 'fortran'
+    self.type = 'fortran'
+    self.release = '5.3.0'
+    self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
+    self.dir = ''
+    self.root_path = 'index.html'
+
+    self.links = {
+      home: 'https://gcc.gnu.org/fortran/'
+    }
+
+    html_filters.push 'fortran/clean_html', 'fortran/entries'
+
+    options[:skip_patterns] = [
+      /Funding/,
+      /Projects/,
+      /Copying/,
+      /License/,
+      /Proposed/,
+      /Contribut/,
+      /Index/
+    ]
+
+    options[:attribution] = <<-HTML
+      &copy; Free Software Foundation<br>
+      Licensed under the GNU Free Documentation License version 1.3.
+    HTML
+  end
+end

+ 1 - 0
public/icons/docs/fortran/SOURCE

@@ -0,0 +1 @@
+https://commons.wikimedia.org/wiki/File:Fortran.png

BIN
public/icons/docs/fortran/fortran.png