sc-docs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +48 -0
  5. data/LICENSE +21 -0
  6. data/README.md +59 -0
  7. data/bin/sc-docs +5 -0
  8. data/lib/sc_docs.rb +3 -0
  9. data/lib/sc_docs/cli.rb +54 -0
  10. data/lib/sc_docs/docs/Buildfile +8 -0
  11. data/lib/sc_docs/docs/README +8 -0
  12. data/lib/sc_docs/docs/apps/docs/Buildfile +15 -0
  13. data/lib/sc_docs/docs/apps/docs/controllers/classes.js +27 -0
  14. data/lib/sc_docs/docs/apps/docs/controllers/search_controller.js +62 -0
  15. data/lib/sc_docs/docs/apps/docs/controllers/selected_class.js +143 -0
  16. data/lib/sc_docs/docs/apps/docs/core.js +148 -0
  17. data/lib/sc_docs/docs/apps/docs/main.js +41 -0
  18. data/lib/sc_docs/docs/apps/docs/models/class.js +63 -0
  19. data/lib/sc_docs/docs/apps/docs/models/entity.js +29 -0
  20. data/lib/sc_docs/docs/apps/docs/models/method.js +79 -0
  21. data/lib/sc_docs/docs/apps/docs/models/property.js +48 -0
  22. data/lib/sc_docs/docs/apps/docs/resources/images/method_icon.png +0 -0
  23. data/lib/sc_docs/docs/apps/docs/resources/images/property_icon.png +0 -0
  24. data/lib/sc_docs/docs/apps/docs/resources/loading.rhtml +9 -0
  25. data/lib/sc_docs/docs/apps/docs/resources/main_page.css +156 -0
  26. data/lib/sc_docs/docs/apps/docs/resources/main_page.js +91 -0
  27. data/lib/sc_docs/docs/apps/docs/resources/templates/details.handlebars +81 -0
  28. data/lib/sc_docs/docs/apps/docs/resources/templates/extensions/signature.js +0 -0
  29. data/lib/sc_docs/docs/apps/docs/system/jquery_ui.js +62 -0
  30. data/lib/sc_docs/docs/apps/docs/system/showdown.js +1297 -0
  31. data/lib/sc_docs/docs/apps/docs/theme.js +29 -0
  32. data/lib/sc_docs/docs/apps/docs/views/detail_list.js +24 -0
  33. data/lib/sc_docs/docs/apps/docs/views/master_list.js +35 -0
  34. data/lib/sc_docs/docs/apps/docs/views/methods_collection.js +80 -0
  35. data/lib/sc_docs/docs/apps/docs/views/properties_collection.js +9 -0
  36. data/lib/sc_docs/generator.rb +145 -0
  37. data/lib/sc_docs/server.rb +21 -0
  38. data/lib/sc_docs/templates/docs.sproutcore.com/allclasses.tmpl +31 -0
  39. data/lib/sc_docs/templates/docs.sproutcore.com/allfiles.tmpl +66 -0
  40. data/lib/sc_docs/templates/docs.sproutcore.com/class.tmpl +437 -0
  41. data/lib/sc_docs/templates/docs.sproutcore.com/index.tmpl +52 -0
  42. data/lib/sc_docs/templates/docs.sproutcore.com/output/css/api.css +619 -0
  43. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.jpg +0 -0
  44. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.png +0 -0
  45. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/clearinput.png +0 -0
  46. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/cross.png +0 -0
  47. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/ddiagonal.png +0 -0
  48. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/diagonal.png +0 -0
  49. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.jpg +0 -0
  50. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.png +0 -0
  51. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/glow.png +0 -0
  52. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/logo.png +0 -0
  53. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/pixels.png +0 -0
  54. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/search.png +0 -0
  55. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/api.js +134 -0
  56. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/jquery-bbq.js +18 -0
  57. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/jquery-1.5.1.min.js +16 -0
  58. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/modernizr-1.7.min.js +2 -0
  59. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/plugin.js +1 -0
  60. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/script.js +5 -0
  61. data/lib/sc_docs/templates/docs.sproutcore.com/publish.js +200 -0
  62. data/lib/sc_docs/templates/docs.sproutcore.com/static/default.css +300 -0
  63. data/lib/sc_docs/templates/docs.sproutcore.com/static/header.html +19 -0
  64. data/lib/sc_docs/templates/docs.sproutcore.com/static/index.html +19 -0
  65. data/lib/sc_docs/templates/docs.sproutcore.com/symbol.tmpl +35 -0
  66. data/lib/sc_docs/templates/sc_fixture/publish.js +632 -0
  67. data/lib/sc_docs/version.rb +4 -0
  68. data/sc_docs.gemspec +27 -0
  69. data/vendor/jsdoc/README.txt +109 -0
  70. data/vendor/jsdoc/app/frame.js +33 -0
  71. data/vendor/jsdoc/app/frame/Chain.js +102 -0
  72. data/vendor/jsdoc/app/frame/Dumper.js +144 -0
  73. data/vendor/jsdoc/app/frame/Hash.js +84 -0
  74. data/vendor/jsdoc/app/frame/Link.js +173 -0
  75. data/vendor/jsdoc/app/frame/Namespace.js +10 -0
  76. data/vendor/jsdoc/app/frame/Opt.js +134 -0
  77. data/vendor/jsdoc/app/frame/Reflection.js +26 -0
  78. data/vendor/jsdoc/app/frame/String.js +93 -0
  79. data/vendor/jsdoc/app/frame/Testrun.js +129 -0
  80. data/vendor/jsdoc/app/handlers/FOODOC.js +26 -0
  81. data/vendor/jsdoc/app/handlers/XMLDOC.js +26 -0
  82. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  83. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  84. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  85. data/vendor/jsdoc/app/lib/JSDOC.js +106 -0
  86. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +204 -0
  87. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  88. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +140 -0
  89. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +109 -0
  90. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  91. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +146 -0
  92. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  93. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +644 -0
  94. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +243 -0
  95. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  96. data/vendor/jsdoc/app/lib/JSDOC/Token.js +18 -0
  97. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +332 -0
  98. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  99. data/vendor/jsdoc/app/lib/JSDOC/Util.js +32 -0
  100. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +507 -0
  101. data/vendor/jsdoc/app/main.js +111 -0
  102. data/vendor/jsdoc/app/plugins/commentSrcJson.js +20 -0
  103. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  104. data/vendor/jsdoc/app/plugins/functionCall.js +10 -0
  105. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  106. data/vendor/jsdoc/app/plugins/symbolLink.js +10 -0
  107. data/vendor/jsdoc/app/plugins/tagParamConfig.js +31 -0
  108. data/vendor/jsdoc/app/plugins/tagSynonyms.js +43 -0
  109. data/vendor/jsdoc/app/run.js +297 -0
  110. data/vendor/jsdoc/app/t/TestDoc.js +144 -0
  111. data/vendor/jsdoc/app/t/runner.js +13 -0
  112. data/vendor/jsdoc/app/test.js +342 -0
  113. data/vendor/jsdoc/app/test/addon.js +24 -0
  114. data/vendor/jsdoc/app/test/anon_inner.js +14 -0
  115. data/vendor/jsdoc/app/test/augments.js +31 -0
  116. data/vendor/jsdoc/app/test/augments2.js +26 -0
  117. data/vendor/jsdoc/app/test/borrows.js +46 -0
  118. data/vendor/jsdoc/app/test/borrows2.js +23 -0
  119. data/vendor/jsdoc/app/test/config.js +22 -0
  120. data/vendor/jsdoc/app/test/constructs.js +18 -0
  121. data/vendor/jsdoc/app/test/encoding.js +10 -0
  122. data/vendor/jsdoc/app/test/encoding_other.js +12 -0
  123. data/vendor/jsdoc/app/test/event.js +54 -0
  124. data/vendor/jsdoc/app/test/exports.js +14 -0
  125. data/vendor/jsdoc/app/test/functions_anon.js +39 -0
  126. data/vendor/jsdoc/app/test/functions_nested.js +33 -0
  127. data/vendor/jsdoc/app/test/global.js +13 -0
  128. data/vendor/jsdoc/app/test/globals.js +25 -0
  129. data/vendor/jsdoc/app/test/ignore.js +10 -0
  130. data/vendor/jsdoc/app/test/inner.js +16 -0
  131. data/vendor/jsdoc/app/test/jsdoc_test.js +477 -0
  132. data/vendor/jsdoc/app/test/lend.js +33 -0
  133. data/vendor/jsdoc/app/test/memberof.js +19 -0
  134. data/vendor/jsdoc/app/test/memberof2.js +38 -0
  135. data/vendor/jsdoc/app/test/memberof3.js +33 -0
  136. data/vendor/jsdoc/app/test/memberof_constructor.js +17 -0
  137. data/vendor/jsdoc/app/test/module.js +17 -0
  138. data/vendor/jsdoc/app/test/multi_methods.js +25 -0
  139. data/vendor/jsdoc/app/test/name.js +19 -0
  140. data/vendor/jsdoc/app/test/namespace_nested.js +23 -0
  141. data/vendor/jsdoc/app/test/nocode.js +13 -0
  142. data/vendor/jsdoc/app/test/oblit_anon.js +20 -0
  143. data/vendor/jsdoc/app/test/overview.js +20 -0
  144. data/vendor/jsdoc/app/test/param_inline.js +37 -0
  145. data/vendor/jsdoc/app/test/params_optional.js +8 -0
  146. data/vendor/jsdoc/app/test/prototype.js +17 -0
  147. data/vendor/jsdoc/app/test/prototype_nested.js +9 -0
  148. data/vendor/jsdoc/app/test/prototype_oblit.js +13 -0
  149. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +24 -0
  150. data/vendor/jsdoc/app/test/public.js +10 -0
  151. data/vendor/jsdoc/app/test/scripts/code.js +5 -0
  152. data/vendor/jsdoc/app/test/scripts/notcode.txt +5 -0
  153. data/vendor/jsdoc/app/test/shared.js +42 -0
  154. data/vendor/jsdoc/app/test/shared2.js +2 -0
  155. data/vendor/jsdoc/app/test/shortcuts.js +22 -0
  156. data/vendor/jsdoc/app/test/static_this.js +13 -0
  157. data/vendor/jsdoc/app/test/synonyms.js +31 -0
  158. data/vendor/jsdoc/app/test/tosource.js +23 -0
  159. data/vendor/jsdoc/app/test/variable_redefine.js +14 -0
  160. data/vendor/jsdoc/changes.txt +127 -0
  161. data/vendor/jsdoc/conf/sample.conf +31 -0
  162. metadata +240 -0
