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
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').remove
15+
1416 css('pre').each do |node|
1517 node.content = node.content
1618 end
lib/docs/filters/docker/clean_html_old.rb+22−0
@@ -0,0 +1,22 @@
1+module 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
22+end
lib/docs/filters/docker/entries.rb+11−13
@@ -2,14 +2,15 @@ module Docs · 1 unmodified line
22 class Docker
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
5− name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
5+ return 'Engine' if subpath == 'engine/'
6+
7+ name = nav_link.content.strip
68 name.capitalize! if name == 'exoscale'
79
810 if name =~ /\A[a-z\-\s]+\z/
911 name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
1012 name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
1113 name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
12− name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
1314 else
1415 name << " (#{product})" if name !~ /#{product}/i
1516 end
@@ -18,16 +19,13 @@ module Docs · 2 unmodified lines
1819 end
1920
2021 def get_type
21− unless nav_link
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
22+ return 'Engine' if subpath == 'engine/'
2623
27− type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|
28− node.at_css('> button').content.strip
24+ type = nav_link.ancestors('.menu-open').to_a.reverse.to_a[0..1].map do |node|
25+ node.at_css('> a').content.strip
2926 end.join(': ')
3027
28+ type = self.name if type.empty?
3129 type.remove! %r{\ADocker }
3230 type.remove! %r{ Engine}
3331 type.sub! %r{Command[\-\s]line reference}i, 'CLI'
@@ -37,14 +35,14 @@ module Docs · 3 unmodified lines
3735
3836 def nav_link
3937 return @nav_link if defined?(@nav_link)
40− @nav_link = at_css('#multiple .active')
38+ @nav_link = at_css('.currentPage')
4139
4240 unless @nav_link
43− link = at_css('#content li a')
41+ link = at_css('#DocumentationText li a')
4442 return unless link
45− link = at_css("#multiple a[href='#{link['href']}']")
43+ link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
4644 return unless link
47− @nav_link = link.ancestors('article').first.at_css('button')
45+ @nav_link = link.ancestors('.menu-closed').first.at_css('a')
4846 end
4947
5048 @nav_link
lib/docs/filters/docker/entries_old.rb+56−0
@@ -0,0 +1,56 @@
1+module 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
56+end
lib/docs/scrapers/docker.rb+47−11
@@ -6,20 +6,37 @@ module Docs · 5 unmodified lines
66 code: 'https://github.com/docker/docker'
77 }
88
9− html_filters.push 'docker/entries', 'docker/clean_html'
10−
11− options[:container] = '#docs'
129 options[:trailing_slash] = true
1310
14− options[:only_patterns] = [
15− /\Aengine\//,
16− /\Acompose\//,
17− /\Amachine\//,
18− /\Aswarm\//
19− ]
20− options[:skip] = %w(swarm/scheduler/)
11+ options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
12+
13+ options[:skip] = %w(
14+ swarm/scheduler/
15+ swarm/swarm_at_scale/
16+ swarm/reference/
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+
2135 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/'
2340 }
2441
2542 options[:attribution] = <<-HTML
@@ -29,14 +46,33 @@ module Docs · 3 unmodified lines
2946 Docker, Inc. and other parties may also have trademark rights in other terms used herein.
3047 HTML
3148
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+
3258 version '1.11' do
3359 self.release = '1.11'
3460 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\//
3566 end
3667
3768 version '1.10' do
3869 self.release = '1.10'
3970 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\//
4076 end
4177 end
4278 end