History

Improve & version PostgreSQL documentation (9.4 and 9.5)

Thibaut Courouble committed 10 years ago

Commit 426d6b81 parent 9098ff56 files · +73 −61Browse files

Unified · Split

6 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +1 −1
  2. assets/stylesheets/pages/_postgres.scss +1 −0
  3. lib/docs/filters/postgresql/clean_html.rb +1 −1
  4. lib/docs/filters/postgresql/entries.rb +37 −7
  5. lib/docs/filters/postgresql/extract_metadata.rb +1 −1
  6. lib/docs/scrapers/postgresql.rb +32 −51
assets/javascripts/templates/pages/about_tmpl.coffee+1−1
@@ -321,7 +321,7 @@ credits = [ · 320 unmodified lines
321321 'https://creativecommons.org/licenses/by/3.0/'
322322 ], [
323323 'PostgreSQL',
324− '1996-2013 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
324+ '1996-2016 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
325325 'PostgreSQL',
326326 'http://www.postgresql.org/about/licence/'
327327 ], [
assets/stylesheets/pages/_postgres.scss+1−0
@@ -10,4 +10,5 @@ · 9 unmodified lines
1010 blockquote.TIP { @extend %note, %note-green; }
1111
1212 p > code { @extend %label; }
13+ p.c2 { font-weight: bold; }
1314 }
lib/docs/filters/postgresql/clean_html.rb+1−1
@@ -20,7 +20,7 @@ module Docs · 19 unmodified lines
2020 node.before(node.children).remove
2121 end
2222
23− css('div.SECT1', 'pre > kbd', 'tt > code', 'h1 > tt').each do |node|
23+ css('div.SECT1', 'pre > kbd', 'tt > code', 'h1 > tt', '> .CHAPTER').each do |node|
2424 node.before(node.children).remove
2525 end
2626
lib/docs/filters/postgresql/entries.rb+37−7
@@ -23,7 +23,21 @@ module Docs · 22 unmodified lines
2323 'High Availability, Load Balancing, and Replication' => 'High Availability',
2424 'Monitoring Database Activity' => 'Monitoring',
2525 'Monitoring Disk Usage' => 'Monitoring',
26− 'Reliability and the Write-Ahead Log' => 'Write-Ahead Log' }
26+ 'Reliability and the Write-Ahead Log' => 'Write-Ahead Log',
27+ 'Overview of PostgreSQL Internals' => 'Internals',
28+ 'System Catalogs' => 'Internals: Catalogs',
29+ 'How the Planner Uses Statistics' => 'Internals',
30+ 'Index Access Method Interface Definition' => 'Index Access Method',
31+ 'Database Physical Storage' => 'Physical Storage' }
32+
33+ INTERNAL_TYPES = [
34+ 'Genetic Query Optimizer',
35+ 'Index Access Method',
36+ 'GiST Indexes',
37+ 'SP-GiST Indexes',
38+ 'GIN Indexes',
39+ 'BRIN Indexes',
40+ 'Physical Storage' ]
2741
2842 def base_name
2943 @base_name ||= clean_heading_name(at_css('h1').content)
@@ -32,8 +46,8 @@ module Docs · 2 unmodified lines
3246 def get_name
3347 if %w(Overview Introduction).include?(base_name)
3448 result[:pg_chapter_name]
35− elsif PREPEND_TYPES.include?(type)
36− "#{type}: #{base_name}"
49+ elsif PREPEND_TYPES.include?(type) || type.start_with?('Internals')
50+ "#{type.remove('Internals: ')}: #{base_name}"
3751 else
3852 REPLACE_NAMES[base_name] || base_name
3953 end
@@ -50,8 +64,10 @@ module Docs · 10 unmodified lines
5064 if type.start_with?('Func') && (match = base_name.match(/\A(?!Form|Seq|Set|Enum)(.+) Func/))
5165 "Functions: #{match[1]}"
5266 else
53− type.remove! 'SQL '
54− REPLACE_TYPES[type] || type
67+ type.remove! %r{\ASQL }
68+ type = REPLACE_TYPES[type] || type
69+ type = "Internals: #{type}" if INTERNAL_TYPES.include?(type)
70+ type
5571 end
5672 end
5773 end
@@ -60,6 +76,7 @@ module Docs · 2 unmodified lines
6076 return [] if skip_additional_entries?
6177 return config_additional_entries if type && type.include?('Configuration')
6278 return data_types_additional_entries if type == 'Data Types'
79+ return command_additional_entries if type == 'Commands'
6380 return get_heading_entries('h3[id]') if slug == 'functions-xml'
6481
6582 entries = get_heading_entries('h2[id]')
@@ -81,6 +98,7 @@ module Docs · 15 unmodified lines
8198 else
8299 if type && type.start_with?('Functions')
83100 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')
84102 entries.concat %w(IS NULL BETWEEN DISTINCT\ FROM).map { |name| ["#{self.name}: #{name}"] } if slug == 'functions-comparison'
85103 end
86104 end
@@ -107,8 +125,18 @@ module Docs · 20 unmodified lines
107125 get_custom_entries(selector)
108126 end
109127
128+ def command_additional_entries
129+ css('.REFSECT2[id^="SQL"]').each_with_object([]) do |node, entries|
130+ next unless heading = node.at_css('h3')
131+ next unless heading.content.strip =~ /[A-Z_\-]+ Clause/
132+ name = heading.at_css('.LITERAL').content
133+ name.prepend "#{self.name} ... "
134+ entries << [name, node['id']]
135+ end
136+ end
137+
110138 def include_default_entry?
111− !initial_page? && !at_css('.TOC')
139+ !initial_page? && !at_css('.TOC') && type
112140 end
113141
114142 SKIP_ENTRIES_SLUGS = [
@@ -128,10 +156,12 @@ module Docs · 13 unmodified lines
128156 'Monitoring' ]
129157
130158 def skip_additional_entries?
131− SKIP_ENTRIES_SLUGS.include?(slug) || SKIP_ENTRIES_TYPES.include?(type)
159+ return true unless type
160+ SKIP_ENTRIES_SLUGS.include?(slug) || SKIP_ENTRIES_TYPES.include?(type) || type.start_with?('Internals')
132161 end
133162
134163 def clean_heading_name(name)
164+ name.remove! 'Chapter '
135165 name.remove! %r{\A[\d\.\s]+}
136166 name.remove! 'Using '
137167 name.remove! %r{\AThe }
lib/docs/filters/postgresql/extract_metadata.rb+1−1
@@ -17,7 +17,7 @@ module Docs · 16 unmodified lines
1717 return unless text = at_css('.NAVHEADER td[align="center"]').content
1818 return unless match = text.match(/\AChapter (\d+)\. (.+)\z/)
1919 result[:pg_chapter] = match[1].to_i
20− result[:pg_chapter_name] = match[2]
20+ result[:pg_chapter_name] = match[2].strip
2121 end
2222 end
2323 end
lib/docs/scrapers/postgresql.rb+32−51
@@ -1,11 +1,11 @@
11 module Docs
22 class Postgresql < UrlScraper
3+ include FixInternalUrlsBehavior
4+
35 self.name = 'PostgreSQL'
46 self.type = 'postgres'
5− self.release = '9.4'
6− self.base_url = "http://www.postgresql.org/docs/#{release}/static/"
77 self.root_path = 'reference.html'
8− self.initial_paths = %w(sql.html admin.html)
8+ self.initial_paths = %w(sql.html admin.html internals.html)
99
1010 html_filters.insert_before 'normalize_urls', 'postgresql/extract_metadata'
1111 html_filters.push 'postgresql/clean_html', 'postgresql/entries', 'title'
@@ -14,61 +14,42 @@ module Docs · 2 unmodified lines
1414 options[:root_title] = 'PostgreSQL'
1515 options[:follow_links] = ->(filter) { filter.initial_page? }
1616
17− options[:only] = %w(
18− arrays.html
19− rowtypes.html
20− rangetypes.html
21− transaction-iso.html
22− explicit-locking.html
23− applevel-consistency.html
24− locking-indexes.html
25− config-setting.html
26− locale.html
27− collation.html
28− multibyte.html
29− using-explain.html
30− planner-stats.html
31− explicit-joins.html
32− populate.html
33− non-durability.html
34− logfile-maintenance.html
35− continuous-archiving.html
36− dynamic-trace.html)
37−
38− options[:only_patterns] = [
39− /\Asql\-/,
40− /\Aapp\-/,
41− /\Addl\-/,
42− /\Adml\-/,
43− /\Aqueries\-/,
44− /\Adatatype\-/,
45− /\Afunctions\-/,
46− /\Atypeconv\-/,
47− /\Atextsearch\-/,
48− /\Amvcc\-/,
49− /\Aindexes\-/,
50− /\Aruntime\-config\-/,
51− /\Aauth\-/,
52− /\Aclient\-authentication/,
53− /\Amanage\-ag/,
54− /\Aroutine/,
55− /\Abackup\-/,
56− /\Amonitoring\-/,
57− /\Awal\-/,
58− /\Adisk/,
59− /role/,
60− /recovery/,
61− /standby/]
62−
6317 options[:skip] = %w(
18+ index.html
6419 ddl-others.html
6520 functions-event-triggers.html
6621 functions-trigger.html
67− textsearch-migration.html)
22+ textsearch-migration.html
23+ supported-platforms.html
24+ error-message-reporting.html
25+ error-style-guide.html
26+ plhandler.html)
27+
28+ options[:skip_patterns] = [
29+ /\Atutorial/,
30+ /\Ainstall/,
31+ /\Aregress/,
32+ /\Aprotocol/,
33+ /\Asource/,
34+ /\Anls/,
35+ /\Afdw/,
36+ /\Atablesample/,
37+ /\Acustom-scan/,
38+ /\Abki/ ]
6839
6940 options[:attribution] = <<-HTML
70− &copy; 1996&ndash;2014 The PostgreSQL Global Development Group<br>
41+ &copy; 1996&ndash;2016 The PostgreSQL Global Development Group<br>
7142 Licensed under the PostgreSQL License.
7243 HTML
44+
45+ version '9.5' do
46+ self.release = '9.5'
47+ self.base_url = 'http://www.postgresql.org/docs/9.5/static/'
48+ end
49+
50+ version '9.4' do
51+ self.release = '9.4'
52+ self.base_url = 'http://www.postgresql.org/docs/9.4/static/'
53+ end
7354 end
7455 end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t