History

Add Immutable.js documentation

Closes #513.

Thibaut Courouble committed 9 years ago

Commit fd151681 parent a5b44b413 files · +137 −-4Browse files

Unified · Split

13 files
  1. assets/images/docs.png +0 −0
  2. assets/images/docs@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/javascripts/views/pages/simple.coffee +1 −0
  6. assets/stylesheets/global/_icons.scss +1 −0
  7. assets/stylesheets/pages/_simple.scss +1 −0
  8. lib/docs/filters/immutable/clean_html.rb +48 −0
  9. lib/docs/filters/immutable/entries.rb +23 −0
  10. lib/docs/scrapers/immutable.rb +58 −0
  11. public/icons/docs/immutable/16.png +0 −0
  12. public/icons/docs/immutable/16@2x.png +0 −0
  13. public/icons/docs/immutable/SOURCE +1 −0
assets/images/docs.png+0−0

Binary file not shown.

assets/images/docs@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
1[1[
2 [2 [
3 "2016-11-20",
4 "New documentation: <a href=\"/immutable/\">Immutable.js</a>"
5 ], [
3 "2016-10-10",6 "2016-10-10",
4 "New documentations: <a href=\"/scikit_learn/\">scikit-learn</a> and <a href=\"/statsmodels/\">Statsmodels</a>"7 "New documentations: <a href=\"/scikit_learn/\">scikit-learn</a> and <a href=\"/statsmodels/\">Statsmodels</a>"
5 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -254,6 +254,11 @@ credits = [ · 253 unmodified lines
254 '2005-2016 Haxe Foundation',254 '2005-2016 Haxe Foundation',
255 'MIT',255 'MIT',
256 'http://haxe.org/foundation/open-source.html'256 'http://haxe.org/foundation/open-source.html'
257 ], [
258 'Immutable.js',
259 '2014-2016 Facebook, Inc.',
260 'BSD',
261 'https://raw.githubusercontent.com/facebook/immutable-js/master/LICENSE'
257 ], [262 ], [
258 'InfluxData',263 'InfluxData',
259 '2015 InfluxData, Inc.',264 '2015 InfluxData, Inc.',
assets/javascripts/views/pages/simple.coffee+1−0
@@ -22,6 +22,7 @@ app.views.ElixirPage = · 21 unmodified lines
22app.views.EmberPage =22app.views.EmberPage =
23app.views.ExpressPage =23app.views.ExpressPage =
24app.views.GoPage =24app.views.GoPage =
25app.views.ImmutablePage =
25app.views.InfluxdataPage =26app.views.InfluxdataPage =
26app.views.KnockoutPage =27app.views.KnockoutPage =
27app.views.KotlinPage =28app.views.KotlinPage =
assets/stylesheets/global/_icons.scss+1−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
72._icon-angularjs:before { background-position: -9rem -1rem; }72._icon-angularjs:before { background-position: -9rem -1rem; }
73._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; }73._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; }
74._icon-ember:before { background-position: -1rem -2rem; }74._icon-ember:before { background-position: -1rem -2rem; }
75._icon-immutable:before { background-position: -3rem -2rem; @extend %darkIconFix !optional; }
75._icon-jqueryui:before { background-position: -4rem -2rem; }76._icon-jqueryui:before { background-position: -4rem -2rem; }
76._icon-jquerymobile:before { background-position: -5rem -2rem; }77._icon-jquerymobile:before { background-position: -5rem -2rem; }
77._icon-lodash:before { background-position: -6rem -2rem; }78._icon-lodash:before { background-position: -6rem -2rem; }
assets/stylesheets/pages/_simple.scss+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
25._gnu,25._gnu,
26._grunt,26._grunt,
27._haxe,27._haxe,
28._immutable,
28._influxdata,29._influxdata,
29._less,30._less,
30._lodash,31._lodash,
lib/docs/filters/immutable/clean_html.rb+48−0
@@ -0,0 +1,48 @@
1module Docs
2 class Immutable
3 class CleanHtmlFilter < Filter
4 def call
5 css('section', 'span', 'div[data-reactid]').each do |node|
6 node.before(node.children).remove
7 end
8
9 css('.codeBlock').each do |node|
10 node.name = 'pre'
11 node.content = node.content
12 node['data-language'] = 'js'
13 end
14
15 css('*[data-reactid]').remove_attr('data-reactid')
16 css('a[target]').remove_attr('target')
17
18 css('a[href^="#"]').each do |node|
19 node['href'] = node['href'].sub(/\A#\//, '#').gsub('/', '.').downcase
20 end
21
22 type = type_id = nil
23 css('*').each do |node|
24 if node.name == 'h1'
25 node['id'] = type_id = node.content.strip.downcase
26 type = node.content.strip
27 elsif node.name == 'h3'
28 node['id'] = node.content.strip.downcase
29 node['id'] = node['id'].remove('()') unless node['id'] == "#{type_id}()"
30
31 unless node['id'].start_with?(type_id)
32 node.content = "#{type}##{node.content}"
33 node['id'] = "#{type_id}.#{node['id']}" unless node['id'].start_with?("#{type_id}.")
34 end
35 end
36 end
37
38 css('h4.groupTitle').each do |node|
39 node.name = 'h2'
40 end
41
42 css('*[class]').remove_attr('class')
43
44 doc
45 end
46 end
47 end
48end
lib/docs/filters/immutable/entries.rb+23−0
@@ -0,0 +1,23 @@
1module Docs
2 class Immutable
3 class EntriesFilter < Docs::EntriesFilter
4 def additional_entries
5 entries = []
6 type = nil
7
8 css('*').each do |node|
9 if node.name == 'h1'
10 name = node.content
11 type = node.content.split('.').first
12 entries << [name, node['id'], type]
13 elsif node.name == 'h3'
14 name = node.content
15 entries << [name, node['id'], type]
16 end
17 end
18
19 entries
20 end
21 end
22 end
23end
lib/docs/scrapers/immutable.rb+58−0
@@ -0,0 +1,58 @@
1module Docs
2 class Immutable < UrlScraper
3 self.name = 'Immutable.js'
4 self.slug = 'immutable'
5 self.type = 'immutable'
6 self.release = '3.8.1'
7 self.base_url = 'https://facebook.github.io/immutable-js/docs/'
8 self.links = {
9 home: 'https://facebook.github.io/immutable-js/',
10 code: 'https://github.com/facebook/immutable-js'
11 }
12
13 html_filters.push 'immutable/clean_html', 'immutable/entries', 'title'
14
15 options[:skip_links] = true
16 options[:container] = '.docContents'
17 options[:root_title] = 'Immutable.js'
18
19 options[:attribution] = <<-HTML
20 &copy; 2014&ndash;2015 Facebook, Inc.<br>
21 Licensed under the 3-clause BSD License.
22 HTML
23
24 stub '' do
25 capybara = load_capybara_selenium
26 capybara.app_host = 'https://facebook.github.io'
27 capybara.visit(URL.parse(self.base_url).path)
28 capybara.execute_script <<-JS
29 var content, event, links, link;
30
31 event = document.createEvent('Event');
32 event.initEvent('hashchange', false, false);
33
34 content = document.querySelector('.docContents section').cloneNode(true);
35 links = Array.prototype.slice.call(document.querySelectorAll('.sideBar .scrollContent a'));
36
37 while (link = links.shift()) {
38 if (!document.body.contains(link)) {
39 document.body.appendChild(link);
40 }
41
42 link.click();
43 dispatchEvent(event);
44 content.innerHTML += document.querySelector('.docContents').innerHTML;
45
46 document.querySelectorAll('.sideBar .scrollContent .groupTitle').forEach(function(el) {
47 if (el.textContent == 'Types') {
48 Array.prototype.unshift.apply(links, Array.prototype.slice.call(el.parentNode.querySelectorAll('a')));
49 }
50 });
51 }
52
53 document.querySelector('.docContents').innerHTML = content.innerHTML;
54 JS
55 capybara.html
56 end
57 end
58end
public/icons/docs/immutable/16.png+0−0

Binary file not shown.

public/icons/docs/immutable/16@2x.png+0−0

Binary file not shown.

public/icons/docs/immutable/SOURCE+1−0
@@ -0,0 +1 @@
1https://raw.githubusercontent.com/facebook/immutable-js/master/pages/src/static/favicon.png