History

Merge pull request #1126 from Cimbali/master

Add documentation for gnuplot

Jed Fox committed 6 years ago

Commit 7287d0b2 parents e647b3a f5a31529 files · +186 −-2Browse files

Unified · Split

9 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. assets/stylesheets/application.css.scss +1 −0
  3. assets/stylesheets/pages/_gnuplot.scss +6 −0
  4. lib/docs/filters/gnuplot/clean_html.rb +61 −0
  5. lib/docs/filters/gnuplot/entries.rb +73 −0
  6. lib/docs/scrapers/gnuplot.rb +41 −0
  7. public/icons/docs/gnuplot/16.png +0 −0
  8. public/icons/docs/gnuplot/16@2x.png +0 −0
  9. public/icons/docs/gnuplot/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -311,6 +311,11 @@ credits = [ · 310 unmodified lines
311 'Free Software Foundation',311 'Free Software Foundation',
312 'GFDL',312 'GFDL',
313 'https://www.gnu.org/licenses/fdl-1.3.en.html'313 'https://www.gnu.org/licenses/fdl-1.3.en.html'
314 ], [
315 'Gnuplot',
316 'Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley',
317 'gnuplot license',
318 'https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright'
314 ], [319 ], [
315 'Go',320 'Go',
316 'Google, Inc.',321 'Google, Inc.',
assets/stylesheets/application.css.scss+1−0
@@ -60,6 +60,7 @@ · 59 unmodified lines
60 'pages/github',60 'pages/github',
61 'pages/go',61 'pages/go',
62 'pages/graphite',62 'pages/graphite',
63 'pages/gnuplot',
63 'pages/haskell',64 'pages/haskell',
64 'pages/jekyll',65 'pages/jekyll',
65 'pages/jquery',66 'pages/jquery',
assets/stylesheets/pages/_gnuplot.scss+6−0
@@ -0,0 +1,6 @@
1._gnuplot {
2 .CENTER {
3 text-align: center;
4 }
5 @extend %simple;
6}
lib/docs/filters/gnuplot/clean_html.rb+61−0
@@ -0,0 +1,61 @@
1module Docs
2 class Gnuplot
3 class CleanHtmlFilter < Filter
4 def call
5 # remove some anchors nested inside headers: <hX><a name="">...</a></hX>
6 css('h1, h2, h3, h4, h5').each do |heading|
7 anchor = heading.css('a')[0]
8 heading['id'] = anchor['id'] || anchor['name']
9 heading.content = anchor.content.strip
10 end
11
12 # make the title on the front page which is in some weird tags
13 if root_page?
14 title = css('.HUGE')[0]
15 title.name = 'h1'
16
17 subtitle = css('.XLARGE')[0]
18 title.content = title.content + ' − ' + subtitle.content
19
20 css('> *:first-child')[0].before(title)
21 subtitle.remove
22
23 css('p:contains("TableOfContents")').remove
24 end
25
26 # remove nav, empty items, and any useless horizontal rules as well
27 # as the subsection table of contents (.ChildLinks)
28 css('.navigation').remove
29 css('#CHILD_LINKS, ul.ChildLinks').remove
30 css('hr').remove
31 # Anchors that use only names are some numerical IDs that latex2html distributes through the document
32 css('a[name]:not([href]):not([id])').remove
33
34 # spacing
35 css('> div, p').each do |node|
36 node.remove if node.content.strip.empty?
37 end
38
39 # links generated are of the form (NB: some might have been removed):
40 # <B>{text} (p.&nbsp;<A HREF="{target}"><IMG ALT="[*]" SRC="crossref.png"></A>)<A NAME="{anchor}"></A></B>
41 # transform to <b><a href="{target}>{text}</a></b>
42 css('b:contains(" (p. ")').each do |node|
43 text = node.content.gsub /\(p\. (\[\*\])?\)/, ''
44
45 link = node.css('a[href]')[0]
46 if link
47 link.content = text.strip
48
49 node.children.each do |child|
50 child.remove if child != link
51 end
52 else
53 node.content = text.strip
54 end
55 end
56
57 doc
58 end
59 end
60 end
61end
lib/docs/filters/gnuplot/entries.rb+73−0
@@ -0,0 +1,73 @@
1module Docs
2 class Gnuplot
3 PROMOTE = {'Expressions' => nil, 'Linetypes, colors, and styles' => nil, 'Fit' => nil, 'Format' => nil,
4 'Plot' => nil, 'Splot' => nil, 'Style' => 'Plot appearance',
5 'Set-show' => 'Set / Show', 'Datafile' => nil, 'Key' => 'Legend'}
6 NOREPEAT = ['String constants, string variables, and string functions', 'Substitution and Command line macros']
7
8 class EntriesFilter < Docs::EntriesFilter
9 def initialize(*)
10 super
11 end
12
13 def get_name
14 return 'Stats' if slug.downcase == 'stats_statistical_summary'
15 return css('h1')[0].content.strip
16 end
17
18 def get_type
19 return (PROMOTE[name] || name) if PROMOTE.include? name
20
21 parent = at_css('.navigation > b:contains("Up:")').next_element.content
22 return 'Using Gnuplot' if parent == 'Gnuplot'
23 return parent
24 end
25
26 def include_default_entry?
27 !root_page? and slug.downcase != 'complete_list_terminals' #and !PROMOTE.include? name
28 end
29
30 def additional_entries
31 return [] if root_page?
32 entries = []
33
34 if slug.downcase == 'complete_list_terminals'
35 list_stack = [[css('ul.ChildLinks'), '', nil]]
36 else
37 list_stack = [[css('ul.ChildLinks'), name, nil]]
38 end
39
40 while !list_stack.empty?
41 list, name_, type_ = list_stack.pop
42 list.css('> li').each do |item|
43
44 sublists = item.css('> ul')
45 link = item.css('> a, span')
46
47 if link.empty?
48 item_name = name_
49 else
50 item_name = link[0].text.strip
51 item_name = "#{name_} #{item_name}".strip unless PROMOTE.include? name_ or NOREPEAT.include? name_
52 item_name = item_name.sub /^(\w+) \1/, '\1'
53 item_name = 'set style boxplot' if slug.downcase == 'set_show' and item_name == 'Boxplot'
54
55 if PROMOTE.include? name_
56 type_ = PROMOTE[name_] || name_
57 end
58
59 entries << [item_name, link[0]['href'].split('#')[1], type_]
60 end
61
62 list_stack.push([sublists, item_name, type_]) unless sublists.empty?
63 end
64 end
65
66 return entries
67 end
68
69 private
70
71 end
72 end
73end
lib/docs/scrapers/gnuplot.rb+41−0
@@ -0,0 +1,41 @@
1module Docs
2 class Gnuplot < FileScraper
3 self.name = 'Gnuplot'
4 self.slug = 'gnuplot'
5 self.type = 'gnuplot'
6 self.links = {
7 home: 'http://gnuplot.sourceforge.net/'
8 }
9
10 self.root_path = 'index.html'
11
12 html_filters.push 'gnuplot/entries', 'gnuplot/clean_html'
13
14 options[:skip_links] = false
15
16 options[:skip] = %w(
17 Copyright.html
18 External_libraries.html
19 Known_limitations.html
20 Introduction.html
21 About_this_document.html
22 New_features.html
23 Differences_from_version_4.html
24 Seeking_assistance.html
25 Gnuplot.html
26 Deprecated_syntax.html
27 Demos_Online_Examples.html
28 Terminal_types.html
29 Plotting_styles.html
30 Commands.html
31 Contents.html
32 Bugs.html
33 )
34
35 options[:attribution] = <<-HTML
36 Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley<br>
37 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).
38 HTML
39
40 end
41end
public/icons/docs/gnuplot/16.png+0−0

Binary file not shown.

public/icons/docs/gnuplot/16@2x.png+0−0

Binary file not shown.

public/icons/docs/gnuplot/SOURCE+1−0
@@ -0,0 +1 @@
1https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/demo/html/favicon.ico