diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index b066c0ab..46001979 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -262,6 +262,11 @@ credits = [ '2001-2015 by the original authors
Drupal is a registered trademark of Dries Buytaert.', 'GPLv2', 'https://api.drupal.org/api/drupal/LICENSE.txt' + ],[ + 'Eigen3', + 'Eigen', + 'MPL2', + 'https://www.mozilla.org/en-US/MPL/2.0/' ], [ 'Electron', 'GitHub Inc.', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 3a6d428e..1d5da325 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -52,6 +52,7 @@ 'pages/dart', 'pages/dojo', 'pages/drupal', + 'pages/eigen3', 'pages/elixir', 'pages/elisp', 'pages/ember', diff --git a/assets/stylesheets/pages/_eigen3.scss b/assets/stylesheets/pages/_eigen3.scss new file mode 100644 index 00000000..e69de29b diff --git a/lib/docs/filters/eigen3/clean_html.rb b/lib/docs/filters/eigen3/clean_html.rb new file mode 100644 index 00000000..3870566e --- /dev/null +++ b/lib/docs/filters/eigen3/clean_html.rb @@ -0,0 +1,25 @@ +module Docs + class Eigen3 + class CleanHtmlFilter < Filter + + def call + @doc = at_css('#doc-content') + css('#MSearchSelectWindow').remove + css('#MSearchResultsWindow').remove + css('.directory .levels').remove + css('.header .summary').remove + css('.ttc').remove + css('.top').remove + css('.dynheader.closed').remove + css('.permalink').remove + css('.groupheader').remove + css('.header').remove + css('#details').remove + css('*').each do |node| + node.remove_attribute('class') + end + doc + end + end + end +end diff --git a/lib/docs/filters/eigen3/entries.rb b/lib/docs/filters/eigen3/entries.rb new file mode 100644 index 00000000..b80b0e24 --- /dev/null +++ b/lib/docs/filters/eigen3/entries.rb @@ -0,0 +1,123 @@ +module Docs + class Eigen3 + class EntriesFilter < Docs::EntriesFilter + def get_type + group = at_css('.title .ingroups') + content = at_css('.contents').content + title = get_title() + downtitle = title.downcase + name = get_name + + if slug.include?('unsupported') + return 'Unsupported' + elsif slug.start_with?('Topic') || downtitle.end_with?("topics") + return 'Topics' + elsif downtitle.end_with?("class template reference") || downtitle.end_with?("class reference") + return 'Classes' + elsif downtitle.end_with?("struct reference") + return 'Structs' + elsif downtitle.end_with?("typedefs") + return 'Typedefs' + elsif downtitle.end_with?("namespace reference") + return 'Namespaces' + elsif not group.nil? and group.content.include?('Reference') and (downtitle.end_with?("module") || downtitle.end_with?("modules")) + return "Modules" + elsif not group.nil? + if group.children.length > 0 + return 'Chapter: ' + group.children[-1].content + else + return 'Chapter: ' + group.content + end + else + return 'Eigen' + end + end + + def get_name + title = get_title().gsub(/[<(].*/, '').gsub(/(Class|Class Template|Namespace|Struct) Reference/, '').strip + end + + def get_title + unless at_css('.title').nil? + group = at_css('.title .ingroups') + title = at_css('.title').content + if not group.nil? + title = title.delete_suffix(group.content) + end + return title.strip + else + return slug + end + end + + + def additional_entries + # return [] if slug.include?('unsupported') + name = get_name() + entries = [] + + css('table.memberdecls').map do |table| + doxygen_type = table.at_css("tr.heading").text.strip + case doxygen_type + when "Functions" + type = "Functions" + when "Public Member Functions", "Static Public Member Functions", "Public Types", "Additional Inherited Members" + type = nil + when "Classes" + type = "Classes" + when "Typedefs" + type = "Typedefs" + when "Variables" + type = "Variables" + else + next + end + + tmp_entries = [] + + table.css('td.memItemRight,td.memTemplItemRight').map do |node_r| + node_l = node_r.parent.at_css('memItemLeft') + if (not node_l.nil? and node_l.text.strip == 'enum') || node_r.content.include?('{') + node_r.css("a").each {|n| tmp_entries << [n.content, n.attr('href')]} + else + n = node_r.at_css("a") + next if n.nil? + tmp_entries << [node_r.content, n.attr('href')] + end + end + + tmp_entries.each do |args| + (content, href) = args + next if href.nil? + if not href.include?("#") and (name == 'Eigen' || type == "Classes") then + next + end + + if slug.include?('unsupported') + if not (href.include?('unsupported') || href.include?('#')) + next + elsif href.include?('#') and not href.include?('unsupported') + href = 'unsupported/' + href + end + end + + if doxygen_type == "Typedefs" + content = content.sub(/\s*=.*$/, "") + end + + if not (name.end_with?('module') || name.end_with?('typedefs')) \ + and not content.start_with?("Eigen::") + content = name + "::" + content + end + content.gsub! /^\s+/, '' + content.gsub! /\s+,\s+/, ', ' + content.gsub! /\s\s+/, ' ' + entries << [content, href, type] + end + + end + entries + end + end + end +end diff --git a/lib/docs/scrapers/eigen3.rb b/lib/docs/scrapers/eigen3.rb new file mode 100644 index 00000000..7ed3d1eb --- /dev/null +++ b/lib/docs/scrapers/eigen3.rb @@ -0,0 +1,76 @@ +module Docs + class Eigen3 < UrlScraper + self.name = 'Eigen3' + self.type = 'eigen3' + self.slug = 'eigen3' + self.base_url = 'https://eigen.tuxfamily.org/dox/' + self.root_path = 'index.html' + self.initial_paths = [ + "modules.html" + ] + self.release = '3.4.0' + + self.links = { + home: 'https://eigen.tuxfamily.org', + code: 'https://gitlab.com/libeigen/eigen' + } + + html_filters.push 'eigen3/entries', 'eigen3/clean_html', 'title' + + # Remove the `clean_text` because Doxygen are actually creating empty + # anchor such as to do anchor link.. and that anchor + # will be removed by clean_text + self.text_filters = FilterStack.new + text_filters.push 'images', 'inner_html', 'attribution' + + + + def get_latest_version(opts) + tags = get_gitlab_tags("https://gitlab.com", "libeigen", "eigen", opts) + tags[0]['name'] + end + + options[:attribution] = <<-HTML + © Eigen.
+ Licensed under the MPL2 License. + HTML + + # Skip source code since it doesn't provide any useful docs + options[:skip_patterns] = [/_source/, /-members/, /__Reference\.html/, /_chapter\.html/, /\.txt/, /\.tgz/] + + # TODO: replace cppreference + # options[:replace_urls] = { 'http://en.cppreference.com/w/cpp/' => 'cpp/' } + + def parse(response) # Hook here because Nokogori removes whitespace from code fragments + last_idx = 0 + # Process nested
s inside code fragment div. + while not (last_idx = response.body.index('
', last_idx)).nil? + # enter code fragment
+ level = 1 + while not (last_idx = response.body.index(/<\/?div/, last_idx+1)).nil? + # skip nested divs inside. + if response.body[last_idx..last_idx+3] == '' + response.body[last_idx..last_idx+5] = '' + end + end + response.body.gsub! /[\r\n\s]*
]*>.*<\/div>[\r\n\s]*/, "" + response.body.gsub! /
(.*?)<\/div>/m, "\\1" + response.body.gsub! '
', '
'
+      super
+    end
+
+    def process_response?(response)
+      return false unless super
+      # Remove Empty pages.
+      response.body.index(/
[\r\n\s]*<\/div>/m).nil? and \ + response.body.index(/

TODO: write this dox page!<\/p>/).nil? + end + end +end diff --git a/public/icons/docs/eigen3/16.png b/public/icons/docs/eigen3/16.png new file mode 100644 index 00000000..265a2f49 Binary files /dev/null and b/public/icons/docs/eigen3/16.png differ diff --git a/public/icons/docs/eigen3/16@2x.png b/public/icons/docs/eigen3/16@2x.png new file mode 100644 index 00000000..9cc98d2c Binary files /dev/null and b/public/icons/docs/eigen3/16@2x.png differ diff --git a/public/icons/docs/eigen3/SOURCE b/public/icons/docs/eigen3/SOURCE new file mode 100644 index 00000000..439adb72 --- /dev/null +++ b/public/icons/docs/eigen3/SOURCE @@ -0,0 +1 @@ +https://gitlab.com/libeigen/eigen/-/blob/master/doc/Eigen_Silly_Professor_64x64.png