History

Update Docker documentation (17.06)

Thibaut Courouble committed 9 years ago

Commit 437eb8d1 parent 0e134da8 files · +230 −88Browse files

Unified · Split

8 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +2 −2
  2. lib/docs/filters/docker/clean_html.rb +7 −1
  3. lib/docs/filters/docker/clean_html_old.rb +16 −1
  4. lib/docs/filters/docker/clean_html_very_old.rb +22 −0
  5. lib/docs/filters/docker/entries.rb +6 −31
  6. lib/docs/filters/docker/entries_old.rb +35 −16
  7. lib/docs/filters/docker/entries_very_old.rb +56 −0
  8. lib/docs/scrapers/docker.rb +86 −37
assets/javascripts/templates/pages/about_tmpl.coffee+2−2
@@ -210,9 +210,9 @@ credits = [ · 209 unmodified lines
210210 'https://raw.githubusercontent.com/django/django/master/LICENSE'
211211 ], [
212212 'Docker',
213− '2013-2016 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',
213+ '2017 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',
214214 'Apache',
215− 'https://raw.githubusercontent.com/docker/docker/master/LICENSE'
215+ 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE'
216216 ], [
217217 'Dojo',
218218 '2005-2017 JS Foundation',
lib/docs/filters/docker/clean_html.rb+7−1
@@ -7,7 +7,7 @@ module Docs · 6 unmodified lines
77 return doc
88 end
99
10− @doc = at_css('#DocumentationText')
10+ @doc = at_css('main .section')
1111
1212 at_css('h2').name = 'h1' unless at_css('h1')
1313
@@ -30,8 +30,14 @@ module Docs · 16 unmodified lines
3030 node.content = node.content.gsub(/\s+/, ' ').strip
3131 end
3232
33+ css('> span').each do |node|
34+ node.name = 'p'
35+ node.remove_attribute('style')
36+ end
37+
3338 doc
3439 end
3540 end
3641 end
3742 end
43+
lib/docs/filters/docker/clean_html_old.rb+16−1
@@ -7,12 +7,27 @@ module Docs · 6 unmodified lines
77 return doc
88 end
99
10− @doc = at_css('#content')
10+ @doc = at_css('#DocumentationText')
1111
1212 at_css('h2').name = 'h1' unless at_css('h1')
1313
14+ css('.anchorLink', '.reading-time', 'hr', '> div[style*="margin-top"]:last-child').remove
15+
16+ css('h1 + h1').each do |node|
17+ node.name = 'h2'
18+ end
19+
1420 css('pre').each do |node|
1521 node.content = node.content
22+ node['data-language'] = node.parent['class'][/language-(\w+)/, 1] if node.parent['class']
23+ end
24+
25+ css('div.highlighter-rouge').each do |node|
26+ node.before(node.children).remove
27+ end
28+
29+ css('code.highlighter-rouge').each do |node|
30+ node.content = node.content.gsub(/\s+/, ' ').strip
1631 end
1732
1833 doc
lib/docs/filters/docker/clean_html_very_old.rb+22−0
@@ -0,0 +1,22 @@
1+module Docs
2+ class Docker
3+ class CleanHtmlVeryOldFilter < Filter
4+ def call
5+ if root_page?
6+ doc.inner_html = "<h1>Docker Documentation</h1>"
7+ return doc
8+ end
9+
10+ @doc = at_css('#content')
11+
12+ at_css('h2').name = 'h1' unless at_css('h1')
13+
14+ css('pre').each do |node|
15+ node.content = node.content
16+ end
17+
18+ doc
19+ end
20+ end
21+ end
22+end
lib/docs/filters/docker/entries.rb+6−31
@@ -4,7 +4,8 @@ module Docs · 3 unmodified lines
44 NAME_BY_SUBPATH = {
55 'engine/' => 'Engine',
66 'compose/' => 'Compose',
7− 'machine/' => 'Machine'
7+ 'machine/' => 'Machine',
8+ 'notary/' => 'Notary'
89 }
910
1011 def get_name
@@ -19,52 +20,26 @@ module Docs · 8 unmodified lines
1920 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
2021 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
2122 else
22− name << " (#{product})" if name !~ /#{product}/i
23+ name << " (#{product})" if name !~ /#{product}/i && !subpath.start_with?('get-started')
2324 end
2425
2526 name
2627 end
2728
28− TYPE_BY_SUBPATH = {
29− 'engine/' => 'Engine',
30− 'compose/' => 'Compose',
31− 'machine/' => 'Machine'
32− }
33−
3429 def get_type
35− return TYPE_BY_SUBPATH[subpath] if TYPE_BY_SUBPATH[subpath]
30+ return NAME_BY_SUBPATH[subpath] if NAME_BY_SUBPATH[subpath]
31+ return 'Get Started' if subpath.start_with?('get-started')
3632 return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')
3733 return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')
3834 return 'Engine: Security' if subpath.start_with?('engine/security/')
3935 return 'Engine: Extend' if subpath.start_with?('engine/extend/')
40− return 'Engine: Get Started' if subpath.start_with?('engine/getstarted')
4136 return 'Engine: Tutorials' if subpath.start_with?('engine/tutorials/')
42− return product if !nav_link && subpath =~ /\A\w+\/[\w\-]+\/\z/
43−
44− leaves = nav_link.ancestors('li.leaf').reverse
45− return product if leaves.length <= 2
46−
47− type = leaves[0..1].map { |node| node.at_css('> a').content.strip }.join(': ')
48− type.remove! %r{\ADocker }
49− type.remove! ' Engine'
50− type.sub! %r{Command[\-\s]line reference}i, 'CLI'
51− type.sub! 'CLI reference', 'CLI'
52− type
37+ product
5338 end
5439
5540 def nav_link
5641 return @nav_link if defined?(@nav_link)
5742 @nav_link = at_css('.currentPage')
58−
59− unless @nav_link
60− link = at_css('#DocumentationText li a')
61− return unless link
62− link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
63− return unless link
64− @nav_link = link.ancestors('.menu-closed').first.at_css('a')
65− end
66−
67− @nav_link
6843 end
6944
7045 def product
lib/docs/filters/docker/entries_old.rb+35−16
@@ -1,15 +1,23 @@
11 module Docs
22 class Docker
33 class EntriesOldFilter < Docs::EntriesFilter
4+ NAME_BY_SUBPATH = {
5+ 'engine/' => 'Engine',
6+ 'compose/' => 'Compose',
7+ 'machine/' => 'Machine'
8+ }
9+
410 def get_name
5− name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
11+ return NAME_BY_SUBPATH[subpath] if NAME_BY_SUBPATH[subpath]
12+ return at_css('h1').content unless nav_link
13+
14+ name = nav_link.content.strip
615 name.capitalize! if name == 'exoscale'
16+ name.remove! ' (base command)'
717
818 if name =~ /\A[a-z\-\s]+\z/
9− name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
10− name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
19+ name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
1120 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
12− name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
1321 else
1422 name << " (#{product})" if name !~ /#{product}/i
1523 end
@@ -17,32 +25,43 @@ module Docs · 1 unmodified line
1725 name
1826 end
1927
28+ TYPE_BY_SUBPATH = {
29+ 'engine/' => 'Engine',
30+ 'compose/' => 'Compose',
31+ 'machine/' => 'Machine'
32+ }
33+
2034 def get_type
21− unless nav_link
22− return 'Engine: User guide' if subpath.start_with?('engine/userguide')
23− end
35+ return TYPE_BY_SUBPATH[subpath] if TYPE_BY_SUBPATH[subpath]
36+ return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')
37+ return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')
38+ return 'Engine: Security' if subpath.start_with?('engine/security/')
39+ return 'Engine: Extend' if subpath.start_with?('engine/extend/')
40+ return 'Engine: Get Started' if subpath.start_with?('engine/getstarted')
41+ return 'Engine: Tutorials' if subpath.start_with?('engine/tutorials/')
42+ return product if !nav_link && subpath =~ /\A\w+\/[\w\-]+\/\z/
2443
25− type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|
26− node.at_css('> button').content.strip
27− end.join(': ')
44+ leaves = nav_link.ancestors('li.leaf').reverse
45+ return product if leaves.length <= 2
2846
47+ type = leaves[0..1].map { |node| node.at_css('> a').content.strip }.join(': ')
2948 type.remove! %r{\ADocker }
30− type.remove! %r{ Engine}
49+ type.remove! ' Engine'
3150 type.sub! %r{Command[\-\s]line reference}i, 'CLI'
32− type = 'Engine: Reference' if type == 'Engine: reference'
51+ type.sub! 'CLI reference', 'CLI'
3352 type
3453 end
3554
3655 def nav_link
3756 return @nav_link if defined?(@nav_link)
38− @nav_link = at_css('#multiple .active')
57+ @nav_link = at_css('.currentPage')
3958
4059 unless @nav_link
41− link = at_css('#content li a')
60+ link = at_css('#DocumentationText li a')
4261 return unless link
43− link = at_css("#multiple a[href='#{link['href']}']")
62+ link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
4463 return unless link
45− @nav_link = link.ancestors('article').first.at_css('button')
64+ @nav_link = link.ancestors('.menu-closed').first.at_css('a')
4665 end
4766
4867 @nav_link
lib/docs/filters/docker/entries_very_old.rb+56−0
@@ -0,0 +1,56 @@
1+module Docs
2+ class Docker
3+ class EntriesVeryOldFilter < Docs::EntriesFilter
4+ def get_name
5+ name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
6+ name.capitalize! if name == 'exoscale'
7+
8+ if name =~ /\A[a-z\-\s]+\z/
9+ name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
10+ name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
11+ name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
12+ name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
13+ else
14+ name << " (#{product})" if name !~ /#{product}/i
15+ end
16+
17+ name
18+ end
19+
20+ def get_type
21+ unless nav_link
22+ return 'Engine: User guide' if subpath.start_with?('engine/userguide')
23+ end
24+
25+ type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|
26+ node.at_css('> button').content.strip
27+ end.join(': ')
28+
29+ type.remove! %r{\ADocker }
30+ type.remove! %r{ Engine}
31+ type.sub! %r{Command[\-\s]line reference}i, 'CLI'
32+ type = 'Engine: Reference' if type == 'Engine: reference'
33+ type
34+ end
35+
36+ def nav_link
37+ return @nav_link if defined?(@nav_link)
38+ @nav_link = at_css('#multiple .active')
39+
40+ unless @nav_link
41+ link = at_css('#content li a')
42+ return unless link
43+ link = at_css("#multiple a[href='#{link['href']}']")
44+ return unless link
45+ @nav_link = link.ancestors('article').first.at_css('button')
46+ end
47+
48+ @nav_link
49+ end
50+
51+ def product
52+ @product ||= subpath.split('/').first.capitalize
53+ end
54+ end
55+ end
56+end
lib/docs/scrapers/docker.rb+86−37
@@ -8,82 +8,131 @@ module Docs · 7 unmodified lines
88
99 options[:trailing_slash] = true
1010
11− options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
12− options[:skip_patterns] = [/\Aengine\/api\/v/, /\Aengine\/installation/]
13− options[:skip] = %w(
14− /
15− engine/userguide/
16− engine/examples/
17− engine/reference/
18− engine/reference/api/
19− engine/reference/api/docker_remote_api_v1.24/
20− engine/getstarted/linux_install_help/
21− machine/reference/
22− machine/drivers/
23− machine/examples/
24− compose/reference/
25− )
26−
2711 options[:fix_urls] = ->(url) do
2812 url.sub! %r{\.md/?(?=#|\z)}, '/'
2913 url.sub! '/index/', '/'
3014 url
3115 end
3216
33− options[:replace_paths] = {
34− 'engine/userguide/networking/dockernetworks/' => 'engine/userguide/networking/',
35− 'engine/userguide/dockervolumes/' => 'engine/tutorials/dockervolumes/',
36− 'engine/reference/logging/overview/' => 'engine/admin/logging/overview/',
37− 'engine/reference/commandline/daemon/' => 'engine/reference/commandline/dockerd/',
38− 'engine/reference/commandline/' => 'engine/reference/commandline/docker/',
39− 'engine/reference/api/docker_remote_api/' => 'engine/api/',
40− 'engine/swarm/how-swarm-mode-works/' => 'engine/swarm/how-swarm-mode-works/nodes/',
41− 'engine/tutorials/dockerizing/' => 'engine/getstarted/step_one/',
42− 'engine/tutorials/usingdocker/' => 'engine/getstarted/step_three/',
43− 'engine/tutorials/dockerimages/' => 'engine/getstarted/step_four/',
44− 'engine/tutorials/dockerrepos/' => 'engine/getstarted/step_six/'
45− }
46−
4717 options[:attribution] = <<-HTML
48− &copy; 2013&ndash;2016 Docker, Inc.<br>
18+ &copy; 2017 Docker, Inc.<br>
4919 Licensed under the Apache License, Version 2.0.<br>
5020 Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>
5121 Docker, Inc. and other parties may also have trademark rights in other terms used herein.
5222 HTML
5323
54− version '1.13' do
55− self.release = '1.13'
24+ version '17' do
25+ self.release = '17.06'
5626 self.base_url = 'https://docs.docker.com/'
5727
5828 html_filters.push 'docker/entries', 'docker/clean_html'
5929
30+ options[:container] = '.wrapper .container-fluid .row'
31+
32+ options[:only_patterns] = [/\Aget-started\//, /\Aengine\//, /\Acompose\//, /\Amachine\//, /\Anotary\//]
33+ options[:skip_patterns] = [/\Aengine\/api\/v/, /glossary/, /docker-ee/]
34+
35+ options[:replace_paths] = {
36+ 'engine/installation/linux/docker-ee/linux-postinstall/' => 'engine/installation/linux/linux-postinstall/',
37+ 'engine/installation/linux/docker-ee/' => 'engine/installation/',
38+ 'engine/installation/linux/docker-ce/' => 'engine/installation/',
39+ 'engine/installation/linux/' => 'engine/installation/',
40+ 'engine/installation/windows/' => 'engine/installation/',
41+ 'engine/userguide/intro/' => 'engine/userguide/',
42+ 'engine/tutorials/dockervolumes/' => 'engine/admin/volumes/volumes/',
43+ 'engine/getstarted/' => 'get-started/',
44+ 'engine/tutorials/dockerimages/' => 'get-started/',
45+ 'engine/tutorials/dockerrepos/' => 'get-started/',
46+ 'engine/admin/host_integration/' => 'engine/admin/start-containers-automatically/',
47+ 'engine/installation/linux/rhel/' => 'engine/installation/linux/docker-ee/rhel/',
48+ 'engine/installation/linux/ubuntulinux/' => 'engine/installation/linux/docker-ee/ubuntu/',
49+ 'engine/installation/linux/suse/' => 'engine/installation/linux/docker-ee/suse/',
50+ 'engine/admin/logging/' => 'engine/admin/logging/view_container_logs/',
51+ 'engine/swarm/how-swarm-mode-works/' => 'engine/swarm/how-swarm-mode-works/nodes/',
52+ 'engine/installation/binaries/' => 'engine/installation/linux/docker-ce/binaries/',
53+ 'engine/reference/commandline/' => 'engine/reference/commandline/docker/',
54+ 'engine/reference/api/' => 'engine/api/',
55+ 'engine/userguide/dockervolumes/' => 'engine/admin/volumes/volumes/',
56+ 'engine/understanding-docker/' => 'engine/docker-overview/',
57+ 'engine/reference/commandline/swarm_join_token/' => 'engine/reference/commandline/swarm_join-token/',
58+ 'engine/api/getting-started/' => 'engine/api/get-started/',
59+ }
60+ end
61+
62+ module OldOptions
63+ def self.included(klass)
64+ klass.options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
65+ klass.options[:skip_patterns] = [/\Aengine\/api\/v/, /\Aengine\/installation/]
66+ klass.options[:skip] = %w(
67+ /
68+ engine/userguide/
69+ engine/examples/
70+ engine/reference/
71+ engine/reference/api/
72+ engine/reference/api/docker_remote_api_v1.24/
73+ engine/getstarted/linux_install_help/
74+ machine/reference/
75+ machine/drivers/
76+ machine/examples/
77+ compose/reference/
78+ )
79+ klass.options[:replace_paths] = {
80+ 'engine/userguide/networking/dockernetworks/' => 'engine/userguide/networking/',
81+ 'engine/userguide/dockervolumes/' => 'engine/tutorials/dockervolumes/',
82+ 'engine/reference/logging/overview/' => 'engine/admin/logging/overview/',
83+ 'engine/reference/commandline/daemon/' => 'engine/reference/commandline/dockerd/',
84+ 'engine/reference/commandline/' => 'engine/reference/commandline/docker/',
85+ 'engine/reference/api/docker_remote_api/' => 'engine/api/',
86+ 'engine/swarm/how-swarm-mode-works/' => 'engine/swarm/how-swarm-mode-works/nodes/',
87+ 'engine/tutorials/dockerizing/' => 'engine/getstarted/step_one/',
88+ 'engine/tutorials/usingdocker/' => 'engine/getstarted/step_three/',
89+ 'engine/tutorials/dockerimages/' => 'engine/getstarted/step_four/',
90+ 'engine/tutorials/dockerrepos/' => 'engine/getstarted/step_six/'
91+ }
92+ end
93+ end
94+
95+ version '1.13' do
96+ include OldOptions
97+
98+ self.release = '1.13'
99+ self.base_url = "https://docs.docker.com/v#{self.version}/"
100+
101+ html_filters.push 'docker/entries_old', 'docker/clean_html_old'
102+
60103 options[:container] = '.container-fluid .row'
61104 end
62105
63106 version '1.12' do
107+ include OldOptions
108+
64109 self.release = '1.12'
65− # self.base_url = 'https://docs.docker.com/'
110+ self.base_url = "https://docs.docker.com/v#{self.version}/"
66111
67− html_filters.push 'docker/entries', 'docker/clean_html'
112+ html_filters.push 'docker/entries_old', 'docker/clean_html_old'
68113
69114 options[:container] = '.container-fluid .row'
70115 end
71116
72117 version '1.11' do
118+ include OldOptions
119+
73120 self.release = '1.11'
74121 self.base_url = "https://docs.docker.com/v#{self.version}/"
75122
76− html_filters.push 'docker/entries_old', 'docker/clean_html_old'
123+ html_filters.push 'docker/entries_very_old', 'docker/clean_html_very_old'
77124
78125 options[:container] = '#docs'
79126 options[:only_patterns] << /\Aswarm\//
80127 end
81128
82129 version '1.10' do
130+ include OldOptions
131+
83132 self.release = '1.10'
84133 self.base_url = "https://docs.docker.com/v#{self.version}/"
85134
86− html_filters.push 'docker/entries_old', 'docker/clean_html_old'
135+ html_filters.push 'docker/entries_very_old', 'docker/clean_html_very_old'
87136
88137 options[:container] = '#docs'
89138 options[:only_patterns] << /\Aswarm\//