@@ -0,0 +1,4 @@
1
+ tmp
2
+ .bundle
3
+ bundle
4
+ devbin
@@ -0,0 +1,3 @@
1
+ [submodule "docs/frameworks/sproutcore"]
2
+ path = docs/frameworks/sproutcore
3
+ url = git://github.com/sproutcore/sproutcore.git
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem "sproutcore", "1.6.0.rc.1"
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sc-docs (0.0.1)
5
+ rack
6
+ thor
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ chunky_png (1.1.2)
13
+ compass (0.11.1)
14
+ chunky_png (~> 1.1)
15
+ fssm (>= 0.2.7)
16
+ sass (~> 3.1)
17
+ daemons (1.1.3)
18
+ erubis (2.6.6)
19
+ abstract (>= 1.0.0)
20
+ eventmachine (0.12.10)
21
+ extlib (0.9.15)
22
+ fssm (0.2.7)
23
+ haml (3.1.1)
24
+ json_pure (1.4.6)
25
+ rack (1.2.2)
26
+ sass (3.1.1)
27
+ sproutcore (1.6.0.rc.1)
28
+ chunky_png (~> 1.1.0)
29
+ compass (~> 0.11.1)
30
+ erubis (~> 2.6.6)
31
+ extlib (~> 0.9.15)
32
+ haml (~> 3.1.1)
33
+ json_pure (~> 1.4.6)
34
+ rack (~> 1.2.1)
35
+ thin (~> 1.2.11)
36
+ thor (~> 0.14.3)
37
+ thin (1.2.11)
38
+ daemons (>= 1.0.9)
39
+ eventmachine (>= 0.12.6)
40
+ rack (>= 1.0.0)
41
+ thor (0.14.6)
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ sc-docs!
48
+ sproutcore (= 1.6.0.rc.1)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (C) 2011 Apple Inc.
2
+ Portions Copyright (C) 2011 Strobe Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
@@ -0,0 +1,59 @@
1
+ SproutCore Documentation Generator
2
+ ==================================
3
+
4
+ A tool to generate documentation for the SproutCore framework and SproutCore projects, using the JSDoc format.
5
+
6
+ **Authors**: Majd Taby, Peter Wagenet
7
+
8
+ Usage
9
+ -----
10
+
11
+ ### Basic
12
+
13
+ sc-docs --input_dir INPUT_DIRECTORY_PATH
14
+
15
+ This documents the specified directory and then runs a preview sc-server instance.
16
+
17
+ ### Deploy
18
+
19
+ sc-docs --input_dir INPUT_DIRECTORY_PATH --deploy --project PROJECT_NAME \
20
+ --output_dir = OUTPUT_DIRECTORY_PATH
21
+
22
+ The deploy flag runs sc-build and deploys to the specified directory. If no output_dir is specified then it is deployed to `/Library/WebServer/Documents/`.
23
+
24
+ ### HTML Templates
25
+
26
+ sc-docs --input_dir INPUT_DIRECTORY_PATH --template TEMPLATE_PATH --html
27
+
28
+ By default sc-docs assumes that you want to generate docs for the SproutCore based Doc Viewer. However, you can also generate standard HTML templates.
29
+
30
+ Dependencies
31
+ ------------
32
+
33
+ ### Gems
34
+
35
+ * thor
36
+ * child_labor
37
+ * rack
38
+ * thin *(optional, but recommended)*
39
+
40
+ ### Other
41
+
42
+ * **node.js**: We use a special (much faster) version of jsdoc-toolkit that requires node.js.
43
+
44
+ Templates
45
+ ---------
46
+
47
+ ### sc_fixture
48
+
49
+ Generates the docs in JSON format for use within an SC based viewer app.
50
+
51
+ ### docs.sproutcore.com
52
+
53
+ The template used at docs.sproutcore.com. Designed by Matt Grantham and Ryan Mudryk with additional work by Avrohom Katz.
54
+
55
+ Credits
56
+ ------
57
+
58
+ **jsdoc-toolkit**: Used for the heavy lifting of docs generation
59
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sc_docs/cli'
4
+
5
+ ScDocs::CLI.start
@@ -0,0 +1,3 @@
1
+ module ScDocs
2
+
3
+ end
@@ -0,0 +1,54 @@
1
+ require 'thor'
2
+
3
+ require 'sc_docs/generator'
4
+
5
+ module ScDocs
6
+ class CLI < Thor
7
+
8
+ class_option :input_dir, :aliases => ['-i'], :type => :string,
9
+ :banner => "Directory to generate docs for"
10
+ class_option :output_dir, :aliases => ['-o'], :type => :string,
11
+ :banner => "Directory to output docs to"
12
+ class_option :update, :aliases => ['-u'], :type => :boolean, :default => false,
13
+ :banner => "If input is a git repo, pull and rebase"
14
+ class_option :template, :aliases => ['-t'], :type => :string,
15
+ :banner => "Path to jsdoc template (forces HTML output)"
16
+ class_option :verbose, :aliases => ['-v'], :type => :boolean, :default => false
17
+
18
+ desc "generate", "Generate docs"
19
+ method_option :project, :aliases => ['-p'], :type => :string,
20
+ :banner => "SproutCore Project Name"
21
+ def generate
22
+ puts "Generating Documentation...\n\n"
23
+ run_generator
24
+ end
25
+
26
+ desc "preview", "Preview docs output"
27
+ def preview
28
+ puts "Building Documentation Preview...\n\n"
29
+ run_generator(true)
30
+ end
31
+
32
+ private
33
+
34
+ def run_generator(preview=false)
35
+ update_repo if options[:update]
36
+
37
+ puts options[:template]
38
+ generator = (options[:template] ? HtmlGenerator : ScGenerator).new(options)
39
+ preview ? generator.preview : generator.generate
40
+ end
41
+
42
+ def update_repo
43
+ puts "Updating repository...\n\n" if options[:verbose]
44
+
45
+ if File.directory? input_dir and File.directory? "#{input_dir}/.git"
46
+ Dir.chdir input_dir do
47
+ run("git fetch", print_output)
48
+ run("git rebase origin master", print_output)
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ # ==========================================================================
2
+ # Project: SproutCore - JavaScript Application Framework
3
+ # Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ # License: Licensed under MIT license (see license.js)
5
+ # ==========================================================================
6
+
7
+
8
+ config :all, :required => :sproutcore, :url_prefix => "sc_docs", :load_fixtures => true
@@ -0,0 +1,8 @@
1
+ ==========================================================================
2
+ Project: SproutCore - JavaScript Application Framework
3
+ Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ License: Licensed under MIT license (see license.js)
5
+ ==========================================================================
6
+
7
+ TODO: Describe Your Project
8
+
@@ -0,0 +1,15 @@
1
+ # ==========================================================================
2
+ # Project: SproutCore - JavaScript Application Framework
3
+ # Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ # License: Licensed under MIT license (see license.js)
5
+ # ==========================================================================
6
+
7
+ # This is your Buildfile for your app, Docs. This tells SproutCore
8
+ # how to build your app. These settings override those in your project
9
+ # Buildfile, which contains default settings for all apps in your project.
10
+ #
11
+ # This line tells SproutCore's CSS preprocessor what class names to target.
12
+ # Since your app has a theme named 'docs', and it is based on SproutCore's
13
+ # Ace theme (named 'ace'), it is set to 'ace.docs'.
14
+ config :docs, :css_theme => 'ace.docs'
15
+
@@ -0,0 +1,27 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+ /*globals Docs */
7
+
8
+ /** @class
9
+
10
+ (Document Your Controller Here)
11
+
12
+ @extends SC.TreeController
13
+ */
14
+ Docs.classesController = SC.ArrayController.create(
15
+ /** @scope Docs.classesController.prototype */ {
16
+
17
+ _selectionDidChange: function(){
18
+
19
+ var content = this.getPath('selection.firstObject');
20
+
21
+ if(content) {
22
+ SC.routes.set('location',content.get('displayName'));
23
+ }
24
+
25
+ }.observes('selection')
26
+
27
+ }) ;
@@ -0,0 +1,62 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+ /*globals SC*/
7
+
8
+ /** @class
9
+
10
+ Manages the search feature
11
+
12
+ @author Majd Taby
13
+ @extends SC.Object
14
+ @since SproutCore 1.5
15
+ */
16
+ Docs.searchController = SC.Object.create({
17
+ searchQuery: '',
18
+
19
+ runQuery: function(sender){
20
+ this._runSearch(sender.get('value'));
21
+ },
22
+
23
+ queryDidChange: function(){
24
+ var query = this.get('searchQuery');
25
+ if (!query) {
26
+ this._clearSearch();
27
+ }
28
+
29
+ this._runSearch(query);
30
+
31
+ }.observes('searchQuery'),
32
+
33
+ _clearSearch: function(){
34
+ Docs.classesController.set('content',Docs.allClassesRecordArray);
35
+ },
36
+
37
+ _runSearch: function(query){
38
+
39
+ var matches = this._findMatchesForQuery(query);
40
+
41
+ if (matches) {
42
+ Docs.classesController.set('content',matches);
43
+ }
44
+ },
45
+
46
+ _findMatchesForQuery: function(query) {
47
+ var indexHash = Docs.get('indexHash');
48
+ var classMatches = [];
49
+ var symbolMatches = null;
50
+
51
+ // Go through every symbol, try to match the name of the class first
52
+ for(var name in indexHash){
53
+
54
+ if (name.indexOf(query) !== -1) {
55
+ var storeObject = Docs.store.materializeRecord(indexHash[name]);
56
+ classMatches.push(storeObject);
57
+ }
58
+ };
59
+
60
+ return classMatches;
61
+ }
62
+ });
@@ -0,0 +1,143 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2008-2011 Apple Inc. All rights reserved.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+ /*globals Docs */
7
+
8
+ sc_require('system/jquery_ui');
9
+
10
+ /** @class
11
+
12
+ (Document Your Controller Here)
13
+
14
+ @extends SC.ObjectController
15
+ */
16
+ Docs.selectedClassController = SC.ObjectController.create(
17
+ /** @scope Docs.selectedClassController.prototype */ {
18
+
19
+ contentBinding: SC.Binding.single('Docs.classesController.selection'),
20
+ nameBinding: SC.Binding.oneWay('.content.displayName'),
21
+
22
+ symbolSelection: null,
23
+ symbols: [],
24
+ properties: [],
25
+ methods: [],
26
+
27
+ _contentDidChange: function(){
28
+ var content = this.get('content');
29
+ if (!content) {return;}
30
+
31
+ var that = this;
32
+ // Give the browser a chance to render, we can wait
33
+ // for the next run loop
34
+ //that.invokeLater(function(){
35
+
36
+ var methods = content.get('methods').toArray().sortProperty('name');
37
+ var properties = content.get('properties').toArray().sortProperty('name');
38
+
39
+ that.set('symbols',properties.concat(methods));
40
+
41
+ that.set('properties',properties);
42
+ that.set('methods',methods);
43
+
44
+ that.invokeLater(function(){
45
+ that._updateDataTypeButtons();
46
+ });
47
+ //});
48
+
49
+
50
+ }.observes('content'),
51
+
52
+ _updateLocation: function(symbol) {
53
+
54
+ var location = SC.routes.get('location');
55
+ var prefix = "/";
56
+ if(location) {
57
+ prefix = location.split('/')[0]+'/';
58
+ }
59
+ SC.routes.set('location',prefix+symbol.get('name'));
60
+
61
+ },
62
+
63
+ _scrollToSymbol: function($symbol){
64
+ var container = SC.$('.class-detail');
65
+ var position = this._positionInContainer($symbol[0],container[0]);
66
+
67
+ container.stop();
68
+ container.animate({scrollTop: position.top}, 250,'swing');
69
+ $symbol.children('.header').effect("highlight", {}, 1000);
70
+ },
71
+
72
+ _selectionDidChange: function(){
73
+ var symbol = this.getPath('symbolSelection.firstObject');
74
+ if (!symbol) { return; }
75
+
76
+ var that = this;
77
+ this.invokeLater(function(){
78
+ that._updateLocation(symbol);
79
+
80
+ var $symbol = SC.$('div[name="'+symbol.get('name')+'"]');
81
+ if(!$symbol || !$symbol[0]) { return; }
82
+
83
+ that._scrollToSymbol($symbol);
84
+ });
85
+
86
+ }.observes('symbolSelection'),
87
+
88
+ _positionInContainer: function(obj,container) {
89
+ var curtop = 0;
90
+ var curleft = 0;
91
+
92
+ if (obj.offsetParent) {
93
+ do {
94
+ if (obj === container) { break; }
95
+
96
+ curleft += obj.offsetLeft;
97
+ curtop += obj.offsetTop;
98
+ } while (obj = obj.offsetParent);
99
+ }
100
+
101
+ return {left: curleft, top: curtop};
102
+ },
103
+
104
+ _updateDataTypeButtons: function() {
105
+
106
+ var that = this;
107
+ var dataTypes = SC.$('.class-detail .data-type');
108
+ var curClassName = that.getPath('content.displayName');
109
+ var symbols = this.get('symbols');
110
+
111
+ dataTypes.each(function(index){
112
+
113
+ var name = $(this).attr('name');
114
+ var indexHash = Docs.get('indexHash');
115
+ var valid = NO;
116
+
117
+ // Check if it's a top-level symbol
118
+ if (indexHash[name] && curClassName !== name) {
119
+ valid = YES;
120
+ }
121
+ // Assume it's a symbol in the current class
122
+ else if (symbols.findProperty('displayName',name)) {
123
+ valid = YES;
124
+ }
125
+
126
+ if (valid) {
127
+ var el = $(this);
128
+ el.addClass('clickable');
129
+
130
+ el.click(function(){
131
+ var name = el.attr('name');
132
+
133
+ if (name.indexOf('.') !== 0) {
134
+ Docs.routeToClass({'class': name});
135
+ }
136
+ else {
137
+ Docs.routeToSymbol({symbol: name});
138
+ }
139
+ });
140
+ }
141
+ });
142
+ }
143
+ }) ;