History

Add D3.js documentation

Thibaut committed 12 years ago

Commit 8e469d31 parent 7fa7c8f14 files · +127 −-3Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  4. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  5. assets/javascripts/views/pages/d3.coffee +6 −0
  6. assets/stylesheets/application.css.scss +1 −0
  7. assets/stylesheets/global/_icons.scss +1 −0
  8. assets/stylesheets/pages/_d3.scss +6 −0
  9. lib/docs/filters/d3/clean_html.rb +42 −0
  10. lib/docs/filters/d3/entries.rb +22 −0
  11. lib/docs/scrapers/d3.rb +43 −0
  12. public/icons/docs/d3/16.png +0 −0
  13. public/icons/docs/d3/16@2x.png +0 −0
  14. public/icons/docs/d3/SOURCE +1 −0
assets/images/icons.png+0−0

Binary file not shown.

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

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -93,6 +93,11 @@ credits = [ · 92 unmodified lines
93 '2005-2013 Mozilla Developer Network and individual contributors',93 '2005-2013 Mozilla Developer Network and individual contributors',
94 'CC BY-SA',94 'CC BY-SA',
95 'http://creativecommons.org/licenses/by-sa/2.5/'95 'http://creativecommons.org/licenses/by-sa/2.5/'
96 ], [
97 'D3.js',
98 '2014 Michael Bostock',
99 'BSD',
100 'https://raw.github.com/mbostock/d3/master/LICENSE'
96 ], [101 ], [
97 'Ember.js',102 'Ember.js',
98 '2014 Yehuda Katz, Tom Dale and Ember.js contributors',103 '2014 Yehuda Katz, Tom Dale and Ember.js contributors',
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -24,7 +24,10 @@ newsItem = (date, news) -> · 23 unmodified lines
24 result24 result
25 25
26app.news = [26app.news = [
27 [ 1390003200000, # January 18, 201327 [ 1390089600000, # January 19, 2013
28 """ New <a href="/d3/">D3.js</a> documentation """,
29 ], [
30 1390003200000, # January 18, 2013
28 """ DevDocs is now available as a <a href="https://marketplace.firefox.com/app/devdocs/">Firefox web app</a> (currently requires Aurora). """,31 """ DevDocs is now available as a <a href="https://marketplace.firefox.com/app/devdocs/">Firefox web app</a> (currently requires Aurora). """,
29 ], [32 ], [
30 1389484800000, # January 12, 201333 1389484800000, # January 12, 2013
assets/javascripts/views/pages/d3.coffee+6−0
@@ -0,0 +1,6 @@
1#= require views/pages/base
2
3class app.views.D3Page extends app.views.BasePage
4 afterRender: ->
5 @highlightCode @findAll('.highlight > pre'), 'javascript'
6 return
assets/stylesheets/application.css.scss+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
29 29
30@import 'pages/angular',30@import 'pages/angular',
31 'pages/coffeescript',31 'pages/coffeescript',
32 'pages/d3',
32 'pages/ember',33 'pages/ember',
33 'pages/jquery',34 'pages/jquery',
34 'pages/git',35 'pages/git',
assets/stylesheets/global/_icons.scss+1−0
@@ -45,3 +45,4 @@ · 44 unmodified lines
45._icon-git:before { background-position: -1rem -6rem; }45._icon-git:before { background-position: -1rem -6rem; }
46._icon-redis:before { background-position: -2rem -6rem; }46._icon-redis:before { background-position: -2rem -6rem; }
47._icon-postgresql:before { background-position: -3rem -6rem; }47._icon-postgresql:before { background-position: -3rem -6rem; }
48._icon-d3:before { background-position: -4rem -6rem; }
assets/stylesheets/pages/_d3.scss+6−0
@@ -0,0 +1,6 @@
1._d3 {
2 > h2 { @extend %block-heading; }
3 > h3, > h4 { font-size: 1rem; }
4 > h6 { @extend %block-label, %label-blue; }
5 code { @extend %label; }
6}
lib/docs/filters/d3/clean_html.rb+42−0
@@ -0,0 +1,42 @@
1module Docs
2 class D3
3 class CleanHtmlFilter < Filter
4 def call
5 css('#gollum-footer', '.markdown-body > blockquote:first-child', '.anchor').remove
6
7 # Replace #head with <h1>
8 css('#head > h1').each do |node|
9 node.parent.before(node).remove
10 node.content = 'D3.js' if root_page?
11 end
12
13 # Move content to the root-level
14 css('#wiki-content').each do |node|
15 node.before(node.at_css('.markdown-body').children).remove
16 end
17
18 # Remove links inside <h2>
19 css('h2 > a').each do |node|
20 node.before(node.children).remove
21 end
22
23 # Make headings for function definitions and add "id" attributes
24 css('p > a:first-child').each do |node|
25 next unless node['name'] || node.content == '#'
26 parent = node.parent
27 parent.name = 'h6'
28 parent['id'] = (node['name'] || node['href'].sub(/\A.+#/, '')).sub('wiki-', '')
29 parent.css('a[name]').remove
30 node.remove
31 end
32
33 # Remove code highlighting
34 css('.highlight > pre').each do |node|
35 node.content = node.content
36 end
37
38 doc
39 end
40 end
41 end
42end
lib/docs/filters/d3/entries.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class D3
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 at_css('h1').content
6 end
7
8 def get_type
9 name
10 end
11
12 def additional_entries
13 css('h6[id]').inject [] do |entries, node|
14 name = node.content
15 name.sub! %r{\(.*\z}, ''
16 entries << [name, node['id']] unless name == entries.last.try(:first)
17 entries
18 end
19 end
20 end
21 end
22end
lib/docs/scrapers/d3.rb+43−0
@@ -0,0 +1,43 @@
1module Docs
2 class D3 < UrlScraper
3 self.name = 'D3.js'
4 self.slug = 'd3'
5 self.type = 'd3'
6 self.version = '3.4.1'
7 self.base_url = 'https://github.com/mbostock/d3/wiki/'
8 self.root_path = 'API-Reference'
9
10 html_filters.push 'd3/clean_html', 'd3/entries'
11
12 options[:container] = '#wiki-wrapper'
13
14 options[:only] = %w(
15 Selections
16 Transitions
17 Arrays
18 Math
19 Requests
20 Formatting
21 CSV
22 Localization
23 Colors
24 Namespaces
25 Internals)
26
27 options[:only_patterns] = [
28 /\-Scales\z/,
29 /\ASVG\-/,
30 /\ATime\-/,
31 /\-Layout\z/,
32 /\AGeo\-/,
33 /\-Geom\z/,
34 /\-Behavior\z/]
35
36 options[:skip_patterns] = [/\//]
37
38 options[:attribution] = <<-HTML
39 &copy; 2014 Michael Bostock<br>
40 Licensed under the BSD License.
41 HTML
42 end
43end
public/icons/docs/d3/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/d3/SOURCE+1−0
@@ -0,0 +1 @@
1http://d3js.org/