Finish Docker scraper

pull/417/merge
Thibaut Courouble 9 years ago
parent 457439f35a
commit e92d0e15e7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 122 KiB

@ -7,7 +7,7 @@ class app.collections.Types extends app.Collection
(result[@_groupFor(type)] ||= []).push(type)
result.filter (e) -> e.length > 0
GUIDES_RGX = /(^|[\s\(])(guides?|tutorials?|reference|book|getting\ started|manual)($|[\s\):])/i
GUIDES_RGX = /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual)($|[\):])/i
_groupFor: (type) ->
if GUIDES_RGX.test(type.name)

@ -1,5 +1,8 @@
[
[
"2016-08-07",
"New documentation: <a href=\"/docker/\">Docker</a>"
], [
"2016-07-31",
"New documentations: <a href=\"/bootstrap~3/\">Bootstrap 3</a> and <a href=\"/bootstrap~4/\">Bootstrap 4</a>"
], [

@ -179,6 +179,11 @@ credits = [
'Django Software Foundation and individual contributors',
'BSD',
'https://raw.githubusercontent.com/django/django/master/LICENSE'
], [
'Docker',
'2013-2016 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',
'Apache',
'https://raw.githubusercontent.com/docker/docker/master/LICENSE'
], [
'Dojo',
'2005-2015 The Dojo Foundation',

@ -116,6 +116,7 @@
._icon-socketio:before { background-position: -2rem -6rem; }
._icon-modernizr:before { background-position: -3rem -6rem; }
._icon-bower:before { background-position: -4rem -6rem; }
._icon-docker:before { background-position: -1rem -7rem; }
._icon-cakephp:before { background-position: -2rem -7rem; }
._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; }
._icon-clojure:before { background-position: -4rem -7rem; }

@ -3,14 +3,13 @@ module Docs
class CleanHtmlFilter < Filter
def call
if root_page?
@doc = at_css('.tabs-content')
else
@doc = at_css('#content')
doc.inner_html = "<h1>Docker Documentation</h1>"
return doc
end
if not at_css('h1')
at_css('h2').name = 'h1'
end
@doc = at_css('#content')
at_css('h2').name = 'h1' unless at_css('h1')
css('pre').each do |node|
node.content = node.content

@ -2,20 +2,56 @@ module Docs
class Docker
class EntriesFilter < Docs::EntriesFilter
def get_name
title = at_css('h1').content
name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
name.capitalize! if name == 'exoscale'
title = title.split(' — ').first
title = title.split(' - ').first
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-machine ' if subpath =~ /machine\/reference\/./
name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
else
name << " (#{product})" if name !~ /#{product}/i
end
title
name
end
def get_type
if slug.count('/') == 1 or slug.count('/') == 2
slug.split('/').first.capitalize
else
slug.split('/')[0...-1].map(&:capitalize).join('/').gsub(/\-|\_/, ' ')
unless nav_link
return 'Engine: User guide' if subpath.start_with?('engine/userguide')
return 'Engine: Secure' if subpath.start_with?('engine/security')
return 'Engine' if subpath == 'engine/'
end
type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|
node.at_css('> button').content.strip
end.join(': ')
type.remove! %r{\ADocker }
type.remove! %r{ Engine}
type.sub! %r{Command[\-\s]line reference}i, 'CLI'
type = 'Engine: Reference' if type == 'Engine: reference'
type
end
def nav_link
return @nav_link if defined?(@nav_link)
@nav_link = at_css('#multiple .active')
unless @nav_link
link = at_css('#content li a')
return unless link
link = at_css("#multiple a[href='#{link['href']}']")
return unless link
@nav_link = link.ancestors('article').first.at_css('button')
end
@nav_link
end
def product
@product ||= subpath.split('/').first.capitalize
end
end
end

@ -1,16 +1,14 @@
module Docs
class Docker < UrlScraper
self.name = 'Docker'
self.slug = 'docker'
self.type = 'docker'
self.links = {
home: 'https://docker.com/',
code: 'https://github.com/docker/docker'
}
html_filters.push 'docker/clean_html', 'docker/entries'
html_filters.push 'docker/entries', 'docker/clean_html'
options[:container] = '#docs'
options[:trailing_slash] = true
options[:only_patterns] = [
@ -19,14 +17,16 @@ module Docs
/\Amachine\//,
/\Aswarm\//
]
options[:skip] = [
"engine/installation/ubuntulinux/" # invalid document
]
options[:skip] = %w(swarm/scheduler/)
options[:replace_paths] = {
'engine/installation/ubuntulinux/' => 'engine/installation/linux/ubuntulinux/'
}
options[:attribution] = <<-HTML
&copy; 2016 Docker Inc.<br>
Licensed under the Apache 2 License.
&copy; 2013&ndash;2016 Docker, Inc.<br>
Licensed under the Apache License, Version 2.0.<br>
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
HTML
version '1.11' do

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Loading…
Cancel
Save