Skip to content

Commit ee6b195

Browse files
authored
Add Composer (#879)
Add Composer Co-authored-by: Jasper van Merle <[email protected]>
2 parents f580152 + ce5f182 commit ee6b195

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ credits = [
186186
'2009-2018 Jeremy Ashkenas',
187187
'MIT',
188188
'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE'
189+
], [
190+
'Composer',
191+
'Nils Adermann, Jordi Boggiano',
192+
'MIT',
193+
'https://raw.githubusercontent.com/composer/composer/master/LICENSE'
189194
], [
190195
'Cordova',
191196
'2012-2018 The Apache Software Foundation',
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Docs
2+
class Composer
3+
class CleanHtmlFilter < Filter
4+
def call
5+
# Remove unneeded elements
6+
css('#searchbar, .toc, .fork-and-edit, .anchor').remove
7+
8+
# Fix the home page titles
9+
if subpath == ''
10+
css('h1').each do |node|
11+
node.name = 'h2'
12+
end
13+
14+
# Add a main title before the first subtitle
15+
at_css('h2').before('<h1>Composer</h1>')
16+
end
17+
18+
# Code blocks
19+
css('pre').each do |node|
20+
code = node.at_css('code[class]')
21+
22+
unless code.nil?
23+
node['data-language'] = 'javascript' if code['class'].include?('javascript')
24+
node['data-language'] = 'php' if code['class'].include?('php')
25+
end
26+
27+
node.content = node.content.strip
28+
node.remove_attribute('class')
29+
end
30+
31+
doc
32+
end
33+
end
34+
end
35+
end

lib/docs/filters/composer/entries.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module Docs
2+
class Composer
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
title = at_css('h1').content
6+
title = "#{Integer(subpath[1]) + 1}. #{title}" if type == 'Book'
7+
title
8+
end
9+
10+
def get_type
11+
return 'Articles' if subpath.start_with?('articles/')
12+
'Book'
13+
end
14+
15+
def additional_entries
16+
entries = []
17+
18+
if subpath == '04-schema.md' # JSON Schema
19+
css('h3').each do |node|
20+
name = node.content.strip
21+
name.remove!(' (root-only)')
22+
entries << [name, node['id'], 'JSON Schema']
23+
end
24+
end
25+
26+
if subpath == '06-config.md' # Composer config
27+
css('h2').each do |node|
28+
entries << [node.content.strip, node['id'], 'Configuration Options']
29+
end
30+
end
31+
32+
entries
33+
end
34+
end
35+
end
36+
end

lib/docs/scrapers/composer.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Docs
2+
class Composer < UrlScraper
3+
self.type = 'simple'
4+
self.release = '1.9.0'
5+
self.base_url = 'https://getcomposer.org/doc/'
6+
self.links = {
7+
home: 'https://getcomposer.org',
8+
code: 'https://github.com/composer/composer'
9+
}
10+
11+
html_filters.push 'composer/clean_html', 'composer/entries'
12+
13+
options[:container] = '#main'
14+
15+
options[:skip_patterns] = [
16+
/^faqs/
17+
]
18+
19+
options[:attribution] = <<-HTML
20+
&copy; Nils Adermann, Jordi Boggiano<br>
21+
Licensed under the MIT License.
22+
HTML
23+
24+
def get_latest_version(opts)
25+
get_latest_github_release('composer', 'composer', opts)
26+
end
27+
end
28+
end

public/icons/docs/composer/16.png

1.43 KB
Loading
3.52 KB
Loading

public/icons/docs/composer/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/composer/getcomposer.org/blob/master/web/img/logo-composer-transparent.png

0 commit comments

Comments
 (0)