jsduck 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +2 -1
- data/README.md +6 -12
- data/Rakefile +1 -1
- data/js-classes/Date.js +19 -18
- data/jsduck.gemspec +3 -2
- data/lib/jsduck/assets.rb +5 -5
- data/lib/jsduck/ast.rb +2 -2
- data/lib/jsduck/batch_formatter.rb +11 -5
- data/lib/jsduck/class_formatter.rb +1 -1
- data/lib/jsduck/doc_formatter.rb +19 -21
- data/lib/jsduck/doc_parser.rb +1 -1
- data/lib/jsduck/guides.rb +17 -8
- data/lib/jsduck/html_stack.rb +46 -32
- data/lib/jsduck/img/dir.rb +94 -0
- data/lib/jsduck/img/dir_set.rb +39 -0
- data/lib/jsduck/img/writer.rb +23 -0
- data/lib/jsduck/inline/auto_link.rb +106 -0
- data/lib/jsduck/inline/img.rb +19 -11
- data/lib/jsduck/inline/link.rb +6 -132
- data/lib/jsduck/inline/link_renderer.rb +69 -0
- data/lib/jsduck/options.rb +5 -3
- metadata +420 -396
- data/lib/jsduck/images.rb +0 -72
data/lib/jsduck/images.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require "jsduck/logger"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
module JsDuck
|
5
|
-
|
6
|
-
# Looks up images from directories specified through --images option.
|
7
|
-
class Images
|
8
|
-
def initialize(paths)
|
9
|
-
@paths = scan_for_images(paths)
|
10
|
-
@images = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
# Scans each path for image files, building a hash of paths where
|
14
|
-
# each path points to a hash of image files found in that path.
|
15
|
-
def scan_for_images(paths)
|
16
|
-
map = {}
|
17
|
-
paths.each do |path|
|
18
|
-
# Scans directory for image files
|
19
|
-
map[path] = {}
|
20
|
-
Dir[path+"/**/*.{png,jpg,jpeg,gif}"].each do |img|
|
21
|
-
map[path][img] = false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
map
|
25
|
-
end
|
26
|
-
|
27
|
-
# Adds relative image path of an image
|
28
|
-
def add(filename)
|
29
|
-
unless @images[filename]
|
30
|
-
@images[filename] = true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Copys over images to given output dir
|
35
|
-
def copy(output_dir)
|
36
|
-
@images.each_key do |img|
|
37
|
-
unless copy_img(img, output_dir)
|
38
|
-
Logger.warn(:image, "Image not found.", img)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
report_unused
|
42
|
-
end
|
43
|
-
|
44
|
-
# Attempts to copy one image, returns true on success
|
45
|
-
def copy_img(img, output_dir)
|
46
|
-
@paths.each_pair do |path, map|
|
47
|
-
filename = path + "/" + img
|
48
|
-
if map.has_key?(filename)
|
49
|
-
dest = output_dir + "/" + img
|
50
|
-
Logger.log("Copying image", dest)
|
51
|
-
FileUtils.makedirs(File.dirname(dest))
|
52
|
-
FileUtils.cp(filename, dest)
|
53
|
-
# mark file as used.
|
54
|
-
map[filename] = true
|
55
|
-
return true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
return false
|
59
|
-
end
|
60
|
-
|
61
|
-
# Report unused images
|
62
|
-
def report_unused
|
63
|
-
@paths.each_pair do |path, map|
|
64
|
-
map.each_pair do |img, used|
|
65
|
-
Logger.warn(:image_unused, "Image not used.", img) unless used
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|