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
210 'https://raw.githubusercontent.com/django/django/master/LICENSE'210 'https://raw.githubusercontent.com/django/django/master/LICENSE'
211 ], [211 ], [
212 'Docker',212 '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.',
214 'Apache',214 'Apache',
215 'https://raw.githubusercontent.com/docker/docker/master/LICENSE'215 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE'
216 ], [216 ], [
217 'Dojo',217 'Dojo',
218 '2005-2017 JS Foundation',218 '2005-2017 JS Foundation',
lib/docs/filters/docker/clean_html.rb+7−1
@@ -7,7 +7,7 @@ module Docs · 6 unmodified lines
7 return doc7 return doc
8 end8 end
9 9
10 @doc = at_css('#DocumentationText')10 @doc = at_css('main .section')
11 11
12 at_css('h2').name = 'h1' unless at_css('h1')12 at_css('h2').name = 'h1' unless at_css('h1')
13 13
@@ -30,8 +30,14 @@ module Docs · 16 unmodified lines
30 node.content = node.content.gsub(/\s+/, ' ').strip30 node.content = node.content.gsub(/\s+/, ' ').strip
31 end31 end
32 32
33 css('> span').each do |node|
34 node.name = 'p'
35 node.remove_attribute('style')
36 end
37
33 doc38 doc
34 end39 end
35 end40 end
36 end41 end
37end42end
43
lib/docs/filters/docker/clean_html_old.rb+16−1
@@ -7,12 +7,27 @@ module Docs · 6 unmodified lines
7 return doc7 return doc
8 end8 end
9 9
10 @doc = at_css('#content')10 @doc = at_css('#DocumentationText')
11 11
12 at_css('h2').name = 'h1' unless at_css('h1')12 at_css('h2').name = 'h1' unless at_css('h1')
13 13
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
14 css('pre').each do |node|20 css('pre').each do |node|
15 node.content = node.content21 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
16 end31 end
17 32
18 doc33 doc
lib/docs/filters/docker/clean_html_very_old.rb+22−0
@@ -0,0 +1,22 @@
1module 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
22end
lib/docs/filters/docker/entries.rb+6−31
@@ -4,7 +4,8 @@ module Docs · 3 unmodified lines
4 NAME_BY_SUBPATH = {4 NAME_BY_SUBPATH = {
5 'engine/' => 'Engine',5 'engine/' => 'Engine',
6 'compose/' => 'Compose',6 'compose/' => 'Compose',
7 'machine/' => 'Machine'7 'machine/' => 'Machine',
8 'notary/' => 'Notary'
8 }9 }
9 10
10 def get_name11 def get_name
@@ -19,52 +20,26 @@ module Docs · 8 unmodified lines
19 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./20 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
20 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./21 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
21 else22 else
22 name << " (#{product})" if name !~ /#{product}/i23 name << " (#{product})" if name !~ /#{product}/i && !subpath.start_with?('get-started')
23 end24 end
24 25
25 name26 name
26 end27 end
27 28
28 TYPE_BY_SUBPATH = {
29 'engine/' => 'Engine',
30 'compose/' => 'Compose',
31 'machine/' => 'Machine'
32 }
33
34 def get_type29 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')
36 return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')32 return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')
37 return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')33 return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')
38 return 'Engine: Security' if subpath.start_with?('engine/security/')34 return 'Engine: Security' if subpath.start_with?('engine/security/')
39 return 'Engine: Extend' if subpath.start_with?('engine/extend/')35 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/')36 return 'Engine: Tutorials' if subpath.start_with?('engine/tutorials/')
42 return product if !nav_link && subpath =~ /\A\w+\/[\w\-]+\/\z/37 product
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
53 end38 end
54 39
55 def nav_link40 def nav_link
56 return @nav_link if defined?(@nav_link)41 return @nav_link if defined?(@nav_link)
57 @nav_link = at_css('.currentPage')42 @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
68 end43 end
69 44
70 def product45 def product
lib/docs/filters/docker/entries_old.rb+35−16
@@ -1,15 +1,23 @@
1module Docs1module Docs
2 class Docker2 class Docker
3 class EntriesOldFilter < Docs::EntriesFilter3 class EntriesOldFilter < Docs::EntriesFilter
4 NAME_BY_SUBPATH = {
5 'engine/' => 'Engine',
6 'compose/' => 'Compose',
7 'machine/' => 'Machine'
8 }
9
4 def get_name10 def get_name
5 name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip11 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
6 name.capitalize! if name == 'exoscale'15 name.capitalize! if name == 'exoscale'
16 name.remove! ' (base command)'
7 17
8 if name =~ /\A[a-z\-\s]+\z/18 if name =~ /\A[a-z\-\s]+\z/
9 name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./19 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
10 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
11 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./20 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
12 name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
13 else21 else
14 name << " (#{product})" if name !~ /#{product}/i22 name << " (#{product})" if name !~ /#{product}/i
15 end23 end
@@ -17,32 +25,43 @@ module Docs · 1 unmodified line
17 name25 name
18 end26 end
19 27
28 TYPE_BY_SUBPATH = {
29 'engine/' => 'Engine',
30 'compose/' => 'Compose',
31 'machine/' => 'Machine'
32 }
33
20 def get_type34 def get_type
21 unless nav_link35 return TYPE_BY_SUBPATH[subpath] if TYPE_BY_SUBPATH[subpath]
22 return 'Engine: User guide' if subpath.start_with?('engine/userguide')36 return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')
23 end37 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/
24 43
25 type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|44 leaves = nav_link.ancestors('li.leaf').reverse
26 node.at_css('> button').content.strip45 return product if leaves.length <= 2
27 end.join(': ')
28 46
47 type = leaves[0..1].map { |node| node.at_css('> a').content.strip }.join(': ')
29 type.remove! %r{\ADocker }48 type.remove! %r{\ADocker }
30 type.remove! %r{ Engine}49 type.remove! ' Engine'
31 type.sub! %r{Command[\-\s]line reference}i, 'CLI'50 type.sub! %r{Command[\-\s]line reference}i, 'CLI'
32 type = 'Engine: Reference' if type == 'Engine: reference'51 type.sub! 'CLI reference', 'CLI'
33 type52 type
34 end53 end
35 54
36 def nav_link55 def nav_link
37 return @nav_link if defined?(@nav_link)56 return @nav_link if defined?(@nav_link)
38 @nav_link = at_css('#multiple .active')57 @nav_link = at_css('.currentPage')
39 58
40 unless @nav_link59 unless @nav_link
41 link = at_css('#content li a')60 link = at_css('#DocumentationText li a')
42 return unless link61 return unless link
43 link = at_css("#multiple a[href='#{link['href']}']")62 link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
44 return unless link63 return unless link
45 @nav_link = link.ancestors('article').first.at_css('button')64 @nav_link = link.ancestors('.menu-closed').first.at_css('a')
46 end65 end
47 66
48 @nav_link67 @nav_link
lib/docs/filters/docker/entries_very_old.rb+56−0
@@ -0,0 +1,56 @@
1module 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
56end
lib/docs/scrapers/docker.rb+86−37
@@ -8,82 +8,131 @@ module Docs · 7 unmodified lines
8 8
9 options[:trailing_slash] = true9 options[:trailing_slash] = true
10 10
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
27 options[:fix_urls] = ->(url) do11 options[:fix_urls] = ->(url) do
28 url.sub! %r{\.md/?(?=#|\z)}, '/'12 url.sub! %r{\.md/?(?=#|\z)}, '/'
29 url.sub! '/index/', '/'13 url.sub! '/index/', '/'
30 url14 url
31 end15 end
32 16
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
47 options[:attribution] = <<-HTML17 options[:attribution] = <<-HTML
48 &copy; 2013&ndash;2016 Docker, Inc.<br>18 &copy; 2017 Docker, Inc.<br>
49 Licensed under the Apache License, Version 2.0.<br>19 Licensed under the Apache License, Version 2.0.<br>
50 Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>20 Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>
51 Docker, Inc. and other parties may also have trademark rights in other terms used herein.21 Docker, Inc. and other parties may also have trademark rights in other terms used herein.
52 HTML22 HTML
53 23
54 version '1.13' do24 version '17' do
55 self.release = '1.13'25 self.release = '17.06'
56 self.base_url = 'https://docs.docker.com/'26 self.base_url = 'https://docs.docker.com/'
57 27
58 html_filters.push 'docker/entries', 'docker/clean_html'28 html_filters.push 'docker/entries', 'docker/clean_html'
59 29
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
60 options[:container] = '.container-fluid .row'103 options[:container] = '.container-fluid .row'
61 end104 end
62 105
63 version '1.12' do106 version '1.12' do
107 include OldOptions
108
64 self.release = '1.12'109 self.release = '1.12'
65 # self.base_url = 'https://docs.docker.com/'110 self.base_url = "https://docs.docker.com/v#{self.version}/"
66 111
67 html_filters.push 'docker/entries', 'docker/clean_html'112 html_filters.push 'docker/entries_old', 'docker/clean_html_old'
68 113
69 options[:container] = '.container-fluid .row'114 options[:container] = '.container-fluid .row'
70 end115 end
71 116
72 version '1.11' do117 version '1.11' do
118 include OldOptions
119
73 self.release = '1.11'120 self.release = '1.11'
74 self.base_url = "https://docs.docker.com/v#{self.version}/"121 self.base_url = "https://docs.docker.com/v#{self.version}/"
75 122
76 html_filters.push 'docker/entries_old', 'docker/clean_html_old'123 html_filters.push 'docker/entries_very_old', 'docker/clean_html_very_old'
77 124
78 options[:container] = '#docs'125 options[:container] = '#docs'
79 options[:only_patterns] << /\Aswarm\//126 options[:only_patterns] << /\Aswarm\//
80 end127 end
81 128
82 version '1.10' do129 version '1.10' do
130 include OldOptions
131
83 self.release = '1.10'132 self.release = '1.10'
84 self.base_url = "https://docs.docker.com/v#{self.version}/"133 self.base_url = "https://docs.docker.com/v#{self.version}/"
85 134
86 html_filters.push 'docker/entries_old', 'docker/clean_html_old'135 html_filters.push 'docker/entries_very_old', 'docker/clean_html_very_old'
87 136
88 options[:container] = '#docs'137 options[:container] = '#docs'
89 options[:only_patterns] << /\Aswarm\//138 options[:only_patterns] << /\Aswarm\//