jazzy 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70f00685fae336565bfc9917dae9bfaf0634a811
4
- data.tar.gz: 57d370af3a76c3c215e91a83390fce948a33779a
3
+ metadata.gz: debc2610dfdacc28a580056ac62cfffdb0819402
4
+ data.tar.gz: 4a2d884071430d1581dbd971bd17ca43b51fa3df
5
5
  SHA512:
6
- metadata.gz: 148bc0db32b0da87f0f344721de0ef6827f0e5759a7e1e19151bc66063ac55222308d76f5d38425a52006b2b99f1739b4adcbb42ec30d617b904e9c10e64e0a5
7
- data.tar.gz: 550ae9482cef0f1c8e0ae0834d9f157c01075d26e4c250888e7385fd284babe5963e9c45589b5ca254b27680955382bc261bdf19e168ccb047f20f5ecbd8c705
6
+ metadata.gz: 4ef4bcac8aa9ec3a757ccd5c6b3c7b50fa5b29ca2b0e960e0084fa1233780af3605dc39064a51f516612afed4cca24b046e52bee09ae44bfb9bdf1865bf9ae77
7
+ data.tar.gz: f4a8965fc8c61270f9e156c431d0ad6ba600fc0c91f753c3964f3f9a5b8bbc8bacc3c0961987c8a5f899f75517f8e0c0f9163f505e97aac051745c95b6720c08
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## :musical_note: :saxophone: jazzy :trumpet: :musical_note:
1
+ ## jazzy <sup>♪♫</sup>
2
2
  **a soulful way to generate docs for Swift & Objective-C**
3
3
 
4
4
  jazzy is a command-line utility that generates documentation for your Swift or Objective-C projects.
data/bin/jazzy CHANGED
@@ -6,7 +6,8 @@ require 'optparse'
6
6
 
7
7
  options = {
8
8
  input: File.expand_path('.'),
9
- output: File.expand_path('docs')
9
+ output: File.expand_path('docs'),
10
+ excludes: []
10
11
  }
11
12
 
12
13
  opt_parser = OptionParser.new do |opt|
@@ -22,6 +23,10 @@ opt_parser = OptionParser.new do |opt|
22
23
  options[:output] = File.expand_path(output)
23
24
  end
24
25
 
26
+ opt.on("-e", "--exclude filepath1,filepath2,…filepathN", Array, "Exclude specific files") do |e|
27
+ options[:excludes] = e # path will be expanded after we’re sure the input has been stored
28
+ end
29
+
25
30
  opt.on("-h","--help","help") do
26
31
  puts opt_parser
27
32
  end
@@ -29,7 +34,9 @@ end
29
34
 
30
35
  opt_parser.parse!
31
36
 
32
- paths = Jazzy.headers(options[:input])
37
+ options[:excludes] = options[:excludes].map { |p| File.expand_path(File.join(options[:input], p)) }
38
+
39
+ paths = Jazzy.headers(options[:input]) - options[:excludes]
33
40
 
34
41
  FileUtils.rm_r options[:output] if File.directory?(options[:output]); Dir.mkdir options[:output]
35
42
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Jazzy
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
 
7
7
  Gem::Specification.new do |spec|
@@ -15,85 +15,118 @@ class Jazzy
15
15
  klass = Jazzy::Klass.new
16
16
 
17
17
  string = `#{bin_path}/SwiftHeader #{path}`
