[devdocsgjs/main: 971/1867] Add gnuplot documentation as source




commit f5a3152bbba69c7be1a6f84af11645c1bb022669
Author: Cimbali <me cimba li>
Date:   Thu May 23 23:48:41 2019 +0200

    Add gnuplot documentation as source
    
    Documentation is part of the gnuplot source code, available at:
    - https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/docs/
    
    This can be redistributed, according the the Copyright (emphasis mine):
    
    > * Copyright 1986 - 1993, 1998, 2004   Thomas Williams, Colin Kelley
    > *
    > * Permission to use, copy, and distribute this software **and its**
    > * **documentation** for any purpose with or without fee is hereby granted,
    > * provided that the above copyright notice appear in all copies and
    > * that both that copyright notice and this permission notice appear
    > * in supporting documentation.
    
    Full copyright notice here:
    https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright
    
    The term “gnuplot license” is not very widespread but brings satisfying
    results on search engines (including on wikipedia), so I took the
    liberty to add a link to the copyright file, taken from the “Gnuplot's
    copyright” link on the gnuplot home page, http://gnuplot.info.
    
    Here is how to build the gnuplot docs to parse them:
    
        mkdir gnuplot-src gnuplot-conf $DEVDOCS_ROOT/docs/gnuplot
        git clone -b 5.2.7 --depth 1 https://git.code.sf.net/p/gnuplot/gnuplot-main ./gnuplot-src
        cd gnuplot-src/
        ./prepare
        cd ../gnuplot-conf
        ../gnuplot-src/configure
        make -C docs nofigures.tex
        latex2html -html 5.0,math -split 4 -link 8 -long_titles 5 -dir $DEVDOCS_ROOT/docs/gnuplot -ascii_mode 
