History

Add RequireJS documentation

Thibaut committed 12 years ago

Commit ec0e9f01 parent 91862db14 files · +115 −-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/requirejs.coffee +11 −0
  6. assets/stylesheets/application.css.scss +1 −0
  7. assets/stylesheets/global/_icons.scss +1 −0
  8. assets/stylesheets/pages/_requirejs.scss +10 −0
  9. lib/docs/filters/requirejs/clean_html.rb +22 −0
  10. lib/docs/filters/requirejs/entries.rb +35 −0
  11. lib/docs/scrapers/requirejs.rb +29 −0
  12. public/icons/docs/requirejs/16.png +0 −0
  13. public/icons/docs/requirejs/16@2x.png +0 −0
  14. public/icons/docs/requirejs/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
@@ -210,6 +210,11 @@ credits = [ · 209 unmodified lines
210 '2009-2014 Salvatore Sanfilippo',210 '2009-2014 Salvatore Sanfilippo',
211 'CC BY-SA',211 'CC BY-SA',
212 'http://creativecommons.org/licenses/by-sa/4.0/'212 'http://creativecommons.org/licenses/by-sa/4.0/'
213 ], [
214 'RequireJS',
215 '2010-2014 The Dojo Foundation',
216 'MIT',
217 'https://raw.githubusercontent.com/jrburke/requirejs/master/LICENSE'
213 ], [218 ], [
214 'Ruby',219 'Ruby',
215 '1993-2014 Yukihiro Matsumoto',220 '1993-2014 Yukihiro Matsumoto',
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 [ 1402704000000, # June 14, 201427 [ 1402790400000, # June 15, 2014
28 """ New <a href="/requirejs/">RequireJS</a> documentation """,
29 ], [
30 1402704000000, # June 14, 2014
28 """ New <a href="/haskell/">Haskell</a> documentation """,31 """ New <a href="/haskell/">Haskell</a> documentation """,
29 ], [32 ], [
30 1400976000000, # May 25, 201433 1400976000000, # May 25, 2014
assets/javascripts/views/pages/requirejs.coffee+11−0
@@ -0,0 +1,11 @@
1#= require views/pages/base
2
3class app.views.RequirejsPage extends app.views.BasePage
4 afterRender: ->
5 for el in @findAllByTag 'pre'
6 language = if el.textContent.match(/^\s*</)
7 'markup'
8 else
9 'javascript'
10 @highlightCode el, language
11 return
assets/stylesheets/application.css.scss+1−0
@@ -51,6 +51,7 @@ · 50 unmodified lines
51 'pages/postgres',51 'pages/postgres',
52 'pages/rdoc',52 'pages/rdoc',
53 'pages/redis',53 'pages/redis',
54 'pages/requirejs',
54 'pages/rfc',55 'pages/rfc',
55 'pages/sphinx',56 'pages/sphinx',
56 'pages/underscore',57 'pages/underscore',
assets/stylesheets/global/_icons.scss+1−0
@@ -58,3 +58,4 @@ · 57 unmodified lines
58._icon-maxcdn:before { background-position: -4rem -8rem; }58._icon-maxcdn:before { background-position: -4rem -8rem; }
59._icon-laravel:before { background-position: 0 -9rem; }59._icon-laravel:before { background-position: 0 -9rem; }
60._icon-haskell:before { background-position: -1rem -9rem; }60._icon-haskell:before { background-position: -1rem -9rem; }
61._icon-requirejs:before { background-position: -2rem -9rem; }
assets/stylesheets/pages/_requirejs.scss+10−0
@@ -0,0 +1,10 @@
1._requirejs {
2 padding-left: 1rem;
3
4 h1, h2, h3, ul.index { margin-left: -1rem; }
5 h2 { @extend %block-heading; }
6 h3 { @extend %block-label, %label-blue; }
7 h4 { font-size: 1em; }
8
9 ul.index ul { margin: .5em 0; }
10}
lib/docs/filters/requirejs/clean_html.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Requirejs
3 class CleanHtmlFilter < Filter
4 def call
5 css('.sectionMark', '.hbox > .sect').remove
6 css('h1 + .note').remove if root_page?
7
8 css('.section', 'pre > code').each do |node|
9 node.before(node.children).remove
10 end
11
12 css('h2', 'h3', 'h4').each do |node|
13 next unless link = node.at_css('a[name]')
14 node['id'] = link['name']
15 link.before(link.children).remove
16 end
17
18 doc
19 end
20 end
21 end
22end
lib/docs/filters/requirejs/entries.rb+35−0
@@ -0,0 +1,35 @@
1module Docs
2 class Requirejs
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 at_css('h1').content
6 end
7
8 def get_type
9 'Guides'
10 end
11
12 def additional_entries
13 return [] unless root_page?
14
15 entries = []
16 type = nil
17
18 css('*').each do |node|
19 if node.name == 'h2'
20 type = node.content
21 elsif node.name == 'h3' || node.name == 'h4'
22 entries << [node.content, node['id'], type]
23 end
24 end
25
26 css('p[id^="config-"]').each do |node|
27 next if node['id'].include?('note')
28 entries << [node.at_css('strong').content, node['id'], 'Configuration Options']
29 end
30
31 entries
32 end
33 end
34 end
35end
lib/docs/scrapers/requirejs.rb+29−0
@@ -0,0 +1,29 @@
1module Docs
2 class Requirejs < UrlScraper
3 self.name = 'RequireJS'
4 self.type = 'requirejs'
5 self.version = '2.1.4'
6 self.base_url = 'http://requirejs.org/docs/'
7 self.root_path = 'api.html'
8 self.initial_paths = %w(
9 optimization.html
10 jquery.html
11 node.html
12 dojo.html
13 commonjs.html
14 plugins.html
15 why.html
16 whyamd.html)
17
18 html_filters.push 'requirejs/clean_html', 'requirejs/entries'
19
20 options[:container] = '#content'
21 options[:follow_links] = false
22 options[:only] = self.initial_paths
23
24 options[:attribution] = <<-HTML
25 &copy; 2010&ndash;2014 The Dojo Foundation<br>
26 Licensed under the MIT License.
27 HTML
28 end
29end
public/icons/docs/requirejs/16.png+0−0

Binary file not shown.

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

Binary file not shown.

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