Skip to content

Commit d4d1b37

Browse files
committed
Update Docker documentation (1.13)
1 parent 4e41ed9 commit d4d1b37

4 files changed

Lines changed: 73 additions & 26 deletions

File tree

assets/javascripts/views/pages/simple.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ app.views.CoffeescriptPage =
2020
app.views.CordovaPage =
2121
app.views.CrystalPage =
2222
app.views.D3Page =
23+
app.views.DockerPage =
2324
app.views.DrupalPage =
2425
app.views.ElixirPage =
2526
app.views.EmberPage =

lib/docs/filters/docker/clean_html.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,23 @@ def call
1111

1212
at_css('h2').name = 'h1' unless at_css('h1')
1313

14-
css('.anchorLink').remove
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
1519

1620
css('pre').each do |node|
1721
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
1831
end
1932

2033
doc

lib/docs/filters/docker/entries.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
module Docs
22
class Docker
33
class EntriesFilter < Docs::EntriesFilter
4+
NAME_BY_SUBPATH = {
5+
'engine/' => 'Engine',
6+
'compose/' => 'Compose',
7+
'machine/' => 'Machine'
8+
}
9+
410
def get_name
5-
return 'Engine' if subpath == 'engine/'
11+
return NAME_BY_SUBPATH[subpath] if NAME_BY_SUBPATH[subpath]
12+
return at_css('h1').content unless nav_link
613

714
name = nav_link.content.strip
815
name.capitalize! if name == 'exoscale'
16+
name.remove! ' (base command)'
917

1018
if name =~ /\A[a-z\-\s]+\z/
11-
name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
12-
name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
19+
name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
1320
name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
1421
else
1522
name << " (#{product})" if name !~ /#{product}/i
@@ -18,18 +25,30 @@ def get_name
1825
name
1926
end
2027

28+
TYPE_BY_SUBPATH = {
29+
'engine/' => 'Engine',
30+
'compose/' => 'Compose',
31+
'machine/' => 'Machine'
32+
}
33+
2134
def get_type
22-
return 'Engine' if subpath == 'engine/'
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/
2343

24-
type = nav_link.ancestors('.menu-open').to_a.reverse.to_a[0..1].map do |node|
25-
node.at_css('> a').content.strip
26-
end.join(': ')
44+
leaves = nav_link.ancestors('li.leaf').reverse
45+
return product if leaves.length <= 2
2746

28-
type = self.name if type.empty?
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

lib/docs/scrapers/docker.rb

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,39 @@ class Docker < UrlScraper
99
options[:trailing_slash] = true
1010

1111
options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
12-
12+
options[:skip_patterns] = [/\Aengine\/api\/v/, /\Aengine\/installation/]
1313
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/
14+
/
2115
engine/userguide/
22-
engine/extend/
2316
engine/examples/
2417
engine/reference/
2518
engine/reference/api/
26-
engine/security/
27-
engine/security/trust/
19+
engine/reference/api/docker_remote_api_v1.24/
2820
engine/getstarted/linux_install_help/
2921
machine/reference/
3022
machine/drivers/
3123
machine/examples/
3224
compose/reference/
33-
) # index pages
25+
)
26+
27+
options[:fix_urls] = ->(url) do
28+
url.sub! %r{\.md/?(?=#|\z)}, '/'
29+
url.sub! '/index/', '/'
30+
url
31+
end
3432

3533
options[:replace_paths] = {
36-
'engine/installation/ubuntulinux/' => 'engine/installation/linux/ubuntulinux/',
3734
'engine/userguide/networking/dockernetworks/' => 'engine/userguide/networking/',
35+
'engine/userguide/dockervolumes/' => 'engine/tutorials/dockervolumes/',
3836
'engine/reference/logging/overview/' => 'engine/admin/logging/overview/',
39-
'engine/userguide/dockervolumes/' => 'engine/tutorials/dockervolumes/'
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/'
4045
}
4146

4247
options[:attribution] = <<-HTML
@@ -46,9 +51,18 @@ class Docker < UrlScraper
4651
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
4752
HTML
4853

54+
version '1.13' do
55+
self.release = '1.13'
56+
self.base_url = 'https://docs.docker.com/'
57+
58+
html_filters.push 'docker/entries', 'docker/clean_html'
59+
60+
options[:container] = '.container-fluid .row'
61+
end
62+
4963
version '1.12' do
5064
self.release = '1.12'
51-
self.base_url = 'https://docs.docker.com/'
65+
# self.base_url = 'https://docs.docker.com/'
5266

5367
html_filters.push 'docker/entries', 'docker/clean_html'
5468

0 commit comments

Comments
 (0)