History

Merge pull request #1717 from xjkdev/docs-eigen3

Added Eigen3 document

Simon Legner committed 4 years ago

Commit c338f2c2 parents 44d42bb c94aa259 files · +229 −-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/_eigen3.scss +0 −0
  4. lib/docs/filters/eigen3/clean_html.rb +25 −0
  5. lib/docs/filters/eigen3/entries.rb +123 −0
  6. lib/docs/scrapers/eigen3.rb +76 −0
  7. public/icons/docs/eigen3/16.png +0 −0
  8. public/icons/docs/eigen3/16@2x.png +0 −0
  9. public/icons/docs/eigen3/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -262,6 +262,11 @@ credits = [ · 261 unmodified lines
262262 '2001-2015 by the original authors<br>Drupal is a registered trademark of Dries Buytaert.',
263263 'GPLv2',
264264 'https://api.drupal.org/api/drupal/LICENSE.txt'
265+ ],[
266+ 'Eigen3',
267+ 'Eigen',
268+ 'MPL2',
269+ 'https://www.mozilla.org/en-US/MPL/2.0/'
265270 ], [
266271 'Electron',
267272 'GitHub Inc.',
assets/stylesheets/application.css.scss+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 'pages/dart',
5353 'pages/dojo',
5454 'pages/drupal',
55+ 'pages/eigen3',
5556 'pages/elixir',
5657 'pages/elisp',
5758 'pages/ember',
assets/stylesheets/pages/_eigen3.scss+0−0

Empty file added.

lib/docs/filters/eigen3/clean_html.rb+25−0
@@ -0,0 +1,25 @@
1+module Docs
2+ class Eigen3
3+ class CleanHtmlFilter < Filter
4+
5+ def call
6+ @doc = at_css('#doc-content')
7+ css('#MSearchSelectWindow').remove
8+ css('#MSearchResultsWindow').remove
9+ css('.directory .levels').remove
10+ css('.header .summary').remove
11+ css('.ttc').remove
12+ css('.top').remove
13+ css('.dynheader.closed').remove
14+ css('.permalink').remove
15+ css('.groupheader').remove
16+ css('.header').remove
17+ css('#details').remove
18+ css('*').each do |node|
19+ node.remove_attribute('class')
20+ end
21+ doc
22+ end
23+ end
24+ end
25+end
lib/docs/filters/eigen3/entries.rb+123−0
@@ -0,0 +1,123 @@
1+module Docs
2+ class Eigen3
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_type
5+ group = at_css('.title .ingroups')
6+ content = at_css('.contents').content
7+ title = get_title()
8+ downtitle = title.downcase
9+ name = get_name
10+
11+ if slug.include?('unsupported')
12+ return 'Unsupported'
13+ elsif slug.start_with?('Topic') || downtitle.end_with?("topics")
14+ return 'Topics'
15+ elsif downtitle.end_with?("class template reference") || downtitle.end_with?("class reference")
16+ return 'Classes'
17+ elsif downtitle.end_with?("struct reference")
18+ return 'Structs'
19+ elsif downtitle.end_with?("typedefs")
20+ return 'Typedefs'
21+ elsif downtitle.end_with?("namespace reference")
22+ return 'Namespaces'
23+ elsif not group.nil? and group.content.include?('Reference') and (downtitle.end_with?("module") || downtitle.end_with?("modules"))
24+ return "Modules"
25+ elsif not group.nil?
26+ if group.children.length > 0
27+ return 'Chapter: ' + group.children[-1].content
28+ else
29+ return 'Chapter: ' + group.content
30+ end
31+ else
32+ return 'Eigen'
33+ end
34+ end
35+
36+ def get_name
37+ title = get_title().gsub(/[<(].*/, '').gsub(/(Class|Class Template|Namespace|Struct) Reference/, '').strip
38+ end
39+
40+ def get_title
41+ unless at_css('.title').nil?
42+ group = at_css('.title .ingroups')
43+ title = at_css('.title').content
44+ if not group.nil?
45+ title = title.delete_suffix(group.content)
46+ end
47+ return title.strip
48+ else
49+ return slug
50+ end
51+ end
52+
53+
54+ def additional_entries
55+ # return [] if slug.include?('unsupported')
56+ name = get_name()
57+ entries = []
58+
59+ css('table.memberdecls').map do |table|
60+ doxygen_type = table.at_css("tr.heading").text.strip
61+ case doxygen_type
62+ when "Functions"
63+ type = "Functions"
64+ when "Public Member Functions", "Static Public Member Functions", "Public Types", "Additional Inherited Members"
65+ type = nil
66+ when "Classes"
67+ type = "Classes"
68+ when "Typedefs"
69+ type = "Typedefs"
70+ when "Variables"
71+ type = "Variables"
72+ else
73+ next
74+ end
75+
76+ tmp_entries = []
77+
78+ table.css('td.memItemRight,td.memTemplItemRight').map do |node_r|
79+ node_l = node_r.parent.at_css('memItemLeft')
80+ if (not node_l.nil? and node_l.text.strip == 'enum') || node_r.content.include?('{')
81+ node_r.css("a").each {|n| tmp_entries << [n.content, n.attr('href')]}
82+ else
83+ n = node_r.at_css("a")
84+ next if n.nil?
85+ tmp_entries << [node_r.content, n.attr('href')]
86+ end
87+ end
88+
89+ tmp_entries.each do |args|
90+ (content, href) = args
91+ next if href.nil?
92+ if not href.include?("#") and (name == 'Eigen' || type == "Classes") then
93+ next
94+ end
95+
96+ if slug.include?('unsupported')
97+ if not (href.include?('unsupported') || href.include?('#'))
98+ next
99+ elsif href.include?('#') and not href.include?('unsupported')
100+ href = 'unsupported/' + href
101+ end
102+ end
103+
104+ if doxygen_type == "Typedefs"
105+ content = content.sub(/\s*=.*$/, "")
106+ end
107+
108+ if not (name.end_with?('module') || name.end_with?('typedefs')) \
109+ and not content.start_with?("Eigen::")
110+ content = name + "::" + content
111+ end
112+ content.gsub! /^\s+/, ''
113+ content.gsub! /\s+,\s+/, ', '
114+ content.gsub! /\s\s+/, ' '
115+ entries << [content, href, type]
116+ end
117+
118+ end
119+ entries
120+ end
121+ end
122+ end
123+end
lib/docs/scrapers/eigen3.rb+76−0
@@ -0,0 +1,76 @@
1+module Docs
2+ class Eigen3 < UrlScraper
3+ self.name = 'Eigen3'
4+ self.type = 'eigen3'
5+ self.slug = 'eigen3'
6+ self.base_url = 'https://eigen.tuxfamily.org/dox/'
7+ self.root_path = 'index.html'
8+ self.initial_paths = [
9+ "modules.html"
10+ ]
11+ self.release = '3.4.0'
12+
13+ self.links = {
14+ home: 'https://eigen.tuxfamily.org',
15+ code: 'https://gitlab.com/libeigen/eigen'
16+ }
17+
18+ html_filters.push 'eigen3/entries', 'eigen3/clean_html', 'title'
19+
20+ # Remove the `clean_text` because Doxygen are actually creating empty
21+ # anchor such as <a id="asd"></a> to do anchor link.. and that anchor
22+ # will be removed by clean_text
23+ self.text_filters = FilterStack.new
24+ text_filters.push 'images', 'inner_html', 'attribution'
25+
26+
27+
28+ def get_latest_version(opts)
29+ tags = get_gitlab_tags("https://gitlab.com", "libeigen", "eigen", opts)
30+ tags[0]['name']
31+ end
32+
33+ options[:attribution] = <<-HTML
34+ &copy; Eigen.<br>
35+ Licensed under the MPL2 License.
36+ HTML
37+
38+ # Skip source code since it doesn't provide any useful docs
39+ options[:skip_patterns] = [/_source/, /-members/, /__Reference\.html/, /_chapter\.html/, /\.txt/, /\.tgz/]
40+
41+ # TODO: replace cppreference
42+ # options[:replace_urls] = { 'http://en.cppreference.com/w/cpp/' => 'cpp/' }
43+
44+ def parse(response) # Hook here because Nokogori removes whitespace from code fragments
45+ last_idx = 0
46+ # Process nested <div>s inside code fragment div.
47+ while not (last_idx = response.body.index('<div class="fragment">', last_idx)).nil?
48+ # enter code fragment <div>
49+ level = 1
50+ while not (last_idx = response.body.index(/<\/?div/, last_idx+1)).nil?
51+ # skip nested divs inside.
52+ if response.body[last_idx..last_idx+3] == '<div'
53+ level += 1
54+ else
55+ level -= 1
56+ end
57+ break if level == 0 # exit code fragment
58+ end
59+ if not last_idx.nil? and response.body[last_idx..last_idx+5] == '</div>'
60+ response.body[last_idx..last_idx+5] = '</pre>'
61+ end
62+ end
63+ response.body.gsub! /[\r\n\s]*<div class="ttc"[^>]*>.*<\/div>[\r\n\s]*/, ""
64+ response.body.gsub! /<div class="line">(.*?)<\/div>/m, "\\1"
65+ response.body.gsub! '<div class="fragment">', '<pre class="fragment" data-language="cpp">'
66+ super
67+ end
68+
69+ def process_response?(response)
70+ return false unless super
71+ # Remove Empty pages.
72+ response.body.index(/<div class="contents">[\r\n\s]*<\/div>/m).nil? and \
73+ response.body.index(/<p>TODO: write this dox page!<\/p>/).nil?
74+ end
75+ end
76+end
public/icons/docs/eigen3/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/eigen3/SOURCE+1−0
@@ -0,0 +1 @@
1+https://gitlab.com/libeigen/eigen/-/blob/master/doc/Eigen_Silly_Professor_64x64.png