History

Update Docker documentation (1.12, 1.11, 1.10)

Thibaut Courouble committed 10 years ago

Commit 0ebd9fa1 parent 9386a2d5 files · +139 −25Browse files

Unified · Split

5 files
  1. lib/docs/filters/docker/clean_html.rb +3 −1
  2. lib/docs/filters/docker/clean_html_old.rb +22 −0
  3. lib/docs/filters/docker/entries.rb +11 −13
  4. lib/docs/filters/docker/entries_old.rb +56 −0
  5. lib/docs/scrapers/docker.rb +47 −11
lib/docs/filters/docker/clean_html.rb+3−1
@@ -7,10 +7,12 @@ 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').remove
15
14 css('pre').each do |node|16 css('pre').each do |node|
15 node.content = node.content17 node.content = node.content
16 end18 end
lib/docs/filters/docker/clean_html_old.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Docker
3 class CleanHtmlOldFilter < 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+11−13
@@ -2,14 +2,15 @@ module Docs · 1 unmodified line
2 class Docker2 class Docker
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip5 return 'Engine' if subpath == 'engine/'
6
7 name = nav_link.content.strip
6 name.capitalize! if name == 'exoscale'8 name.capitalize! if name == 'exoscale'
7 9
8 if name =~ /\A[a-z\-\s]+\z/10 if name =~ /\A[a-z\-\s]+\z/
9 name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./11 name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
10 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./12 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
11 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./13 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
12 name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
13 else14 else
14 name << " (#{product})" if name !~ /#{product}/i15 name << " (#{product})" if name !~ /#{product}/i
15 end16 end
@@ -18,16 +19,13 @@ module Docs · 2 unmodified lines
18 end19 end
19 20
20 def get_type21 def get_type
21 unless nav_link22 return 'Engine' if subpath == 'engine/'
22 return 'Engine: User guide' if subpath.start_with?('engine/userguide')
23 return 'Engine: Secure' if subpath.start_with?('engine/security')
24 return 'Engine' if subpath == 'engine/'
25 end
26 23
27 type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|24 type = nav_link.ancestors('.menu-open').to_a.reverse.to_a[0..1].map do |node|
28 node.at_css('> button').content.strip25 node.at_css('> a').content.strip
29 end.join(': ')26 end.join(': ')
30 27
28 type = self.name if type.empty?
31 type.remove! %r{\ADocker }29 type.remove! %r{\ADocker }
32 type.remove! %r{ Engine}30 type.remove! %r{ Engine}
33 type.sub! %r{Command[\-\s]line reference}i, 'CLI'31 type.sub! %r{Command[\-\s]line reference}i, 'CLI'
@@ -37,14 +35,14 @@ module Docs · 3 unmodified lines
37 35
38 def nav_link36 def nav_link
39 return @nav_link if defined?(@nav_link)37 return @nav_link if defined?(@nav_link)
40 @nav_link = at_css('#multiple .active')38 @nav_link = at_css('.currentPage')
41 39
42 unless @nav_link40 unless @nav_link
43 link = at_css('#content li a')41 link = at_css('#DocumentationText li a')
44 return unless link42 return unless link
45 link = at_css("#multiple a[href='#{link['href']}']")43 link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
46 return unless link44 return unless link
47 @nav_link = link.ancestors('article').first.at_css('button')45 @nav_link = link.ancestors('.menu-closed').first.at_css('a')
48 end46 end
49 47
50 @nav_link48 @nav_link
lib/docs/filters/docker/entries_old.rb+56−0
@@ -0,0 +1,56 @@
1module Docs
2 class Docker
3 class EntriesOldFilter < 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+47−11
@@ -6,20 +6,37 @@ module Docs · 5 unmodified lines
6 code: 'https://github.com/docker/docker'6 code: 'https://github.com/docker/docker'
7 }7 }
8 8
9 html_filters.push 'docker/entries', 'docker/clean_html'
10
11 options[:container] = '#docs'
12 options[:trailing_slash] = true9 options[:trailing_slash] = true
13 10
14 options[:only_patterns] = [11 options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
15 /\Aengine\//,12
16 /\Acompose\//,13 options[:skip] = %w(
17 /\Amachine\//,14 swarm/scheduler/
18 /\Aswarm\//15 swarm/swarm_at_scale/
19 ]16 swarm/reference/
20 options[:skip] = %w(swarm/scheduler/)17 engine/installation/linux/
18 engine/installation/cloud/
19 engine/installation/
20 engine/tutorials/
21 engine/userguide/
22 engine/extend/
23 engine/examples/
24 engine/reference/
25 engine/reference/api/
26 engine/security/
27 engine/security/trust/
28 engine/getstarted/linux_install_help/
29 machine/reference/
30 machine/drivers/
31 machine/examples/
32 compose/reference/
33 ) # index pages
34
21 options[:replace_paths] = {35 options[:replace_paths] = {
22 'engine/installation/ubuntulinux/' => 'engine/installation/linux/ubuntulinux/'36 'engine/installation/ubuntulinux/' => 'engine/installation/linux/ubuntulinux/',
37 'engine/userguide/networking/dockernetworks/' => 'engine/userguide/networking/',
38 'engine/reference/logging/overview/' => 'engine/admin/logging/overview/',
39 'engine/userguide/dockervolumes/' => 'engine/tutorials/dockervolumes/'
23 }40 }
24 41
25 options[:attribution] = <<-HTML42 options[:attribution] = <<-HTML
@@ -29,14 +46,33 @@ module Docs · 3 unmodified lines
29 Docker, Inc. and other parties may also have trademark rights in other terms used herein.46 Docker, Inc. and other parties may also have trademark rights in other terms used herein.
30 HTML47 HTML
31 48
49 version '1.12' do
50 self.release = '1.12'
51 self.base_url = 'https://docs.docker.com/'
52
53 html_filters.push 'docker/entries', 'docker/clean_html'
54
55 options[:container] = '.container-fluid .row'
56 end
57
32 version '1.11' do58 version '1.11' do
33 self.release = '1.11'59 self.release = '1.11'
34 self.base_url = "https://docs.docker.com/v#{self.version}/"60 self.base_url = "https://docs.docker.com/v#{self.version}/"
61
62 html_filters.push 'docker/entries_old', 'docker/clean_html_old'
63
64 options[:container] = '#docs'
65 options[:only_patterns] << /\Aswarm\//
35 end66 end
36 67
37 version '1.10' do68 version '1.10' do
38 self.release = '1.10'69 self.release = '1.10'
39 self.base_url = "https://docs.docker.com/v#{self.version}/"70 self.base_url = "https://docs.docker.com/v#{self.version}/"
71
72 html_filters.push 'docker/entries_old', 'docker/clean_html_old'
73
74 options[:container] = '#docs'
75 options[:only_patterns] << /\Aswarm\//
40 end76 end
41 end77 end
42end78end