Merge pull request #1717 from xjkdev/docs-eigen3

Added Eigen3 document
pull/1726/head
Simon Legner 3 years ago committed by GitHub
commit c338f2c824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -262,6 +262,11 @@ credits = [
'2001-2015 by the original authors<br>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.',

@ -52,6 +52,7 @@
'pages/dart',
'pages/dojo',
'pages/drupal',
'pages/eigen3',
'pages/elixir',
'pages/elisp',
'pages/ember',

@ -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

@ -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

@ -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 <a id="asd"></a> 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
&copy; Eigen.<br>
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 <div>s inside code fragment div.
while not (last_idx = response.body.index('<div class="fragment">', last_idx)).nil?
# enter code fragment <div>
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] == '<div'
level += 1
else
level -= 1
end
break if level == 0 # exit code fragment
end
if not last_idx.nil? and response.body[last_idx..last_idx+5] == '</div>'
response.body[last_idx..last_idx+5] = '</pre>'
end
end
response.body.gsub! /[\r\n\s]*<div class="ttc"[^>]*>.*<\/div>[\r\n\s]*/, ""
response.body.gsub! /<div class="line">(.*?)<\/div>/m, "\\1"
response.body.gsub! '<div class="fragment">', '<pre class="fragment" data-language="cpp">'
super
end
def process_response?(response)
return false unless super
# Remove Empty pages.
response.body.index(/<div class="contents">[\r\n\s]*<\/div>/m).nil? and \
response.body.index(/<p>TODO: write this dox page!<\/p>/).nil?
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

@ -0,0 +1 @@
https://gitlab.com/libeigen/eigen/-/blob/master/doc/Eigen_Silly_Professor_64x64.png
Loading…
Cancel
Save