@@ -4,6 +4,7 @@ class EntriesFilter < Docs::EntriesFilter
44 REPLACE_NAMES = {
55 'Sorting Rows' => 'ORDER BY' ,
66 'Select Lists' => 'SELECT Lists' ,
7+ 'Comparison Functions and Operators' => 'Comparisons' ,
78 'Data Type Formatting Functions' => 'Formatting Functions' ,
89 'Enum Support Functions' => 'Enum Functions' ,
910 'Row and Array Comparisons' => 'Array Comparisons' ,
@@ -43,8 +44,14 @@ def base_name
4344 @base_name ||= clean_heading_name ( at_css ( 'h1' ) . content )
4445 end
4546
47+ def heading_level
48+ @heading_level ||= at_css ( 'h1' ) . content . scan ( /\d +(?=\. )/ ) . last
49+ end
50+
4651 def get_name
47- if %w( Overview Introduction ) . include? ( base_name )
52+ if type . start_with? ( 'Tutorial' )
53+ "#{ heading_level } . #{ base_name } "
54+ elsif %w( Overview Introduction ) . include? ( base_name )
4855 result [ :pg_chapter_name ]
4956 elsif PREPEND_TYPES . include? ( type ) || type . start_with? ( 'Internals' )
5057 "#{ type . remove ( 'Internals: ' ) } : #{ base_name } "
@@ -58,17 +65,23 @@ def get_type
5865
5966 if result [ :pg_up_path ] == 'sql-commands.html'
6067 'Commands'
68+ elsif result [ :pg_up_path ] == 'appendixes.html'
69+ 'Appendixes'
6170 elsif result [ :pg_up_path ] . start_with? ( 'reference-' )
6271 'Applications'
6372 elsif type = result [ :pg_chapter_name ]
64- if type . start_with? ( 'Func' ) && ( match = base_name . match ( /\A (?!Form|Seq|Set|Enum)(.+) Func/ ) )
73+ if type . start_with? ( 'Func' ) && ( match = base_name . match ( /\A (?!Form|Seq|Set|Enum|Comp )(.+) Func/ ) )
6574 "Functions: #{ match [ 1 ] } "
6675 else
6776 type . remove! %r{\A SQL }
6877 type = REPLACE_TYPES [ type ] || type
69- type = "Internals: #{ type } " if INTERNAL_TYPES . include? ( type )
78+ type . prepend 'Internals: ' if INTERNAL_TYPES . include? ( type )
79+ type . prepend 'Tutorial: ' if slug . start_with? ( 'tutorial' )
7080 type
7181 end
82+ elsif type = result [ :pg_appendix_name ]
83+ type . prepend 'Appendix: '
84+ type
7285 end
7386 end
7487
@@ -97,9 +110,15 @@ def additional_entries
97110 entries . concat get_custom_entries ( '> div[id^="FUNC"] td:first-child > code' )
98111 else
99112 if type && type . start_with? ( 'Functions' )
100- entries . concat get_custom_entries ( '> .TABLE td:first-child > code:first-child' )
101- entries . concat get_custom_entries ( '> .TABLE td:first-child > p > code:first-child' )
102- entries . concat %w( IS NULL BETWEEN DISTINCT\ FROM ) . map { |name | [ "#{ self . name } : #{ name } " ] } if slug == 'functions-comparison'
113+ entries . concat get_custom_entries ( '> .TABLE td:first-child > code.LITERAL:first-child' )
114+ entries . concat get_custom_entries ( '> .TABLE td:first-child > code.FUNCTION:first-child' )
115+ entries . concat get_custom_entries ( '> .TABLE td:first-child > code:not(.LITERAL):first-child + code.LITERAL' )
116+ entries . concat get_custom_entries ( '> .TABLE td:first-child > p > code.LITERAL:first-child' )
117+ entries . concat get_custom_entries ( '> .TABLE td:first-child > p > code.FUNCTION:first-child' )
118+ entries . concat get_custom_entries ( '> .TABLE td:first-child > p > code:not(.LITERAL):first-child + code.LITERAL' )
119+ if slug == 'functions-comparison' && !at_css ( '#FUNCTIONS-COMPARISON-PRED-TABLE' ) # before 9.6
120+ entries . concat %w( IS NULL BETWEEN DISTINCT\ FROM ) . map { |name | [ "#{ self . name } : #{ name } " ] }
121+ end
103122 end
104123 end
105124
@@ -157,12 +176,18 @@ def include_default_entry?
157176
158177 def skip_additional_entries?
159178 return true unless type
160- SKIP_ENTRIES_SLUGS . include? ( slug ) || SKIP_ENTRIES_TYPES . include? ( type ) || type . start_with? ( 'Internals' )
179+ SKIP_ENTRIES_SLUGS . include? ( slug ) ||
180+ SKIP_ENTRIES_TYPES . include? ( type ) ||
181+ type . start_with? ( 'Internals' ) ||
182+ type . start_with? ( 'Tutorial' ) ||
183+ type . start_with? ( 'Appendix' )
161184 end
162185
163186 def clean_heading_name ( name )
164187 name . remove! 'Chapter '
165188 name . remove! %r{\A [\d \. \s ]+}
189+ name . remove! 'Appendix '
190+ name . remove! %r{\A [A-Z]\. [\d \. \s ]*}
166191 name . remove! 'Using '
167192 name . remove! %r{\A The }
168193 name . remove! ' (Common Table Expressions)'
@@ -185,7 +210,7 @@ def get_custom_entries(selector)
185210 name . squeeze! ' '
186211 name . remove! %r{\( [^\) ]*\z } # bug fix: json_populate_record
187212 name = '||' if name . include? ' || '
188- id = name . gsub ( /[^a-z0 -9\- _]/ ) { |char | char . ord }
213+ id = name . gsub ( /[^a-zA-Z0 -9\- _]/ ) { |char | char . ord }
189214 id = id . parameterize
190215 name . prepend "#{ additional_entry_prefix } : "
191216
0 commit comments