Ver Fonte

Update Docker documentation (1.13)

Thibaut Courouble há 9 anos atrás
pai
commit
d4d1b37626

+ 1 - 0
assets/javascripts/views/pages/simple.coffee

@@ -20,6 +20,7 @@ app.views.CoffeescriptPage =
 app.views.CordovaPage =
 app.views.CrystalPage =
 app.views.D3Page =
+app.views.DockerPage =
 app.views.DrupalPage =
 app.views.ElixirPage =
 app.views.EmberPage =

+ 14 - 1
lib/docs/filters/docker/clean_html.rb

@@ -11,10 +11,23 @@ module Docs
 
         at_css('h2').name = 'h1' unless at_css('h1')
 
-        css('.anchorLink').remove
+        css('.anchorLink', '.reading-time', 'hr', '> div[style*="margin-top"]:last-child').remove
+
+        css('h1 + h1').each do |node|
+          node.name = 'h2'
+        end
 
         css('pre').each do |node|
           node.content = node.content
+          node['data-language'] = node.parent['class'][/language-(\w+)/, 1] if node.parent['class']
+        end
+
+        css('div.highlighter-rouge').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('code.highlighter-rouge').each do |node|
+          node.content = node.content.gsub(/\s+/, ' ').strip
         end
 
         doc

+ 29 - 10
lib/docs/filters/docker/entries.rb

@@ -1,15 +1,22 @@
 module Docs
   class Docker
     class EntriesFilter < Docs::EntriesFilter
+      NAME_BY_SUBPATH = {
+        'engine/' => 'Engine',
+        'compose/' => 'Compose',
+        'machine/' => 'Machine'
+      }
+
       def get_name
-        return 'Engine' if subpath == 'engine/'
+        return NAME_BY_SUBPATH[subpath] if NAME_BY_SUBPATH[subpath]
+        return at_css('h1').content unless nav_link
 
         name = nav_link.content.strip
         name.capitalize! if name == 'exoscale'
+        name.remove! ' (base command)'
 
         if name =~ /\A[a-z\-\s]+\z/
-          name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
-          name.prepend 'docker-compose  ' if subpath =~ /compose\/reference\/./
+          name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
           name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
         else
           name << " (#{product})" if name !~ /#{product}/i
@@ -18,18 +25,30 @@ module Docs
         name
       end
 
+      TYPE_BY_SUBPATH = {
+        'engine/' => 'Engine',
+        'compose/' => 'Compose',
+        'machine/' => 'Machine'
+      }
+
       def get_type
-        return 'Engine' if subpath == 'engine/'
+        return TYPE_BY_SUBPATH[subpath] if TYPE_BY_SUBPATH[subpath]
+        return 'Engine: CLI'         if subpath.start_with?('engine/reference/commandline/')
+        return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')
+        return 'Engine: Security'    if subpath.start_with?('engine/security/')
+        return 'Engine: Extend'      if subpath.start_with?('engine/extend/')
+        return 'Engine: Get Started' if subpath.start_with?('engine/getstarted')
+        return 'Engine: Tutorials'   if subpath.start_with?('engine/tutorials/')
+        return product if !nav_link && subpath =~ /\A\w+\/[\w\-]+\/\z/
 
-        type = nav_link.ancestors('.menu-open').to_a.reverse.to_a[0..1].map do |node|
-          node.at_css('> a').content.strip
-        end.join(': ')
+        leaves = nav_link.ancestors('li.leaf').reverse
+        return product if leaves.length <= 2
 
-        type = self.name if type.empty?
+        type = leaves[0..1].map { |node| node.at_css('> a').content.strip }.join(': ')
         type.remove! %r{\ADocker }
-        type.remove! %r{ Engine}
+        type.remove! ' Engine'
         type.sub! %r{Command[\-\s]line reference}i, 'CLI'
-        type = 'Engine: Reference' if type == 'Engine: reference'
+        type.sub! 'CLI reference', 'CLI'
         type
       end
 

+ 29 - 15
lib/docs/scrapers/docker.rb

@@ -9,34 +9,39 @@ module Docs
     options[:trailing_slash] = true
 
     options[:only_patterns] = [/\Aengine\//, /\Acompose\//, /\Amachine\//]
-
+    options[:skip_patterns] = [/\Aengine\/api\/v/, /\Aengine\/installation/]
     options[:skip] = %w(
-      swarm/scheduler/
-      swarm/swarm_at_scale/
-      swarm/reference/
-      engine/installation/linux/
-      engine/installation/cloud/
-      engine/installation/
-      engine/tutorials/
+      /
       engine/userguide/
-      engine/extend/
       engine/examples/
       engine/reference/
       engine/reference/api/
-      engine/security/
-      engine/security/trust/
+      engine/reference/api/docker_remote_api_v1.24/
       engine/getstarted/linux_install_help/
       machine/reference/
       machine/drivers/
       machine/examples/
       compose/reference/
-    ) # index pages
+    )
+
+    options[:fix_urls] = ->(url) do
+      url.sub! %r{\.md/?(?=#|\z)}, '/'
+      url.sub! '/index/', '/'
+      url
+    end
 
     options[:replace_paths] = {
-      'engine/installation/ubuntulinux/'            => 'engine/installation/linux/ubuntulinux/',
       'engine/userguide/networking/dockernetworks/' => 'engine/userguide/networking/',
+      'engine/userguide/dockervolumes/'             => 'engine/tutorials/dockervolumes/',
       'engine/reference/logging/overview/'          => 'engine/admin/logging/overview/',
-      'engine/userguide/dockervolumes/'             => 'engine/tutorials/dockervolumes/'
+      'engine/reference/commandline/daemon/'        => 'engine/reference/commandline/dockerd/',
+      'engine/reference/commandline/'               => 'engine/reference/commandline/docker/',
+      'engine/reference/api/docker_remote_api/'     => 'engine/api/',
+      'engine/swarm/how-swarm-mode-works/'          => 'engine/swarm/how-swarm-mode-works/nodes/',
+      'engine/tutorials/dockerizing/'               => 'engine/getstarted/step_one/',
+      'engine/tutorials/usingdocker/'               => 'engine/getstarted/step_three/',
+      'engine/tutorials/dockerimages/'              => 'engine/getstarted/step_four/',
+      'engine/tutorials/dockerrepos/'               => 'engine/getstarted/step_six/'
     }
 
     options[:attribution] = <<-HTML
@@ -46,9 +51,18 @@ module Docs
       Docker, Inc. and other parties may also have trademark rights in other terms used herein.
     HTML
 
+    version '1.13' do
+      self.release = '1.13'
+      self.base_url = 'https://docs.docker.com/'
+
+      html_filters.push 'docker/entries', 'docker/clean_html'
+
+      options[:container] = '.container-fluid .row'
+    end
+
     version '1.12' do
       self.release = '1.12'
-      self.base_url = 'https://docs.docker.com/'
+      # self.base_url = 'https://docs.docker.com/'
 
       html_filters.push 'docker/entries', 'docker/clean_html'