docs/nofigures.tex

 .../javascripts/templates/pages/about_tmpl.coffee  |   5 ++
 assets/stylesheets/application.css.scss            |   1 +
 assets/stylesheets/pages/_gnuplot.scss             |   6 ++
 lib/docs/filters/gnuplot/clean_html.rb             |  61 +++++++++++++++++
 lib/docs/filters/gnuplot/entries.rb                |  73 +++++++++++++++++++++
 lib/docs/scrapers/gnuplot.rb                       |  41 ++++++++++++
 public/icons/docs/gnuplot/16.png                   | Bin 0 -> 2954 bytes
 public/icons/docs/gnuplot/16 2x png                | Bin 0 -> 2163 bytes
 public/icons/docs/gnuplot/SOURCE                   |   1 +
 9 files changed, 188 insertions(+)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 0165ade2..60c74210 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -311,6 +311,11 @@ credits = [
     'Free Software Foundation',
     'GFDL',
     'https://www.gnu.org/licenses/fdl-1.3.en.html'
+  ], [
+    'Gnuplot',
+    'Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley',
+    'gnuplot license',
+    'https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright'
   ], [
     'Go',
     'Google, Inc.',
diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss
index 0072d511..1b1c3ad0 100644
--- a/assets/stylesheets/application.css.scss
+++ b/assets/stylesheets/application.css.scss
@@ -60,6 +60,7 @@
         'pages/github',
         'pages/go',
         'pages/graphite',
+        'pages/gnuplot',
         'pages/haskell',
         'pages/jekyll',
         'pages/jquery',
diff --git a/assets/stylesheets/pages/_gnuplot.scss b/assets/stylesheets/pages/_gnuplot.scss
new file mode 100644
index 00000000..b7d584e7
--- /dev/null
+++ b/assets/stylesheets/pages/_gnuplot.scss
@@ -0,0 +1,6 @@
+._gnuplot {
+  .CENTER {
+    text-align: center;
+  }
+  @extend %simple;
+}
diff --git a/lib/docs/filters/gnuplot/clean_html.rb b/lib/docs/filters/gnuplot/clean_html.rb
new file mode 100644
index 00000000..e612982b
--- /dev/null
+++ b/lib/docs/filters/gnuplot/clean_html.rb
@@ -0,0 +1,61 @@
+module Docs
+  class Gnuplot
+    class CleanHtmlFilter < Filter
+      def call
+        # remove some anchors nested inside headers: <hX><a name="">...</a></hX>
+        css('h1, h2, h3, h4, h5').each do |heading|
+          anchor = heading.css('a')[0]
+          heading['id'] = anchor['id'] || anchor['name']
+          heading.content = anchor.content.strip
+        end
+
+        # make the title on the front page which is in some weird tags
+        if root_page?
+          title = css('.HUGE')[0]
+          title.name = 'h1'
+
+          subtitle = css('.XLARGE')[0]
+          title.content = title.content + ' − ' + subtitle.content
+
+          css('> *:first-child')[0].before(title)
+          subtitle.remove
+
+          css('p:contains("TableOfContents")').remove
+        end
+
+        # remove nav, empty items, and any useless horizontal rules as well
+        # as the subsection table of contents (.ChildLinks)
+        css('.navigation').remove
+        css('#CHILD_LINKS, ul.ChildLinks').remove
+        css('hr').remove
+        # Anchors that use only names are some numerical IDs that latex2html distributes through the document
+        css('a[name]:not([href]):not([id])').remove
+
+        # spacing
+        css('> div, p').each do |node|
+          node.remove if node.content.strip.empty?
+        end
+
+        # links generated are of the form (NB: some might have been removed):
+        # <B>{text} (p.&nbsp;<A HREF="{target}"><IMG  ALT="[*]" SRC="crossref.png"></A>)<A 
NAME="{anchor}"></A></B>
+        # transform to <b><a href="{target}>{text}</a></b>
+        css('b:contains(" (p. ")').each do |node|
+          text = node.content.gsub /\(p\. (\[\*\])?\)/, ''
+
+          link = node.css('a[href]')[0]
+          if link
+            link.content = text.strip
+
+            node.children.each do |child|
+              child.remove if child != link
+            end
+          else
+            node.content = text.strip
+          end
+        end
+
+        doc
+      end
+    end
+  end
+end
diff --git a/lib/docs/filters/gnuplot/entries.rb b/lib/docs/filters/gnuplot/entries.rb
new file mode 100644
index 00000000..ccb7b5fa
--- /dev/null
+++ b/lib/docs/filters/gnuplot/entries.rb
@@ -0,0 +1,73 @@
+module Docs
+  class Gnuplot
+    PROMOTE = {'Expressions' => nil, 'Linetypes, colors, and styles' => nil, 'Fit' => nil, 'Format' => nil,
+               'Plot' => nil, 'Splot' => nil, 'Style' => 'Plot appearance',
+               'Set-show' => 'Set / Show', 'Datafile' => nil, 'Key' => 'Legend'}
+    NOREPEAT = ['String constants, string variables, and string functions', 'Substitution and Command line 
macros']
+
+    class EntriesFilter < Docs::EntriesFilter
+      def initialize(*)
+        super
+      end
+
+      def get_name
+        return 'Stats' if slug.downcase == 'stats_statistical_summary'
+        return css('h1')[0].content.strip
+      end
+
+      def get_type
+        return (PROMOTE[name] || name) if PROMOTE.include? name
+
+        parent = at_css('.navigation > b:contains("Up:")').next_element.content
+        return 'Using Gnuplot' if parent == 'Gnuplot'
+        return parent
+      end
+
+      def include_default_entry?
+        !root_page? and slug.downcase != 'complete_list_terminals' #and !PROMOTE.include? name
+      end
+
+      def additional_entries
+        return [] if root_page?
+        entries = []
+
+        if slug.downcase == 'complete_list_terminals'
+          list_stack = [[css('ul.ChildLinks'), '', nil]]
+        else
+          list_stack = [[css('ul.ChildLinks'), name, nil]]
+        end
+
+        while !list_stack.empty?
+          list, name_, type_ = list_stack.pop
+          list.css('> li').each do |item|
+
+            sublists = item.css('> ul')
+            link = item.css('> a, span')
+
+            if link.empty?
+              item_name = name_
+            else
+              item_name = link[0].text.strip
+              item_name = "#{name_} #{item_name}".strip unless PROMOTE.include? name_ or NOREPEAT.include? 
name_
+              item_name = item_name.sub /^(\w+) \1/, '\1'
+              item_name = 'set style boxplot' if slug.downcase == 'set_show' and item_name == 'Boxplot'
+
+              if PROMOTE.include? name_
+                type_ = PROMOTE[name_] || name_
+              end
+
+              entries << [item_name, link[0]['href'].split('#')[1], type_]
+            end
+
+            list_stack.push([sublists, item_name, type_]) unless sublists.empty?
+          end
+        end
+
+        return entries
+      end
+
+      private
+
+    end
+  end
+end
diff --git a/lib/docs/scrapers/gnuplot.rb b/lib/docs/scrapers/gnuplot.rb
new file mode 100644
index 00000000..dc55edb7
--- /dev/null
+++ b/lib/docs/scrapers/gnuplot.rb
@@ -0,0 +1,41 @@
+module Docs
+  class Gnuplot < FileScraper
+    self.name = 'Gnuplot'
+    self.slug = 'gnuplot'
+    self.type = 'gnuplot'
+    self.links = {
+      home: 'http://gnuplot.sourceforge.net/'
+    }
+
+    self.root_path = 'index.html'
+
+    html_filters.push 'gnuplot/entries', 'gnuplot/clean_html'
+
+    options[:skip_links] = false
+
+    options[:skip] = %w(
+      Copyright.html
+      External_libraries.html
+      Known_limitations.html
+      Introduction.html
+      About_this_document.html
+      New_features.html
+      Differences_from_version_4.html
+      Seeking_assistance.html
+      Gnuplot.html
+      Deprecated_syntax.html
+      Demos_Online_Examples.html
+      Terminal_types.html
+      Plotting_styles.html
+      Commands.html
+      Contents.html
+      Bugs.html
+    )
+
+    options[:attribution] = <<-HTML
+      Copyright 1986 - 1993, 1998, 2004   Thomas Williams, Colin Kelley<br>
+      Distributed under the <a 
href="https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright";>gnuplot license</a> (rights to 
distribute modified versions are withheld).
+    HTML
+
+  end
+end
diff --git a/public/icons/docs/gnuplot/16.png b/public/icons/docs/gnuplot/16.png
new file mode 100644
index 00000000..3db00280
Binary files /dev/null and b/public/icons/docs/gnuplot/16.png differ
diff --git a/public/icons/docs/gnuplot/16 2x png b/public/icons/docs/gnuplot/16 2x png
new file mode 100644
index 00000000..5985b7aa
Binary files /dev/null and b/public/icons/docs/gnuplot/16 2x png differ
diff --git a/public/icons/docs/gnuplot/SOURCE b/public/icons/docs/gnuplot/SOURCE
new file mode 100644
index 00000000..8acb1e8c
--- /dev/null
+++ b/public/icons/docs/gnuplot/SOURCE
@@ -0,0 +1 @@
+https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/demo/html/favicon.ico


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]