jsduck 3.10.0 → 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
data/Rakefile CHANGED
@@ -1,13 +1,16 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'json'
4
3
 
5
4
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
6
5
 
6
+ def os_is_windows?
7
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
8
+ end
9
+
7
10
  require 'rspec'
8
11
  require 'rspec/core/rake_task'
9
12
  RSpec::Core::RakeTask.new(:spec) do |spec|
10
- spec.rspec_opts = ["--color"]
13
+ spec.rspec_opts = ["--color"] unless os_is_windows?
11
14
  spec.pattern = "spec/**/*_spec.rb"
12
15
  end
13
16
 
@@ -176,11 +179,11 @@ class JsDuckRunner
176
179
  end
177
180
 
178
181
  def add_debug
179
- @options += [
182
+ add_options(
180
183
  "--extjs-path", "extjs/ext-all-debug.js",
181
- "--template-links",
182
184
  "--template", "template",
183
- ]
185
+ )
186
+ add_options("--template-links") unless os_is_windows?
184
187
  end
185
188
 
186
189
  def run
@@ -246,7 +249,7 @@ task :touch2 => :sass do
246
249
  runner.add_options(
247
250
  "--output", OUT_DIR,
248
251
  "--config", "#{SDK_DIR}/touch/docs/config.json",
249
- "--examples-base-url", "touch/examples/production/",
252
+ "--examples-base-url", "touch-build/examples/production/",
250
253
  "--seo",
251
254
  "--tests"
252
255
  )
@@ -255,7 +258,7 @@ task :touch2 => :sass do
255
258
  runner.add_comments('touch', '2')
256
259
  runner.run
257
260
 
258
- system("cp -r #{TOUCH_BUILD} #{OUT_DIR}/touch")
261
+ system("cp -r #{TOUCH_BUILD} #{OUT_DIR}/touch-build")
259
262
  end
260
263
 
261
264
  task :default => :spec
data/jsduck.gemspec CHANGED
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
2
2
  s.required_rubygems_version = ">= 1.3.5"
3
3
 
4
4
  s.name = 'jsduck'
5
- s.version = '3.10.0'
6
- s.date = '2012-05-04'
5
+ s.version = '3.10.1'
6
+ s.date = '2012-05-11'
7
7
  s.summary = "Simple JavaScript Duckumentation generator"
8
8
  s.description = "Documentation generator for Sencha JS frameworks"
9
9
  s.homepage = "https://github.com/senchalabs/jsduck"
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.rubyforge_project = s.name
13
13
 
14
14
  s.files = `git ls-files`.split("\n").find_all do |file|
15
- file !~ /spec.rb$/ && file !~ /benchmark/ && file !~ /template\//
15
+ file !~ /spec.rb$/ && file !~ /benchmark/ && file !~ /template\// && file !~ /opt\//
16
16
  end
17
17
  # Add files not in git
18
18
  s.files += Dir['template-min/**/*']
@@ -23,5 +23,9 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'json'
24
24
  s.add_dependency 'parallel'
25
25
 
26
+ s.add_development_dependency 'rspec'
27
+ s.add_development_dependency 'rake'
28
+ s.add_development_dependency 'compass'
29
+
26
30
  s.require_path = 'lib'
27
31
  end
@@ -2,10 +2,10 @@
2
2
  require 'rubygems'
3
3
  require 'rdiscount'
4
4
  require 'strscan'
5
- require 'cgi'
6
5
  require 'jsduck/logger'
7
6
  require 'jsduck/inline_img'
8
7
  require 'jsduck/inline_video'
8
+ require 'jsduck/html'
9
9
 
10
10
  module JsDuck
11
11
 
@@ -274,7 +274,7 @@ module JsDuck
274
274
  when '%-'
275
275
  member ? "-" : ""
276
276
  when '%a'
277
- CGI.escapeHTML(anchor_text||"")
277
+ HTML.escape(anchor_text||"")
278
278
  else
279
279
  $1
280
280
  end
@@ -327,7 +327,7 @@ module JsDuck
327
327
  # Blah blah blah some text.
328
328
  #
329
329
  def shorten(input)
330
- sent = first_sentence(strip_tags(input))
330
+ sent = first_sentence(HTML.strip_tags(input).strip)
331
331
  # Use u-modifier to correctly count multi-byte characters
332
332
  chars = sent.scan(/./mu)
333
333
  if chars.length > @max_length
@@ -343,15 +343,12 @@ module JsDuck
343
343
 
344
344
  # Returns true when input should get shortened.
345
345
  def too_long?(input)
346
- stripped = strip_tags(input)
346
+ stripped = HTML.strip_tags(input).strip
347
347
  # for sentence v/s full - compare byte length
348
348
  # for full v/s max - compare char length
349
349
  first_sentence(stripped).length < stripped.length || stripped.scan(/./mu).length > @max_length
350
350
  end
351
351
 
352
- def strip_tags(str)
353
- str.gsub(/<.*?>/, "").strip
354
- end
355
352
  end
356
353
 
357
354
  end
