1+ # frozen_string_literal: true
2+
13module Docs
24 class Qt
35 class EntriesFilter < Docs ::EntriesFilter
@@ -9,7 +11,7 @@ def get_name
911 name . sub! %r{ QML Basic Type$} , ' (QML basic type)'
1012
1113 # Add '(class)' to the class pages where the subtitle name is used (e.g. qset-const-iterator.html)
12- if at_css ( 'h1.title' ) . content . strip . end_with? ( ' Class' ) and !name . include? ( '(class)' )
14+ if at_css ( 'h1.title' ) . content . strip . end_with? ( ' Class' ) && !name . include? ( '(class)' )
1315 name = "#{ name } (class) "
1416 end
1517
@@ -19,34 +21,34 @@ def get_name
1921 def get_type
2022 breadcrumb = css ( '#main_title_bar + ul li' )
2123 category = if breadcrumb . length < 3
22- then 'Qt'
24+ then 'Qt' . dup
2325 else breadcrumb . at ( 1 ) . content
2426 end
2527
2628 if category == 'Qt'
27- return 'Qt Platforms' if name . include? ' for ' or name == 'Qt Platform Abstraction'
28- return 'Qt Quick' if name == 'Qt Quick Test' or name == 'Qt Quick Test Reference Documentation'
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'
2931
30- alwaysInQt = [ " Qt Configure Options" , " Qt Image Formats" ]
32+ alwaysInQt = [ ' Qt Configure Options' , ' Qt Image Formats' ]
3133 category = name if name . start_with? ( 'Qt ' ) && !alwaysInQt . include? ( name )
3234 end
3335
3436 qtPlatformsTypes = [ 'Qt Platform Headers' , 'Qt Android Extras' , 'Qt Mac Extras' , 'Qt Windows Extras' , 'Qt X11 Extras' ]
35- return 'Qt Platforms' if qtPlatformsTypes . include? category
37+ return 'Qt Platforms' if qtPlatformsTypes . include? ( category )
3638
37- category . sub! ' Manual' , ''
39+ category . remove! ( ' Manual' )
3840 category
3941 end
4042
4143 def include_default_entry?
42- name != 'All Classes' and name != 'All QML Types'
44+ name != 'All Classes' && name != 'All QML Types'
4345 end
4446
4547 def additional_entries
4648 entries = [ ]
4749 titles = [ ]
4850
49- className = at_css ( 'h1.title' ) . content . strip . sub ' Class' , ''
51+ className = at_css ( 'h1.title' ) . content . strip . remove ( ' Class' )
5052 displayedClassName = className
5153 alternativeClassName = at_css ( 'h1.title + .small-subtitle a' )
5254 displayedClassName = alternativeClassName . content if alternativeClassName
@@ -56,7 +58,7 @@ def additional_entries
5658 header = node . clone
5759
5860 # Skip typenames
59- next if header . content . strip . start_with? 'typename '
61+ next if header . content . strip . start_with? ( 'typename ' )
6062
6163 # Remove leading <a name="">
6264 header . children . css ( 'a[name]' ) . remove
@@ -66,7 +68,7 @@ def additional_entries
6668 code . remove if code . name == 'code'
6769
6870 # Remove leading ‘const’
69- header . children . first . remove if header . content . strip . start_with? 'const '
71+ header . children . first . remove if header . content . strip . start_with? ( 'const ' )
7072
7173 # Remove return type
7274 returnType = header . children . first
@@ -78,57 +80,57 @@ def additional_entries
7880 title [ 0 ] = '' if title [ 0 ] == '&' || title [ 0 ] == '*'
7981
8082 # Ignore operator overloads
81- next if title . start_with? 'operator'
83+ next if title . start_with? ( 'operator' )
8284
8385 # Remove function parameters
8486 title . sub! %r{\( .*\) } , '()'
8587
8688 # Remove template generics
87- title . sub! %r{^<.*> } , ''
89+ title . remove! ( %r{^<.*> } )
8890
8991 # Remove ‘const’ at the end
90- title . sub! %r{ const$} , ''
92+ title . remove! ( %r{ const$} )
9193
9294 # Enum/typedef formatting
9395 title . sub! %r{(enum|typedef) (.*)} , '\2 (\1)'
9496
9597 # Remove property type
96- title = "#{ displayedClassName } ::#{ title } " if title . sub! %r{ : .*$} , ''
98+ title = "#{ displayedClassName } ::#{ title } " if title . sub! ( %r{ : .*$} , '' )
9799
98100 # Replace the class name by the alternative class name if available
99- title . sub! className , displayedClassName if alternativeClassName
101+ title = title . sub ( className , displayedClassName ) if alternativeClassName
100102
101- unless titles . include? title # Remove duplicates (function overloading)
103+ unless titles . include? ( title ) # Remove duplicates (function overloading)
102104 entries << [ title , header [ 'id' ] ]
103105 titles . push title
104106 end
105107 end
106108
107109 # QML properties/functions
108- qmlTypeName = at_css ( 'h1.title' ) . content . sub ' QML Type' , ''
110+ qmlTypeName = at_css ( 'h1.title' ) . content . remove ( ' QML Type' , '' )
109111 css ( '.qmlproto' ) . each do |node |
110112 title = node . content . strip
111113 id = node . at_css ( 'tr' ) [ 'id' ]
112114
113115 # Remove options
114- title . sub! %r{^\[ .*\] } , ''
116+ title . remove! ( %r{^\[ .*\] } )
115117
116118 # Remove function parameters
117119 title . sub! %r{\( .*\) } , '()'
118120
119121 # Remove property type
120- title . sub! %r{ : .*$} , ''
122+ title . remove! ( %r{ : .*$} )
121123
122124 # Remove return type
123- title . sub! %r{.* } , ''
125+ title . remove! ( %r{.* } )
124126
125127 # Remove return type
126- title . sub! %r{.* } , ''
128+ title . remove! ( %r{.* } )
127129
128130 title = "#{ qmlTypeName } .#{ title . strip } "
129- unless titles . include? title # Remove duplicates (function overloading)
131+ unless titles . include? ( title ) # Remove duplicates (function overloading)
130132 entries << [ title , id ]
131- titles . push title
133+ titles . push ( title )
132134 end
133135 end
134136
0 commit comments