Skip to content

Commit 045c719

Browse files
authored
Merge pull request #2587 from spamguy/qt-entries
Fix Qt entry typing
2 parents 43731ef + 8f033c3 commit 045c719

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

lib/docs/filters/qt/clean_html.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ module Docs
22
class Qt
33
class CleanHtmlFilter < Filter
44
def call
5-
# Remove unneeded elements
6-
css('.copy-notice, .navigationbar, .headerNavi, .footerNavi, .sidebar, .toc, #ec_toggle', '.landingicons img', 'br').remove
5+
# Narrow down container further. Breadcrumb is safe to remove.
6+
@doc = at_css('article .mainContent .context') unless root_page?
7+
8+
css('h1').remove_attribute('class')
79

810
# QML property/method header
911
css('.qmlproto').each do |node|
10-
id = node.at_css('tr')['id']
11-
id = node.at_css('a')['name'] if id.blank?
12+
id = node.at_css('span.name').content
1213
node.inner_html = node.at_css('td').inner_html
1314
node.name = 'h3'
1415
node['id'] = id
1516
end
1617

17-
css('.main-rounded', '.content', '.line', '.context', '.descr', '.types', '.func', '.table', 'div:not([class])', '.landing', '.col-1', '.heading', '.qmlitem', '.qmldoc', 'div.pre').each do |node|
18-
node.before(node.children).remove
19-
end
20-
2118
css('pre').each do |node|
2219
node.content = node.content
2320
node['data-language'] = 'cpp' if node['class'].include?('cpp')

lib/docs/filters/qt/entries.rb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,8 @@ def get_name
1919
end
2020

2121
def get_type
22-
breadcrumb = css('#main_title_bar + ul li')
23-
category = if breadcrumb.length < 3
24-
then 'Qt'.dup
25-
else breadcrumb.at(1).content
26-
end
27-
28-
if category == 'Qt'
29-
return 'Qt Platforms' if name.include?(' for ') || name == 'Qt Platform Abstraction'
30-
return 'Qt Quick' if name == 'Qt Quick Test' || name == 'Qt Quick Test Reference Documentation'
31-
32-
alwaysInQt = ['Qt Configure Options', 'Qt Image Formats']
33-
category = name if name.start_with?('Qt ') && !alwaysInQt.include?(name)
34-
end
35-
36-
qtPlatformsTypes = ['Qt Platform Headers', 'Qt Android Extras', 'Qt Mac Extras', 'Qt Windows Extras', 'Qt X11 Extras']
37-
return 'Qt Platforms' if qtPlatformsTypes.include?(category)
38-
39-
category.remove!(' Manual')
40-
category
22+
breadcrumb = css('ul.c-breadcrump li') # Yes, really: breadcrump.
23+
breadcrumb[1].content
4124
end
4225

4326
def include_default_entry?
@@ -107,11 +90,9 @@ def additional_entries
10790
end
10891

10992
# QML properties/functions
110-
qmlTypeName = at_css('h1.title').content.remove(' QML Type', '')
11193
css('.qmlproto').each do |node|
11294
title = node.content.strip
113-
id = node.at_css('tr')['id']
114-
id = node.at_css('a')['name'] if id.blank?
95+
id = node.at_css('span.name').content
11596

11697
# Remove options
11798
title.remove!(%r{^\[.*\] })
@@ -128,7 +109,8 @@ def additional_entries
128109
# Remove return type
129110
title.remove!(%r{.* })
130111

131-
title = "#{qmlTypeName}.#{title.strip}"
112+
title = title.strip
113+
132114
unless titles.include?(title) # Remove duplicates (function overloading)
133115
entries << [title, id]
134116
titles.push(title)

lib/docs/scrapers/qt.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Qt < UrlScraper
1111

1212
html_filters.push 'qt/entries', 'qt/clean_html'
1313

14-
options[:container] = 'article, .main'
15-
options[:max_image_size] = 156_000
14+
options[:container] = '.b-sidebar__content'
15+
options[:max_image_size] = 256_000
1616
options[:skip_patterns] = [
1717
# License, copyright attributions
1818
/3rdparty/,
@@ -56,6 +56,8 @@ class Qt < UrlScraper
5656
"compatmap.html",
5757

5858
# Indexes
59+
"qdoc-index.html",
60+
"qmake-manual.html",
5961
"classes.html",
6062
"qtmodules.html",
6163
"modules-qml.html",
@@ -103,7 +105,12 @@ class Qt < UrlScraper
103105
Licensed under the GNU Free Documentation License, Version 1.3.
104106
HTML
105107

106-
version do
108+
version '6.9' do
109+
self.release = '6.9'
110+
self.base_url = "https://doc.qt.io/qt-#{self.release}/"
111+
end
112+
113+
version '6.8' do
107114
self.release = '6.8'
108115
self.base_url = "https://doc.qt.io/qt-#{self.release}/"
109116
end

0 commit comments

Comments
 (0)