Skip to content

Commit 30106dc

Browse files
committed
Merge branch 'master' into pre-release
2 parents 647832d + 8be9630 commit 30106dc

File tree

18 files changed

+285
-77
lines changed

18 files changed

+285
-77
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,30 @@ reported bugs, submitted patches, and provided a lot of useful input.
159159
Changelog
160160
---------
161161

162+
* 2.0.pre3 - Fixes for the previous pre-release.
163+
* Paging of search results.
164+
* Support opening classes in tree in new tabs in IE and Firefox.
165+
* Include upgraded version of prettifier, fixing formatting in IE.
166+
* New --head-html and --body-html command line options.
167+
* New --local-storage-db command line option.
168+
* Avoid creating case-insensitively same source file names,
169+
preventing duplicate file conflicts in Windows.
170+
* Include missing ExtJS image files.
171+
* Don't exclude static members from singleton classes, simply print
172+
warning about using @static in singleton class.
173+
162174
* 2.0.pre2 - Fixes for the previous pre-release.
163175
* New --stdout command line option.
164176
* Fix opening links in new tabs.
165177
* Few other small bugfixes and enhancements.
166178

167179
* 2.0.pre - Completely overhauled Ext4-themed version.
168-
* Currently in a pre-release state.
180+
* A lot of changes since 0.6 releases.
181+
182+
* 0.6.1 - Bug fixes.
183+
* Fix scrolling to class members in Chrome 12.
184+
* Make JSDuck work with Ruby 1.8.6.
185+
* Upgrade the embedded ExtJS to 3.4.0.
169186

170187
* 0.6 - JsDuck is now used for creating the official ExtJS4 documentation.
171188
* Automatic linking of class names found in comments. Instead of writing

Rakefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ end
7171
def run_jsduck_export(extra_options, ext_dir)
7272
load_sdk_vars
7373
rev = `git rev-parse HEAD`.slice(0, 7)
74+
head_html = <<-EOHTML
75+
<link rel="canonical" href="http://docs.sencha.com/ext-js/4-0/" />
76+
<meta name="description" content="Ext JS 4.0 API Documentation from Sencha. Class documentation, Guides and Videos on how to create Javascript applications with Ext JS 4">
77+
EOHTML
7478

