History

Merge pull request #2587 from spamguy/qt-entries

Fix Qt entry typing

Simon Legner committed 1 year ago

Commit 045c7192 parents 43731ef 8f033c33 files · +20 −34Browse files

Unified · Split

3 files
  1. lib/docs/filters/qt/clean_html.rb +5 −8
  2. lib/docs/filters/qt/entries.rb +5 −23
  3. lib/docs/scrapers/qt.rb +10 −3
lib/docs/filters/qt/clean_html.rb+5−8
@@ -2,22 +2,19 @@ module Docs · 1 unmodified line
2 class Qt2 class Qt
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 # Remove unneeded elements5 # Narrow down container further. Breadcrumb is safe to remove.
6 css('.copy-notice, .navigationbar, .headerNavi, .footerNavi, .sidebar, .toc, #ec_toggle', '.landingicons img', 'br').remove6 @doc = at_css('article .mainContent .context') unless root_page?
7
8 css('h1').remove_attribute('class')
7 9
8 # QML property/method header10 # QML property/method header
9 css('.qmlproto').each do |node|11 css('.qmlproto').each do |node|
10 id = node.at_css('tr')['id']12 id = node.at_css('span.name').content
11 id = node.at_css('a')['name'] if id.blank?
12 node.inner_html = node.at_css('td').inner_html13 node.inner_html = node.at_css('td').inner_html
13 node.name = 'h3'14 node.name = 'h3'
14 node['id'] = id15 node['id'] = id
15 end16 end
16 17
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
21 css('pre').each do |node|18 css('pre').each do |node|
22 node.content = node.content19 node.content = node.content
23 node['data-language'] = 'cpp' if node['class'].include?('cpp')20 node['data-language'] = 'cpp' if node['class'].include?('cpp')
lib/docs/filters/qt/entries.rb+5−23
@@ -19,25 +19,8 @@ module Docs · 18 unmodified lines
19 end19 end
20 20
21 def get_type21 def get_type
22 breadcrumb = css('#main_title_bar + ul li')22 breadcrumb = css('ul.c-breadcrump li') # Yes, really: breadcrump.
23 category = if breadcrumb.length < 323 breadcrumb[1].content
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
41 end24 end
42 25
43 def include_default_entry?26 def include_default_entry?
@@ -107,11 +90,9 @@ module Docs · 63 unmodified lines
107 end90 end
108 91
109 # QML properties/functions92 # QML properties/functions
110 qmlTypeName = at_css('h1.title').content.remove(' QML Type', '')
111 css('.qmlproto').each do |node|93 css('.qmlproto').each do |node|
112 title = node.content.strip94 title = node.content.strip
113 id = node.at_css('tr')['id']95 id = node.at_css('span.name').content
114 id = node.at_css('a')['name'] if id.blank?
115 96
116 # Remove options97 # Remove options
117 title.remove!(%r{^\[.*\] })98 title.remove!(%r{^\[.*\] })
@@ -128,7 +109,8 @@ module Docs · 10 unmodified lines
128 # Remove return type109 # Remove return type
129 title.remove!(%r{.* })110 title.remove!(%r{.* })
130 111
131 title = "#{qmlTypeName}.#{title.strip}"112 title = title.strip
113
132 unless titles.include?(title) # Remove duplicates (function overloading)114 unless titles.include?(title) # Remove duplicates (function overloading)
133 entries << [title, id]115 entries << [title, id]
134 titles.push(title)116 titles.push(title)
lib/docs/scrapers/qt.rb+10−3
@@ -11,8 +11,8 @@ module Docs · 10 unmodified lines
11 11
12 html_filters.push 'qt/entries', 'qt/clean_html'12 html_filters.push 'qt/entries', 'qt/clean_html'
13 13
14 options[:container] = 'article, .main'14 options[:container] = '.b-sidebar__content'
15 options[:max_image_size] = 156_00015 options[:max_image_size] = 256_000
16 options[:skip_patterns] = [16 options[:skip_patterns] = [
17 # License, copyright attributions17 # License, copyright attributions
18 /3rdparty/,18 /3rdparty/,
@@ -56,6 +56,8 @@ module Docs · 37 unmodified lines
56 "compatmap.html",56 "compatmap.html",
57 57
58 # Indexes58 # Indexes
59 "qdoc-index.html",
60 "qmake-manual.html",
59 "classes.html",61 "classes.html",
60 "qtmodules.html",62 "qtmodules.html",
61 "modules-qml.html",63 "modules-qml.html",
@@ -103,7 +105,12 @@ module Docs · 41 unmodified lines
103 Licensed under the GNU Free Documentation License, Version 1.3.105 Licensed under the GNU Free Documentation License, Version 1.3.
104 HTML106 HTML
105 107
106 version do108 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
107 self.release = '6.8'114 self.release = '6.8'
108 self.base_url = "https://doc.qt.io/qt-#{self.release}/"115 self.base_url = "https://doc.qt.io/qt-#{self.release}/"
109 end116 end