Skip to content

Commit b98ab15

Browse files
committed
Add Composer
1 parent 24abe4c commit b98ab15

File tree

8 files changed

+98
-0
lines changed

8 files changed

+98
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ credits = [
190190
'2009-2018 Jeremy Ashkenas',
191191
'MIT',
192192
'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE'
193+
], [
194+
'Composer',
195+
'2012-2018 Nils Adermann, Jordi Boggiano',
196+
'MIT',
197+
'https://github.com/composer/composer/blob/master/LICENSE'
193198
], [
194199
'Cordova',
195200
'2012-2017 The Apache Software Foundation',

assets/stylesheets/pages/_simple.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
._bower,
2222
._chai,
2323
._codeceptjs,
24+
._composer,
2425
._docker,
2526
._electron,
2627
._fish,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
# Code blocks
9+
css('pre').each do |node|
10+
code = node.at_css('code[class]')
11+
12+
unless code.nil?
13+
node['data-language'] = 'javascript' if code['class'].include?('javascript')
14+
node['data-language'] = 'php' if code['class'].include?('php')
15+
end
16+
17+
node.content = node.content.strip
18+
node.remove_attribute('class')
19+
end
20+
21+
doc
22+
end
23+
end
24+
end
25+
end

lib/docs/filters/composer/entries.rb

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

lib/docs/scrapers/composer.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module Docs
2+
class Composer < UrlScraper
3+
self.name = 'Composer'
4+
self.type = 'composer'
5+
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+
self.release = '1.7.2'
14+
self.base_url = 'https://getcomposer.org/doc/'
15+
16+
options[:container] = '#main'
17+
18+
options[:skip_patterns] = [
19+
/^faqs/
20+
]
21+
22+
options[:attribution] = <<-HTML
23+
&copy; Nils Adermann, Jordi Boggiano<br>
24+
Licensed under the MIT License.
25+
HTML
26+
end
27+
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)