data/lib/jsduck/guides.rb CHANGED
@@ -4,6 +4,7 @@ require 'jsduck/io'
4
4
  require 'jsduck/null_object'
5
5
  require 'jsduck/logger'
6
6
  require 'jsduck/grouped_asset'
7
+ require 'jsduck/html'
7
8
  require 'fileutils'
8
9
 
9
10
  module JsDuck
@@ -51,7 +52,7 @@ module JsDuck
51
52
  @groups.map do |group|
52
53
  {
53
54
  "title" => group["title"],
54
- "items" => group["items"].map {|g| g.select {|k, v| k != :html } }
55
+ "items" => group["items"].map {|g| Hash[g.select {|k, v| k != :html }] }
55
56
  }
56
57
  end
57
58
  end
@@ -111,8 +112,9 @@ module JsDuck
111
112
  html.each_line do |line|
112
113
  if line =~ /^<h2>(.*)<\/h2>$/
113
114
  i += 1
114
- toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{$1}</a></li>\n"
115
- new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{$1}</h2>\n"
115
+ text = HTML.strip_tags($1)
116
+ toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{text}</a></li>\n"
117
+ new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{text}</h2>\n"
116
118
  else
117
119
  new_html << line
118
120
  end
@@ -0,0 +1,25 @@
1
+ require 'cgi'
2
+
3
+ module JsDuck
4
+
5
+ # Helpers for dealing with HTML
6
+ class HTML
7
+
8
+ # Strips tags from HTML text
9
+ def self.strip_tags(html)
10
+ html.gsub(/<.*?>/, "")
11
+ end
12
+
13
+ # Escapes HTML, replacing < with &lt; ...
14
+ def self.escape(html)
15
+ CGI.escapeHTML(html)
16
+ end
17
+
18
+ # Unescapes HTML, replacing &lt; with < ...
19
+ def self.unescape(html)
20
+ CGI.unescapeHTML(html)
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -1,5 +1,5 @@
1
1
  require 'jsduck/json_duck'
2
- require 'cgi'
2
+ require 'jsduck/html'
3
3
 
4
4
  module JsDuck
5
5
 
@@ -65,7 +65,7 @@ module JsDuck
65
65
  ex = s.scan_until(@end_example_re).sub(@end_example_re, '')
66
66
 
67
67
  examples << {
68
- :code => CGI.unescapeHTML(strip_tags(ex)),
68
+ :code => HTML.unescape(HTML.strip_tags(ex)),
69
69
  :options => options,
70
70
  }
71
71
  else
@@ -89,9 +89,6 @@ module JsDuck
89
89
  hash
90
90
  end
91
91
 
92
- def strip_tags(str)
93
- str.gsub(/<.*?>/, "")
94
- end
95
92
  end
96
93
 
97
94
  end
@@ -1,4 +1,4 @@
1
- require 'cgi'
1
+ require 'jsduck/html'
2
2
  require 'jsduck/logger'
3
3
 
4
4
  module JsDuck
@@ -42,7 +42,7 @@ module JsDuck
42
42
  when '%u'
43
43
  @base_path ? (@base_path + "/" + url) : url
44
44
  when '%a'
45
- CGI.escapeHTML(alt_text||"")
45
+ HTML.escape(alt_text||"")
46
46
  else
47
47
  $1
48
48
  end
@@ -1,4 +1,4 @@
1
- require 'cgi'
1
+ require 'jsduck/html'
2
2
  require 'jsduck/logger'
3
3
 
4
4
  module JsDuck
@@ -47,7 +47,7 @@ module JsDuck
47
47
  when '%u'
48
48
  url
49
49
  when '%a'
50
- CGI.escapeHTML(alt_text||"")
50
+ HTML.escape(alt_text||"")
51
51
  else
52
52
  $1
53
53
  end
@@ -75,7 +75,7 @@ module JsDuck
75
75
  ]
76
76
  @meta_tag_paths = []
77
77
 
78
- @version = "3.10.0"
78
+ @version = "3.10.1"
79
79
 
80
80
  # Customizing output
81
81
  @title = "Sencha Docs - Ext JS"
@@ -1,5 +1,5 @@
1
1
  require 'jsduck/meta_tag_registry'
2
- require 'cgi'
2
+ require 'jsduck/html'
3
3
 
4
4
  module JsDuck
5
5
 
@@ -267,7 +267,7 @@ module JsDuck
267
267
  doc << m[:doc]
268
268
 
269
269
  if m[:default] && m[:default] != "undefined"
270
- doc << "<p>Defaults to: <code>" + CGI.escapeHTML(m[:default]) + "</code></p>"
270
+ doc << "<p>Defaults to: <code>" + HTML.escape(m[:default]) + "</code></p>"
271
271
  end
272
272
 
273
273
  doc << render_meta_data(m[:html_meta], :bottom)
@@ -329,7 +329,7 @@ module JsDuck
329
329
  p[:optional] ? " (optional)" : "",
330
330
  "<div class='sub-desc'>",
331
331
  p[:doc],