7579
run_jsduck([
7680
"--title", "Ext JS 4.0.2a API Documentation",
7781
"--footer", "ExtJS 4.0.2a Documentation from Sencha. Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{rev}",
82+
"--head-html", head_html,
7883
"#{SDK_DIR}/extjs/src",
7984
"#{SDK_DIR}/platform/src",
8085
"#{SDK_DIR}/platform/core/src",
@@ -92,7 +97,7 @@ desc "Run JSDuck on ExtJS SDK to create release version of docs app"
9297
task :export do
9398
load_sdk_vars
9499
run_jsduck_export([
95-
"--append-html", <<-EOHTML
100+
"--body-html", <<-EOHTML
96101
<div id="notice-text" style="display: none">
97102
Use <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a> for up to date documentation and features
98103
</div>
@@ -104,7 +109,7 @@ desc "Run JSDuck on ExtJS SDK to create live docs app"
104109
task :live_docs do
105110
load_sdk_vars
106111
run_jsduck_export([
107-
"--append-html", <<-EOHTML
112+
"--body-html", <<-EOHTML
108113
<script type="text/javascript">
109114
var _gaq = _gaq || [];
110115
_gaq.push(['_setAccount', 'UA-1396058-10']);

bin/jsduck

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ opts = OptionParser.new do | opts |
7171
app.footer = text
7272
end
7373

74-
opts.on('--append-html=HTML', "Extra code to append to the index.html page.", " ") do |html|
75-
app.append_html = html
74+
opts.on('--head-html=HTML', "HTML to append to the <head> section of index.html.", " ") do |html|
75+
app.head_html = html
76+
end
77+
78+
opts.on('--body-html=HTML', "HTML to append to the <body> section index.html.", " ") do |html|
79+
app.body_html = html
7680
end
7781

7882
opts.on('--guides=PATH', "Path to guides directory.",
@@ -154,6 +158,12 @@ opts = OptionParser.new do | opts |
154158
app.extjs_path = path
155159
end
156160

161+
opts.on('--local-storage-db=NAME',
162+
"Prefix for LocalStorage database names.",
163+
"Defaults to 'docs'.", " ") do |name|
164+
app.local_storage_db = name
165+
end
166+
157167
opts.on('-h', '--help', "Prints this help message", " ") do
158168
puts opts
159169
exit

jsduck.gemspec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
22
s.required_rubygems_version = ">= 1.3.7"
33

44
s.name = 'jsduck'
5-
s.version = '2.0.pre2'
6-
s.date = '2011-07-06'
5+
s.version = '2.0.pre3'
6+
s.date = '2011-07-15'
77
s.summary = "Simple JavaScript Duckumentation generator"
88
s.description = "Documentation generator for ExtJS 4"
99
s.homepage = "https://github.com/senchalabs/jsduck"
@@ -16,6 +16,10 @@ Gem::Specification.new do |s|
1616
end
1717
# Add files not in git
1818
s.files += ['template/extjs/ext-all.js']
19+
s.files += ['template/extjs/resources/themes/images/default/tree/arrows.gif']
20+
s.files += ['template/extjs/resources/themes/images/default/grid/loading.gif']
21+
s.files += ['template/extjs/resources/themes/images/default/form/text-bg.gif']
22+
s.files += ['template/extjs/resources/themes/images/default/form/checkbox.gif']
1923
s.files += Dir['template/resources/css/*.css']
2024

2125
s.executables = ["jsduck"]

lib/jsduck/app.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class App
4040
attr_accessor :title
4141
attr_accessor :footer
4242
attr_accessor :extjs_path
43-
attr_accessor :append_html
43+
attr_accessor :local_storage_db
44+
attr_accessor :head_html
45+
attr_accessor :body_html
4446

4547
def initialize
4648
@output_dir = nil
@@ -60,7 +62,9 @@ def initialize
6062
@title = "Ext JS API Documentation"
6163
@footer = 'Generated with <a href="https://github.com/senchalabs/jsduck">JSDuck</a>.'
6264
@extjs_path = "extjs/ext-all.js"
63-
@append_html = ""
65+
@local_storage_db = "docs"
66+
@head_html = ""
67+
@body_html = ""
6468
@timer = Timer.new
6569
@parallel = ParallelWrap.new
6670
end
@@ -281,11 +285,13 @@ def create_index_html(template_dir, dir)
281285
Logger.instance.log("Creating #{dir}/index.html...")
282286
html = IO.read(template_dir+"/index.html")
283287
html.gsub!("{title}", @title)
284-
html.gsub!("{footer}", @footer)
288+
html.gsub!("{footer}", "<div id='footer-content' style='display: none'>#{@footer}</div>")
285289
html.gsub!("{extjs_path}", @extjs_path)
286-
html.gsub!("{append_html}", @append_html)
290+
html.gsub!("{local_storage_db}", @local_storage_db)
287291
html.gsub!("{guides}", @guides.to_html)
288292
html.gsub!("{categories}", @categories.to_html)
293+
html.gsub!("{head_html}", @head_html)
294+
html.gsub!("{body_html}", @body_html)
289295
FileUtils.rm(dir+"/index.html")
290296
File.open(dir+"/index.html", 'w') {|f| f.write(html) }
291297
end

lib/jsduck/class.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,28 @@ def members_hash(type, context=:members)
120120
all_members.delete_if {|key, member| !member[:inheritable] }
121121
end
122122

123-
(@doc[context][type] || []).each do |m|
124-
all_members[m[:name]] = m if !m[:private]
123+
all_members.merge!(local_members_hash(type, context))
124+
125+
# If singleton has static members, include them as if they were
126+
# instance members. Otherwise they will be completely excluded
127+
# from the docs, as the static members block is not created for
128+
# singletons.
129+
if @doc[:singleton] && @doc[:statics][type].length > 0
130+
all_members.merge!(local_members_hash(type, :statics))
125131
end
126132

127133
all_members
128134
end
129135

136+
# Helper method to get the direct members of this class
137+
def local_members_hash(type, context)
138+
local_members = {}
139+
(@doc[context][type] || []).each do |m|
140+
local_members[m[:name]] = m if !m[:private]
141+
end
142+
local_members
143+
end
144+
130145
# Returns member by name.
131146
#
132147
# Optionally one can also specify type name to differenciate

lib/jsduck/source_writer.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def write(source, filename)
2626
def uniq_html_filename(filename)
2727
fname = html_filename(filename)
2828
nr = 1
29-
while File.exists?(fname)
29+
while file_exists?(fname)
3030
nr += 1
3131
fname = html_filename(filename, nr)
3232
end
@@ -37,6 +37,12 @@ def html_filename(filename, nr=0)
3737
@output_dir + "/" + File.basename(filename, ".js") + (nr > 0 ? nr.to_s : "") + ".html"
3838
end
3939

40+
# Case-insensitive check for file existance to avoid conflicts
41+
# when source files dir is moved to Windows machine.
42+
def file_exists?(filename)
43+
Dir.glob(filename, File::FNM_CASEFOLD).length > 0
44+
end
45+
4046
# Returns source wrapped inside HTML page
4147
def wrap_page(source)
4248
return <<-EOHTML

spec/class_spec.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
describe JsDuck::Class do
44

5+
# Avoid printed warnings in output
6+
class JsDuck::Logger
7+
def warn(msg)
8+
end
9+
end
10+
511
describe "#members" do
612

713
before do
@@ -70,6 +76,16 @@
7076
:extends => "ParentClass",
7177
:mixins => ["MixinClass"],
7278
:singleton => true,
79+
:members => {
80+
:method => [
81+
{:name => "sing", :owner => "Singleton"},
82+
]
83+
},
84+
:statics => {
85+
:method => [
86+
{:name => "singStat", :owner => "Singleton"},
87+
]
88+
}
7389
});
7490
@classes["Singleton"] = @singletonChild
7591
@singletonChild.relations = @classes
@@ -133,9 +149,17 @@
133149
@members.should have_key("foo")
134150
end
135151

136-
it "inherites all instace members from mixins" do
152+
it "inherits all instace members from mixins" do
137153
@members.should have_key("xxx")
138154
end
155+
156+
it "lists its instance members" do
157+
@members.should have_key("sing")
158+
end
159+
160+
it "lists its static members as if they were instance members" do
161+
@members.should have_key("singStat")
162+
end
139163
end
140164
end
141165

@@ -182,6 +206,10 @@
182206
@members.should_not have_key("mixinA")
183207
@members.should_not have_key("mixinB")
184208
end
209+
210+
it "doesn't list any of his own static members" do
211+
@members.should_not have_key("singStat")
212+
end
185213
end
186214
end
187215
end

template/app/controller/Search.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,31 @@ Ext.define('Docs.controller.Search', {
1010

1111
stores: ['Search'],
1212

13+
refs: [
14+
{
15+
ref: 'field',
16+
selector: '#search-field'
17+
}
18+
],
19+
20+
// Currentl page in search results and nr of items on one page
21+
pageIndex: 0,
22+
pageSize: 10,
23+
1324
init: function() {
1425
this.control({
1526
'#search-dropdown': {
1627
itemclick: function(dropdown, record) {
1728
this.loadRecord(record);
29+
},
30+
changePage: function(dropdown, delta) {
31+
// don't hide dropdown
32+
clearTimeout(this.hideTimeout);
33+
this.getField().focus();
34+
35+
// increment page number and update search results display
36+
this.pageIndex += delta;
37+
this.search(this.getField().getValue());
1838
}
1939
},
2040
'#search-field': {
@@ -56,6 +76,8 @@ Ext.define('Docs.controller.Search', {
5676
record && this.loadRecord(record);
5777
}
5878
else {
79+
// A new search - reset paging back to first page
80+
this.pageIndex = 0;
5981
// Wait a bit before actually performing the search.
6082
// When user is typing fast, the value of el.value
6183
// might not right away be the final value. For example
@@ -81,7 +103,7 @@ Ext.define('Docs.controller.Search', {
81103
// badly when you make a long mouse press on
82104
// dropdown item.
83105
var dropdown = this.getDropdown();
84-
Ext.Function.defer(dropdown.hide, 500, dropdown);
106+
this.hideTimeout = Ext.Function.defer(dropdown.hide, 500, dropdown);
85107
}
86108
}
87109
});
@@ -103,10 +125,21 @@ Ext.define('Docs.controller.Search', {
103125

104126
search: function(term) {
105127
// perform search and load results to store
106-
var limit = 10;
107128
var results = this.filterMembers(term);
129+
130+
// Don't allow paging before first or after the last page.
131+
if (this.pageIndex < 0) {
132+
this.pageIndex = 0;
133+
}
134+
else if (this.pageIndex > Math.floor(results.length / this.pageSize)) {
135+
this.pageIndex = Math.floor(results.length / this.pageSize);
136+
}
137+
var start = this.pageIndex * this.pageSize;
138+
var end = start + this.pageSize;
139+
108140
this.getDropdown().setTotal(results.length);
109-
this.getDropdown().getStore().loadData(results.slice(0, limit));
141+
this.getDropdown().setStart(start);
142+
this.getDropdown().getStore().loadData(results.slice(start, end));
110143
// position dropdown below search box
111144
this.getDropdown().alignTo('search-field', 'bl', [-23, 2]);
112145
// hide dropdown when nothing found

template/app/model/Favorite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Ext.define('Docs.model.Favorite', {
66
extend: 'Ext.data.Model',
77
proxy: {
88
type: ('localStorage' in window && window['localStorage'] !== null) ? 'localstorage' : 'memory',
9-
id : 'docs-favorites'
9+
id: Docs.localStorageDb + '-favorites'
1010
}
1111
});

0 commit comments

Comments
 (0)