18
- a = string.split(/^\[/); swift = a[0]; map = "[\n"+a[-1]
18
+ a = string.split(/^\[/); swift = a[0]; rawmap = "[\n"+a[-1]
19
19
 
20
- map.gsub!(/(key.\w+):/,'"\1":')
21
- map.gsub!(/(source..+),/,'"\1",')
20
+ rawmap.gsub!(/(key.\w+):/,'"\1":')
21
+ rawmap.gsub!(/(source..+),/,'"\1",')
22
22
 
23
- #print map
24
- #gets
25
-
26
- map = JSON.parse(map)[0]
27
-
28
- swiftmap = {}
29
-
30
- map["key.entities"].each do |e|
31
- swiftmap[e["key.usr"]] = {}
32
- swiftmap[e["key.usr"]]["declaration"] = swift.byteslice(e["key.offset"], e["key.length"])
33
- swiftmap[e["key.usr"]]["name"] = e["key.name"]
34
- end
35
23
 
36
24
  xml = `#{bin_path}/ASTDump #{path}`
37
25
 
38
26
  doc = Nokogiri::XML(xml)
39
27
 
28
+ results = doc.xpath("//*[@file='#{path}']")
29
+
30
+ #results = doc.find_all { |node| node.attribute("file") && node.attribute("file").strip.chomp == path.strip.chomp }
40
31
  # Fill in Overview
41
- doc.xpath("//Other[1]").each do |e|
42
- klass[:name] = e.xpath("Name").text
43
- klass[:usr] = e.xpath("USR").text
44
- klass[:declaration] = {}
45
- klass[:declaration][:objc] = e.xpath("Declaration").text.strip
46
- klass[:abstract] = e.xpath("Abstract/Para").text.strip
47
- paras = []; e.xpath("./Discussion/Para").each {|p| paras << p.text.strip }
48
- klass[:discussion] = paras.join("\n\n")
32
+ top = results.first
33
+ #next if e.attribute("file") && e.attribute("file").text != path
34
+ #print top
35
+ #exit
36
+ klass[:name] = top.xpath("Name").text
37
+ klass[:usr] = top.xpath("USR").text
38
+ klass[:declaration] = {}
39
+ klass[:declaration][:objc] = top.xpath("Declaration").text.strip
40
+ klass[:abstract] = top.xpath("Abstract/Para").text.strip
41
+ paras = []; top.xpath("./Discussion/Para").each {|p| paras << p.text.strip }
42
+ klass[:discussion] = paras.join("\n\n")
43
+
44
+ # Only usable if Swift Header can be correctly generated
45
+ unless rawmap.include? "<<NULL>>"
46
+
47
+ swiftmap = {}
48
+ map = {}
49
+
50
+ JSON.parse(rawmap).each do |element|
51
+
52
+ next unless element["key.name"].downcase == klass[:name].downcase
53
+
54
+ # more than one matching element?
55
+
56
+ element["key.entities"].each do |e|
57
+ swiftmap[e["key.usr"]] = {}
58
+ swiftmap[e["key.usr"]]["declaration"] = swift.byteslice(e["key.offset"], e["key.length"])
59
+ swiftmap[e["key.usr"]]["name"] = e["key.name"]
60
+ end
61
+
62
+ # Inherits
63
+ klass[:inherits] = []
64
+ element["key.inherits"].each { |i| klass[:inherits] << { usr: i["key.usr"], name: i["key.name"] } } unless map["key.inherits"].nil?
65
+
66
+ # Conforms to
67
+ klass[:conforms] = []
68
+ element["key.conforms"].each { |c| klass[:conforms] << { usr: c["key.usr"], name: c["key.name"] } } unless map["key.conforms"].nil?
69
+ end
49
70
  end
50
71
 
51
- # Inherits
52
- klass[:inherits] = []
53
- map["key.inherits"].each do |i|
54
- klass[:inherits] << { usr: i["key.usr"], name: i["key.name"] }
55
- end
56
72
 
57
- # Conforms to
58
- klass[:conforms] = []
59
- map["key.conforms"].each do |c|
60
- klass[:conforms] << { usr: c["key.usr"], name: c["key.name"] }
61
- end
73
+
62
74
 
63
75
  # Import
64
76
  klass[:import] = swift.split("\n")[0].chomp.gsub('import ', '')
65
77
 
66
78
  # Fill in Properties
67
79
  klass[:properties] = []
68
- doc.xpath("//Other[position()>1]").each do |e|
80
+
81
+ results[1..-1].each do |e|
82
+ next unless e.name == "Other"
69
83
  property = {}
70
84
  property[:usr] = e.xpath("USR").text
71
85
  property[:name] = {}
72
86
  property[:name][:objc] = e.xpath("Name").text
73
- property[:name][:swift] = swiftmap[property[:usr]]["name"]
87
+ if !swiftmap.nil? && swiftmap[property[:usr]]
88
+ property[:name][:swift] = swiftmap[property[:usr]]["name"]
89
+ else
90
+ property[:name][:swift] = "Could not be generated"
91
+ end
74
92
  property[:term] = property[:usr]
75
93
  property[:declaration] = {}
76
94
  property[:declaration][:objc] = e.xpath("Declaration").text.strip
77
- property[:declaration][:swift] = swiftmap[property[:usr]]["declaration"]
95
+ if !swiftmap.nil? && swiftmap[property[:usr]]
96
+ property[:declaration][:swift] = swiftmap.nil?
97
+ else
98
+ property[:declaration][:swift] = "Could not be generated"
99
+ end
78
100
  property[:abstract] = e.xpath("Abstract/Para").text.strip
79
101
  paras = []; e.xpath("Discussion/Para").each {|p| paras << p.text.strip }
80
102
  property[:discussion] = paras.join("\n\n") unless paras.length == 0
81
103
  klass[:properties] << property
82
104
  end
83
105
 
106
+ #puts klass[:properties]
107
+
84
108
  # Fill in Methods
85
109
  klass[:methods] = []
86
- doc.xpath("//Function").each do |e|
110
+ results[1..-1].each do |e|
111
+ next unless e.name == "Function"
87
112
  method = {}
88
113
  method[:usr] = e.xpath("USR").text
89
114
  method[:name] = {}
90
115
  method[:name][:objc] = e.xpath("Name").text
91
- method[:name][:swift] = swiftmap[method[:usr]]["name"]
116
+ if !swiftmap.nil? && swiftmap[method[:usr]]
117
+ method[:name][:swift] = swiftmap[method[:usr]]["name"]
118
+ else
119
+ method[:name][:swift] = "Could not be generated"
120
+ end
92
121
  next if method[:usr].include?('(py)')
93
122
  method[:term] = method[:usr].split(')')[-1]
94
123
  method[:declaration] = {}
95
124
  method[:declaration][:objc] = e.xpath("Declaration").text
96
- method[:declaration][:swift] = swiftmap[method[:usr]]["declaration"]
125
+ if !swiftmap.nil? && swiftmap[method[:usr]]
126
+ method[:declaration][:swift] = swiftmap[method[:usr]]["declaration"]
127
+ else
128
+ method[:declaration][:swift] = "Could not be generated"
129
+ end
97
130
  method[:abstract] = e.xpath("Abstract/Para").text.strip
98
131
  paras = []; e.xpath("Discussion/Para").each {|p| paras << p.text.strip }
99
132
  method[:discussion] = paras.join("\n\n") unless paras.length == 0
@@ -14,7 +14,7 @@ class Jazzy::Klass < Mustache
14
14
  end
15
15
 
16
16
  def rendered_abstract_for_overview
17
- self[:abstract].chop! + ' <a class="overview-bulk-toggle">More...</a>'
17
+ $markdown.render( self[:abstract].chop! + ' <a class="overview-bulk-toggle">More...</a>' )
18
18
  end
19
19
 
20
20
  def date
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jazzy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Simard, Tim Anglade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache