Explorar el Código

Add Gnu Make documentation

Enoc hace 4 años
padre
commit
848f7194a0

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2021-12-26",
+    "New documentation: <a href=\"/gnu_make/\">Gnu Make</a>"
+  ],
   [
     "2021-12-07",
     "New documentation: <a href=\"/prettier/\">Prettier</a>",

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

@@ -337,6 +337,11 @@ credits = [
     'GFDL',
     'https://www.gnu.org/licenses/fdl-1.3.en.html'
   ], [
+    'Gnu Make',
+    'Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc.',
+    'GFDL',
+    'https://www.gnu.org/software/make/manual/html_node/GNU-Free-Documentation-License.html'
+   ] ,[
     'Gnuplot',
     'Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley',
     'gnuplot license',

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -76,6 +76,7 @@
         'pages/liquid',
         'pages/love',
         'pages/lua',
+        'pages/gnu_make',
         'pages/mariadb',
         'pages/mdn',
         'pages/meteor',

+ 5 - 0
assets/stylesheets/pages/_gnu_make.scss

@@ -0,0 +1,5 @@
+._make {
+    dl dt {
+        @extend %block-label, %label-blue;
+    }
+}

+ 9 - 0
docs/file-scrapers.md

@@ -92,6 +92,15 @@ curl https://gcc.gnu.org/onlinedocs/gcc-$RELEASE/gfortran-html.tar.gz | \
 tar --extract --gzip --strip-components=1 --directory=docs/gnu_fortran~$VERSION
 ```
 
+## GNU Make
+Go to https://www.gnu.org/software/make/manual/, download the HTML tarball and extract its content in `/path/to/devdocs/docs/gnu_make` or run the following command:
+
+```sh
+mkdir /path/to/devdocs/docs/gnu_make \
+&& curl https://www.gnu.org/software/make/manual/make.html_node.tar.gz | \
+tar --extract --gzip --strip-components=1 --directory=/path/to/devdocs/docs/gnu_make
+```
+
 ## Gnuplot
 
 The most recent release can be found near the bottom of

+ 54 - 0
lib/docs/filters/gnu_make/clean_html.rb

@@ -0,0 +1,54 @@
+module Docs
+  class GnuMake
+    class CleanHtmlFilter < Filter
+      def call
+
+        if current_url == root_url
+          # Remove short table contents
+          css('.shortcontents').remove
+          css('.shortcontents-heading').remove
+          css('.contents-heading').remove
+          css('.contents').remove
+          css('.settitle').remove
+
+          # remove copyright
+          css('blockquote').remove
+        end
+
+        css('hr').remove
+
+        css('.header').remove
+
+        # Remove undesirable in headers
+        css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').each do |node|
+
+          node.content = node.content.slice(/[[:alpha:]]...*/)
+
+          node.content = node.content.sub(/Appendix.{2}/, '') if node.content.include?('Appendix')
+
+          if node.content.match?(/[[:upper:]]\./)
+            node.content = node.content.sub(/[[:upper:]]\./, '')
+            node.content = node.content.gsub(/\./, '')
+            node.content = node.content.gsub(/[[:digit:]]/, '')
+          end
+
+          node.name = "h1"
+        end
+
+        css('dt code').each do |node|
+          node.parent['id'] = node.content
+        end
+
+        css('dt > samp').each do |node|
+          node.parent['id'] = node.content
+        end
+
+        css('br').remove
+
+        css('.footnote').remove
+
+        doc
+      end
+    end
+  end
+end

+ 97 - 0
lib/docs/filters/gnu_make/entries.rb

@@ -0,0 +1,97 @@
+module Docs
+  class GnuMake
+    class EntriesFilter < Docs::EntriesFilter
+
+      NO_ADDITIONAL_ENTRIES = [
+        'Quick Reference', 'Instead of Executing Recipes',
+        'Loaded Object Interface', 'Conversion of Guile Types',
+        'Arguments to Specify the Goals', 'Standard Targets for Users',
+        'Variables for Installation Directories', 'Errors Generated by Make',
+        'The origin Function', 'The vpath Directive',
+        'Interfaces from Guile to make', 'Output During Parallel Execution',
+        'How to Run make', 'The flavor Function', 'Catalogue of Built-In Rules'
+      ]
+
+      DL_DT_TABLE = {
+        'Automatic Variables' => 'Automatic Variables',
+        'Other Special Variables' => 'Automatic Variables',
+        'Variables Used by Implicit Rules' => 'Automatic Variables',
+        'Special Built-in Target Names' => 'Built-in targets',
+        'Functions for File Names' => 'File Names Functions',
+        'Functions for String Substitution and Analysis' => 'String Substitution and Analysis Functions',
+        'Functions for Conditionals' => 'Conditionals Functions',
+        'Functions That Control Make' => 'Make Control Functions',
+        'Syntax of Conditionals' => 'Conditionals Syntax'
+      }
+
+      def get_name
+        name = at_css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix')
+
+        if name.nil?
+          name = at_css('h1, h2, h3').content.slice(/[[:alpha:]]...*/)
+        else
+          name = name.content.slice(/[[:alpha:]]...*/)
+        end
+
+        name.gsub!(/Appendix.{2}/, '') if name.include?('Appendix')
+        # remove withespace at the beginning left when "Appendix" is removed
+        name.gsub!(/\G\s/, '')
+
+        name
+      end
+
+      def get_type
+        return 'Transforming text functions' if name =~ /The [a-z]+ Function/
+        return 'Directives' if name =~ /The [a-z]+ Directive/
+        'Manual'
+      end
+
+      def additional_entries
+        entries = []
+
+        return entries if NO_ADDITIONAL_ENTRIES.include?(name)
+
+        css('dl dt').each do |node|
+
+          break if name == 'Summary of Options'
+
+          entry_type = ""
+
+          if DL_DT_TABLE.key?(name)
+            entry_type = DL_DT_TABLE[name]
+          else
+            entry_type = "Entry type missing"
+          end
+
+          entry_name = node.at_css('code')
+
+          if entry_name.nil?
+            next
+          end
+
+          entry_name = entry_name.content
+          entry_path = slug.downcase + '#' + entry_name
+
+          entries << [entry_name, entry_path, entry_type]
+        end
+
+        css('dt > samp').each do |node|
+
+          break if name == 'Other Special Variables'
+
+          entry_type = 'Automatic Variables' if name == 'Automatic Variables'
+          entry_type = 'Functions for File Names' if name == 'Functions for File Names'
+          entry_type = 'Make Cli Options' if name == 'Summary of Options'
+
+          entry_name = node.content
+          entry_path = slug.downcase + '#' + entry_name
+
+          entries << [entry_name, entry_path, entry_type]
+        end
+
+        entries
+      end
+
+    end
+  end
+end

+ 34 - 0
lib/docs/scrapers/gnu_make.rb

@@ -0,0 +1,34 @@
+# coding: utf-8
+module Docs
+  class GnuMake < FileScraper
+    self.name = 'Gnu make'
+    self.type = 'gnu_make'
+    self.slug = 'gnu_make'
+    self.release = '4.3'
+    self.base_url= 'https://www.gnu.org/software/make/manual/html_node/'
+    self.root_path = 'index.html'
+    self.links = {
+      home:'https://www.gnu.org/software/make/manual/html_node/',
+      code: 'http://git.savannah.gnu.org/cgit/make.git/'
+    }
+
+    html_filters.push 'gnu_make/entries', 'gnu_make/clean_html'
+
+    options[:skip] = [
+      'Concept-Index.html',
+      'Name-Index.html',
+      'GNU-Free-Documentation-License.html'
+    ]
+
+    options[:attribution]= <<-HTML
+      Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc. <br>
+      Licensed under the GNU Free Documentation License.
+    HTML
+
+    def get_latest_version(opts)
+      body = fetch(self.base_url, opts)
+      body.scan(/version \d*\.?\d*/)[0].sub('version', '')
+    end
+
+  end
+end

BIN
public/icons/docs/gnu_make/16.png


BIN
public/icons/docs/gnu_make/16@2x.png


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

@@ -0,0 +1 @@
+https://www.gnu.org/graphics/heckert_gnu.png