Skip to content

Commit 50e138b

Browse files
committed
Update PostgreSQL documentation (9.6.0, 9.5.4, 9.4.9)
1 parent 7394ab0 commit 50e138b

6 files changed

Lines changed: 84 additions & 24 deletions

File tree

assets/javascripts/collections/types.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ class app.collections.Types extends app.Collection
88
result.filter (e) -> e.length > 0
99

1010
GUIDES_RGX = /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual)($|[\):])/i
11+
APPENDIX_RGX = /appendix/i
1112

1213
_groupFor: (type) ->
1314
if GUIDES_RGX.test(type.name)
1415
0
16+
else if APPENDIX_RGX.test(type.name)
17+
2
1518
else
1619
1

assets/stylesheets/pages/_postgres.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66

77
.VARIABLELIST dt { @extend %block-label, %label-blue; }
88

9-
blockquote.NOTE, blockquote.IMPORTANT { @extend %note; }
10-
blockquote.TIP { @extend %note, %note-green; }
9+
blockquote.NOTE, blockquote.IMPORTANT, blockquote.TIP, blockquote.CAUTION { @extend %note; }
10+
blockquote.TIP { @extend %note-green; }
11+
blockquote.CAUTION { @extend %note-orange; }
1112

1213
p > code { @extend %label; }
1314
p.c2 { font-weight: bold; }
15+
16+
.NAVFOOTER > table { width: 100%; }
17+
td[align=center] { text-align: center; }
18+
td[align=right] { text-align: right; }
1419
}

lib/docs/filters/postgresql/clean_html.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,33 @@ def root
1313
def other
1414
@doc = at_css('#docContent')
1515

16-
css('.NAVHEADER', '.NAVFOOTER').remove
16+
css('.NAVHEADER', 'hr', '.NAVFOOTER a[accesskey="H"]').remove
1717

1818
css('a[name]').each do |node|
1919
node.parent['id'] = node['name']
2020
node.before(node.children).remove
2121
end
2222

23-
css('div.SECT1', 'pre > kbd', 'tt > code', 'h1 > tt', '> .CHAPTER').each do |node|
23+
css('div.SECT1', 'pre > kbd', 'tt > code', 'h1 > tt', '> .CHAPTER', 'div.NOTE', '.APPENDIX').each do |node|
2424
node.before(node.children).remove
2525
end
2626

27+
css('div.CAUTION table.CAUTION').each do |node|
28+
parent = node.parent
29+
title = node.at_css('.c2, .c3, .c4, .c5').content
30+
node.replace(node.css('p'))
31+
parent.first_element_child.inner_html = "<strong>#{title}:</strong> #{parent.first_element_child.inner_html}"
32+
parent.name = 'blockquote'
33+
end
34+
2735
css('table').each do |node|
2836
node.remove_attribute 'border'
2937
node.remove_attribute 'width'
38+
node.remove_attribute 'cellspacing'
39+
node.remove_attribute 'cellpadding'
3040
end
3141

3242
css('td').each do |node|
33-
node.remove_attribute 'align'
3443
node.remove_attribute 'valign'
3544
end
3645

lib/docs/filters/postgresql/entries.rb

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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{\ASQL }
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{\AThe }
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

lib/docs/filters/postgresql/extract_metadata.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ def extract_up_path
1515

1616
def extract_chapter
1717
return unless text = at_css('.NAVHEADER td[align="center"]').content
18-
return unless match = text.match(/\AChapter (\d+)\. (.+)\z/)
19-
result[:pg_chapter] = match[1].to_i
20-
result[:pg_chapter_name] = match[2].strip
18+
if match = text.match(/\AChapter (\d+)\. (.+)\z/)
19+
result[:pg_chapter] = match[1].to_i
20+
result[:pg_chapter_name] = match[2].strip
21+
elsif match = text.match(/\AAppendix ([A-Z])\. (.+)\z/)
22+
result[:pg_appendix] = match[1]
23+
result[:pg_appendix_name] = match[2].strip
24+
end
2125
end
2226
end
2327
end

lib/docs/scrapers/postgresql.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Postgresql < UrlScraper
55
self.name = 'PostgreSQL'
66
self.type = 'postgres'
77
self.root_path = 'reference.html'
8-
self.initial_paths = %w(sql.html admin.html internals.html)
8+
self.initial_paths = %w(sql.html admin.html internals.html appendixes.html tutorial.html)
99

1010
html_filters.insert_before 'normalize_urls', 'postgresql/extract_metadata'
1111
html_filters.push 'postgresql/clean_html', 'postgresql/entries', 'title'
@@ -23,10 +23,13 @@ class Postgresql < UrlScraper
2323
supported-platforms.html
2424
error-message-reporting.html
2525
error-style-guide.html
26-
plhandler.html)
26+
plhandler.html
27+
sourcerepo.html
28+
git.html
29+
bug-reporting.html
30+
client-interfaces.html)
2731

2832
options[:skip_patterns] = [
29-
/\Atutorial/,
3033
/\Ainstall/,
3134
/\Aregress/,
3235
/\Aprotocol/,
@@ -35,21 +38,32 @@ class Postgresql < UrlScraper
3538
/\Afdw/,
3639
/\Atablesample/,
3740
/\Acustom-scan/,
38-
/\Abki/ ]
41+
/\Abki/,
42+
/\Arelease/,
43+
/\Acontrib-prog/,
44+
/\Aexternal/,
45+
/\Adocguide/,
46+
/\Afeatures/,
47+
/\Aunsupported-features/ ]
3948

4049
options[:attribution] = <<-HTML
4150
&copy; 1996&ndash;2016 The PostgreSQL Global Development Group<br>
4251
Licensed under the PostgreSQL License.
4352
HTML
4453

54+
version '9.6' do
55+
self.release = '9.6.0'
56+
self.base_url = 'https://www.postgresql.org/docs/9.6/static/'
57+
end
58+
4559
version '9.5' do
46-
self.release = '9.5'
47-
self.base_url = 'http://www.postgresql.org/docs/9.5/static/'
60+
self.release = '9.5.4'
61+
self.base_url = 'https://www.postgresql.org/docs/9.5/static/'
4862
end
4963

5064
version '9.4' do
51-
self.release = '9.4'
52-
self.base_url = 'http://www.postgresql.org/docs/9.4/static/'
65+
self.release = '9.4.9'
66+
self.base_url = 'https://www.postgresql.org/docs/9.4/static/'
5367
end
5468
end
5569
end

0 commit comments

Comments
 (0)