332
- p[:default] ? "<p>Defaults to: <code>#{CGI.escapeHTML(p[:default])}</code></p>" : "",
332
+ p[:default] ? "<p>Defaults to: <code>#{HTML.escape(p[:default])}</code></p>" : "",
333
333
  p[:properties] && p[:properties].length > 0 ? render_params_and_return(p) : "",
334
334
  "</div>",
335
335
  "</li>",
@@ -1,7 +1,7 @@
1
1
  require 'jsduck/js_parser'
2
2
  require 'jsduck/css_parser'
3
3
  require 'jsduck/merger'
4
- require "cgi"
4
+ require 'jsduck/html'
5
5
 
6
6
  module JsDuck
7
7
 
@@ -54,7 +54,7 @@ module JsDuck
54
54
  # Use #each_line instead of #lines to support Ruby 1.6
55
55
  @contents.each_line do |line|
56
56
  linenr += 1;
57
- line = CGI.escapeHTML(line)
57
+ line = HTML.escape(line)
58
58
  # wrap the line in as many spans as there are links to this line number.
59
59
  if @links[linenr]
60
60
  @links[linenr].each do |link|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsduck
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.10.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-04 00:00:00.000000000 Z
13
+ date: 2012-05-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdiscount
@@ -60,6 +60,54 @@ dependencies:
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rake
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: compass
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
63
111
  description: Documentation generator for Sencha JS frameworks
64
112
  email: rene.saarsoo@sencha.com
65
113
  executables:
@@ -69,6 +117,7 @@ extra_rdoc_files: []
69
117
  files:
70
118
  - .gitignore
71
119
  - COPYING
120
+ - Gemfile
72
121
  - README.md
73
122
  - Rakefile
74
123
  - bin/compare
@@ -104,6 +153,7 @@ files:
104
153
  - lib/jsduck/grouped_asset.rb
105
154
  - lib/jsduck/guide_writer.rb
106
155
  - lib/jsduck/guides.rb
156
+ - lib/jsduck/html.rb
107
157
  - lib/jsduck/icons.rb
108
158
  - lib/jsduck/images.rb
109
159
  - lib/jsduck/index_html.rb
@@ -154,14 +204,6 @@ files:
154
204
  - lib/jsduck/type_parser.rb
155
205
  - lib/jsduck/videos.rb
156
206
  - lib/jsduck/welcome.rb
157
- - opt/aside.png
158
- - opt/comments-server-side/.gitignore
159
- - opt/comments-server-side/ForumUser.js
160
- - opt/comments-server-side/app.js
161
- - opt/comments-server-side/database.js
162
- - opt/comments-server-side/package.json
163
- - opt/comments-server-side/util.js
164
- - opt/example.js
165
207
  - template-min/README.md
166
208
  - template-min/template.html
167
209
  - template-min/eg-iframe.html
data/opt/aside.png DELETED
Binary file
@@ -1,2 +0,0 @@
1
- config.js
2
- node_modules
@@ -1,80 +0,0 @@
1
- /**
2
- * Authentication with a vBulletin user database
3
- */
4
-
5
- var crypto = require('crypto'),
6
- _ = require('underscore');
7
-
8
- var ForumUser = exports.ForumUser = function(client) {
9
- this.client = client;
10
- };
11
-
12
- ForumUser.prototype = {
13
-
14
- login: function(username, password, callback) {
15
-
16
- var sql = "SELECT userid, usergroupid, membergroupids, email, username, password, salt FROM user WHERE username = ?",
17
- self = this;
18
-
19
- this.client.query(sql, [username],
20
-
21
- function selectCb(err, results, fields) {
22
- if (err) {
23
- callback(err);
24
- return;
25
- }
26
-
27
- if (results.length == 0) {
28
- callback("No such user");
29
- return;
30
- }
31
-
32
- if (!self.checkPassword(password, results[0].salt, results[0].password)) {
33
- callback("Invalid password");
34
- return;
35
- }
36
-
37
- var user = self.getUserFromResult(results[0]);
38
-
39
- callback(null, user);
40
- }
41
- );
42
- },
43
-
44
- clientUser: function(user) {
45
-
46
- crypto.createHash('md5').update(user.email).digest("hex");
47
-
48
- return {
49
- emailHash: user.email,
50
- userName: user.username,
51
- userId: user.userid,
52
- mod: _.include(user.membergroupids, 7)
53
- };
54
- },
55
-
56
- checkPassword: function(password, salt, saltedPassword) {
57
-
58
- password = crypto.createHash('md5').update(password).digest("hex") + salt;
59
- password = crypto.createHash('md5').update(password).digest("hex");
60
-
61
- return password == saltedPassword;
62
- },
63
-
64
- getUserFromResult: function(result) {
65
-
66
- var ids, id;
67
-
68
- if (result.membergroupids) {
69
- ids = result.membergroupids.split(',');
70
- result.membergroupids = [];
71
- for (id in ids) {
72
- result.membergroupids.push(Number(ids[id]));
73
- }
74
- }
75
-
76
- result.moderator = _.include(result.membergroupids, 7);
77
-
78
- return result;
79
- }
80
- };