Finish Qt scraper

pull/847/merge
Thibaut Courouble 7 years ago
parent 67b5e3cb47
commit e35298c745

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

@ -1,7 +1,7 @@
[ [
[ [
"2018-08-06", "2018-08-12",
"New documentation: <a href=\"/dart/\">Dart</a>" "New documentations: <a href=\"/dart/\">Dart</a> and <a href=\"/qt/\">Qt</a>"
], [ ], [
"2018-07-29", "2018-07-29",
"New documentations: <a href=\"/bash/\">Bash</a>, <a href=\"/graphite/\">Graphite</a> and <a href=\"/pygame/\">Pygame</a>" "New documentations: <a href=\"/bash/\">Bash</a>, <a href=\"/graphite/\">Graphite</a> and <a href=\"/pygame/\">Pygame</a>"

@ -177,3 +177,4 @@
._icon-pygame:before { background-position: -5rem -3rem; @extend %doc-icon-2; } ._icon-pygame:before { background-position: -5rem -3rem; @extend %doc-icon-2; }
._icon-bash:before { background-position: -6rem -3rem; @extend %doc-icon-2; } ._icon-bash:before { background-position: -6rem -3rem; @extend %doc-icon-2; }
._icon-dart:before { background-position: -7rem -3rem; @extend %doc-icon-2; } ._icon-dart:before { background-position: -7rem -3rem; @extend %doc-icon-2; }
._icon-qt:before { background-position: -8rem -3rem; @extend %doc-icon-2; }

@ -1,63 +1,9 @@
._qt { ._qt {
@extend %simple; @extend %simple;
h1 {
margin-top: 0;
@extend %lined-heading;
}
// Home page
.landingicons {
.icons1of3 {
display: flex;
flex-wrap: wrap;
align-items: center;
margin: 1em 0;
@if $style == 'dark' {
&:nth-child(3) img {
filter: invert(1) hue-rotate(180deg) brightness(1.5)
}
}
}
h2 {
flex: 1;
margin: 0;
margin-left: 10px;
}
h2 + p {
width: 100%;
padding-left: 70px;
}
.centerAlign,
.centerAlign img { // Icon
width: 60px;
height: 60px;
margin: 0;
}
}
// Syntax highlighting
.pre {
.operator { @extend .token, .operator; }
.number { @extend .token, .number; }
.keyword { @extend .token, .keyword; }
.type { @extend .token, .function; }
.type a { color: inherit; }
.pun, .comment { @extend .token, .punctuation; }
.kwd, .preprocessor { @extend .token, .keyword; }
.str, .string { @extend .token, .string; }
}
// Function headers // Function headers
h3.fn code { h3.fn > code {
@extend %label;
float: right; float: right;
font-size: .8em; color: $textColorLight;
padding: 0;
margin-right: -.5em;
} }
} }

@ -3,17 +3,27 @@ module Docs
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
# Remove unneeded elements # Remove unneeded elements
css('.copy-notice, .navigationbar, .headerNavi, .footerNavi, .sidebar, .toc, #ec_toggle').remove css('.copy-notice, .navigationbar, .headerNavi, .footerNavi, .sidebar, .toc, #ec_toggle', '.landingicons img', 'br').remove
# QML property/method header # QML property/method header
css('.qmlproto').each do |node| css('.qmlproto').each do |node|
id = node.at_css('tr')['id'] id = node.at_css('tr')['id']
node.inner_html = node.at_css('td').inner_html node.inner_html = node.at_css('td').inner_html
node.name = 'h3' node.name = 'h3'
node.add_class '_qml_header'
node['id'] = id node['id'] = id
end end
css('.main-rounded', '.content', '.line', '.context', '.descr', '.types', '.func', '.table', 'div:not([class])', '.landing', '.col-1', '.heading', '.qmlitem', '.qmldoc', 'div.pre').each do |node|
node.before(node.children).remove
end
css('pre').each do |node|
node.content = node.content
node['data-language'] = 'cpp' if node['class'].include?('cpp')
node['data-language'] = 'qml' if node['class'].include?('qml')
node.remove_attribute('class')
end
doc doc
end end
end end

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Docs module Docs
class Qt class Qt
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
@ -9,7 +11,7 @@ module Docs
name.sub! %r{ QML Basic Type$}, ' (QML basic type)' name.sub! %r{ QML Basic Type$}, ' (QML basic type)'
# Add '(class)' to the class pages where the subtitle name is used (e.g. qset-const-iterator.html) # Add '(class)' to the class pages where the subtitle name is used (e.g. qset-const-iterator.html)
if at_css('h1.title').content.strip.end_with?(' Class') and !name.include?('(class)') if at_css('h1.title').content.strip.end_with?(' Class') && !name.include?('(class)')
name = "#{name} (class) " name = "#{name} (class) "
end end
@ -19,34 +21,34 @@ module Docs
def get_type def get_type
breadcrumb = css('#main_title_bar + ul li') breadcrumb = css('#main_title_bar + ul li')
category = if breadcrumb.length < 3 category = if breadcrumb.length < 3
then 'Qt' then 'Qt'.dup
else breadcrumb.at(1).content else breadcrumb.at(1).content
end end
if category == 'Qt' if category == 'Qt'
return 'Qt Platforms' if name.include? ' for ' or name == 'Qt Platform Abstraction' return 'Qt Platforms' if name.include?(' for ') || name == 'Qt Platform Abstraction'
return 'Qt Quick' if name == 'Qt Quick Test' or name == 'Qt Quick Test Reference Documentation' return 'Qt Quick' if name == 'Qt Quick Test' || name == 'Qt Quick Test Reference Documentation'
alwaysInQt = ["Qt Configure Options", "Qt Image Formats"] alwaysInQt = ['Qt Configure Options', 'Qt Image Formats']
category = name if name.start_with?('Qt ') && !alwaysInQt.include?(name) category = name if name.start_with?('Qt ') && !alwaysInQt.include?(name)
end end
qtPlatformsTypes = ['Qt Platform Headers', 'Qt Android Extras', 'Qt Mac Extras', 'Qt Windows Extras', 'Qt X11 Extras'] qtPlatformsTypes = ['Qt Platform Headers', 'Qt Android Extras', 'Qt Mac Extras', 'Qt Windows Extras', 'Qt X11 Extras']
return 'Qt Platforms' if qtPlatformsTypes.include? category return 'Qt Platforms' if qtPlatformsTypes.include?(category)
category.sub! ' Manual', '' category.remove!(' Manual')
category category
end end
def include_default_entry? def include_default_entry?
name != 'All Classes' and name != 'All QML Types' name != 'All Classes' && name != 'All QML Types'
end end
def additional_entries def additional_entries
entries = [] entries = []
titles = [] titles = []
className = at_css('h1.title').content.strip.sub ' Class', '' className = at_css('h1.title').content.strip.remove(' Class')
displayedClassName = className displayedClassName = className
alternativeClassName = at_css('h1.title + .small-subtitle a') alternativeClassName = at_css('h1.title + .small-subtitle a')
displayedClassName = alternativeClassName.content if alternativeClassName displayedClassName = alternativeClassName.content if alternativeClassName
@ -56,7 +58,7 @@ module Docs
header = node.clone header = node.clone
# Skip typenames # Skip typenames
next if header.content.strip.start_with? 'typename ' next if header.content.strip.start_with?('typename ')
# Remove leading <a name=""> # Remove leading <a name="">
header.children.css('a[name]').remove header.children.css('a[name]').remove
@ -66,7 +68,7 @@ module Docs
code.remove if code.name == 'code' code.remove if code.name == 'code'
# Remove leading const # Remove leading const
header.children.first.remove if header.content.strip.start_with? 'const ' header.children.first.remove if header.content.strip.start_with?('const ')
# Remove return type # Remove return type
returnType = header.children.first returnType = header.children.first
@ -78,57 +80,57 @@ module Docs
title[0] = '' if title[0] == '&' || title[0] == '*' title[0] = '' if title[0] == '&' || title[0] == '*'
# Ignore operator overloads # Ignore operator overloads
next if title.start_with? 'operator' next if title.start_with?('operator')
# Remove function parameters # Remove function parameters
title.sub! %r{\(.*\)}, '()' title.sub! %r{\(.*\)}, '()'
# Remove template generics # Remove template generics
title.sub! %r{^<.*> }, '' title.remove!(%r{^<.*> })
# Remove const at the end # Remove const at the end
title.sub! %r{ const$}, '' title.remove!(%r{ const$})
# Enum/typedef formatting # Enum/typedef formatting
title.sub! %r{(enum|typedef) (.*)}, '\2 (\1)' title.sub! %r{(enum|typedef) (.*)}, '\2 (\1)'
# Remove property type # Remove property type
title = "#{displayedClassName}::#{title}" if title.sub! %r{ : .*$}, '' title = "#{displayedClassName}::#{title}" if title.sub!(%r{ : .*$}, '')
# Replace the class name by the alternative class name if available # Replace the class name by the alternative class name if available
title.sub! className, displayedClassName if alternativeClassName title = title.sub(className, displayedClassName) if alternativeClassName
unless titles.include? title # Remove duplicates (function overloading) unless titles.include?(title) # Remove duplicates (function overloading)
entries << [title, header['id']] entries << [title, header['id']]
titles.push title titles.push title
end end
end end
# QML properties/functions # QML properties/functions
qmlTypeName = at_css('h1.title').content.sub ' QML Type', '' qmlTypeName = at_css('h1.title').content.remove(' QML Type', '')
css('.qmlproto').each do |node| css('.qmlproto').each do |node|
title = node.content.strip title = node.content.strip
id = node.at_css('tr')['id'] id = node.at_css('tr')['id']
# Remove options # Remove options
title.sub! %r{^\[.*\] }, '' title.remove!(%r{^\[.*\] })
# Remove function parameters # Remove function parameters
title.sub! %r{\(.*\)}, '()' title.sub! %r{\(.*\)}, '()'
# Remove property type # Remove property type
title.sub! %r{ : .*$}, '' title.remove!(%r{ : .*$})
# Remove return type # Remove return type
title.sub! %r{.* }, '' title.remove!(%r{.* })
# Remove return type # Remove return type
title.sub! %r{.* }, '' title.remove!(%r{.* })
title = "#{qmlTypeName}.#{title.strip}" title = "#{qmlTypeName}.#{title.strip}"
unless titles.include? title # Remove duplicates (function overloading) unless titles.include?(title) # Remove duplicates (function overloading)
entries << [title, id] entries << [title, id]
titles.push title titles.push(title)
end end
end end

@ -12,7 +12,7 @@ module Docs
html_filters.push 'qt/entries', 'qt/clean_html' html_filters.push 'qt/entries', 'qt/clean_html'
options[:container] = '.main' options[:container] = '.main'
options[:max_image_size] = 156_000
options[:skip_patterns] = [ options[:skip_patterns] = [
# License, copyright attributions # License, copyright attributions
/3rdparty/, /3rdparty/,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 681 B

Loading…
Cancel
Save