Add Composer (#879)

Add Composer

Co-authored-by: Jasper van Merle <jaspervmerle@gmail.com>
pull/1055/head
Jasper van Merle 6 years ago committed by GitHub
commit ee6b195bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -186,6 +186,11 @@ credits = [
'2009-2018 Jeremy Ashkenas',
'MIT',
'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE'
], [
'Composer',
'Nils Adermann, Jordi Boggiano',
'MIT',
'https://raw.githubusercontent.com/composer/composer/master/LICENSE'
], [
'Cordova',
'2012-2018 The Apache Software Foundation',

@ -0,0 +1,35 @@
module Docs
class Composer
class CleanHtmlFilter < Filter
def call
# Remove unneeded elements
css('#searchbar, .toc, .fork-and-edit, .anchor').remove
# Fix the home page titles
if subpath == ''
css('h1').each do |node|
node.name = 'h2'
end
# Add a main title before the first subtitle
at_css('h2').before('<h1>Composer</h1>')
end
# Code blocks
css('pre').each do |node|
code = node.at_css('code[class]')
unless code.nil?
node['data-language'] = 'javascript' if code['class'].include?('javascript')
node['data-language'] = 'php' if code['class'].include?('php')
end
node.content = node.content.strip
node.remove_attribute('class')
end
doc
end
end
end
end

@ -0,0 +1,36 @@
module Docs
class Composer
class EntriesFilter < Docs::EntriesFilter
def get_name
title = at_css('h1').content
title = "#{Integer(subpath[1]) + 1}. #{title}" if type == 'Book'
title
end
def get_type
return 'Articles' if subpath.start_with?('articles/')
'Book'
end
def additional_entries
entries = []
if subpath == '04-schema.md' # JSON Schema
css('h3').each do |node|
name = node.content.strip
name.remove!(' (root-only)')
entries << [name, node['id'], 'JSON Schema']
end
end
if subpath == '06-config.md' # Composer config
css('h2').each do |node|
entries << [node.content.strip, node['id'], 'Configuration Options']
end
end
entries
end
end
end
end

@ -0,0 +1,28 @@
module Docs
class Composer < UrlScraper
self.type = 'simple'
self.release = '1.9.0'
self.base_url = 'https://getcomposer.org/doc/'
self.links = {
home: 'https://getcomposer.org',
code: 'https://github.com/composer/composer'
}
html_filters.push 'composer/clean_html', 'composer/entries'
options[:container] = '#main'
options[:skip_patterns] = [
/^faqs/
]
options[:attribution] = <<-HTML
&copy; Nils Adermann, Jordi Boggiano<br>
Licensed under the MIT License.
HTML
def get_latest_version(opts)
get_latest_github_release('composer', 'composer', opts)
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

@ -0,0 +1 @@
https://github.com/composer/getcomposer.org/blob/master/web/img/logo-composer-transparent.png
Loading…
Cancel
Save