cocoapods-docstats 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +12 -0
- data/Rakefile +1 -0
- data/cocoapods_docstats.gemspec +25 -0
- data/lib/_utils.rb +26 -0
- data/lib/cocoapods_docstats.rb +3 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/lib/pod/command/lib/docstats.rb +109 -0
- data/lib/spec_extensions.rb +39 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87c4bd82b1df485269337134a888ed01ba986bd4
|
4
|
+
data.tar.gz: 5bfaf03309849421df54d697f470a27bfcd65647
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19b28f197c4ebe40621f0dba361ab44cdafe156419c7ef81d014c1f21f183be22c2b445e742fd12491c14f4b64bf79fb181c5c126266821369fc50cbfc326f41
|
7
|
+
data.tar.gz: 7c4a1b213fb74f0dc35fd91dfb20230908c121c86d9b17a42d2fb0d1e46e7ba31f8b06a48088c2e69f445344b0bc52727c72bbb61757d5ec5137bfe8e5fb978a
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Boris Bügling <boris@icculus.org>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods_docstats.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cocoapods-docstats"
|
8
|
+
spec.version = CocoapodsDocstats::VERSION
|
9
|
+
spec.authors = ["Boris Bügling"]
|
10
|
+
spec.email = ["boris@icculus.org"]
|
11
|
+
spec.description = %q{CocoaPods plugin for showing documentation metrics of Pods.}
|
12
|
+
spec.summary = %q{CocoaPods plugin for showing documentation metrics of Pods.}
|
13
|
+
spec.homepage = "https://github.com/neonichu/cocoapods-docstats"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "docstat"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
data/lib/_utils.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# allow logging of terminal commands
|
2
|
+
|
3
|
+
def command command_to_run
|
4
|
+
puts " " + command_to_run.yellow if $log_all_terminal_commands
|
5
|
+
system command_to_run
|
6
|
+
end
|
7
|
+
|
8
|
+
# a nice puts
|
9
|
+
|
10
|
+
def vputs text
|
11
|
+
puts text.green if $verbose
|
12
|
+
end
|
13
|
+
|
14
|
+
class Array
|
15
|
+
def listify
|
16
|
+
length < 2 ? first.to_s : "#{self[0..-2] * ', '} and #{last}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module HashInit
|
21
|
+
def initialize(*h)
|
22
|
+
if h.length == 1 && h.first.kind_of?(Hash)
|
23
|
+
h.first.each { |k,v| send("#{k}=",v) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Lib
|
4
|
+
class Docstats < Lib
|
5
|
+
self.summary = "Show documentation metrics of Pods."
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Show documentation metrics of Pods.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = 'NAME'
|
12
|
+
|
13
|
+
def initialize(argv)
|
14
|
+
@output = './cocoapods-docstats/'
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def docstat(docset_path)
|
19
|
+
require 'docstat'
|
20
|
+
|
21
|
+
stats = DocStat.process(docset_path)
|
22
|
+
tokens = stats['containers'].map {|c| c['tokens']}.flatten
|
23
|
+
ratio = stats['ratio']
|
24
|
+
puts "#{tokens.size} tokens, #{((ratio*1000).to_i/1000.0) * 100}% documented"
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_docset(path, spec)
|
28
|
+
headers = headers_for_spec_at_location(path, spec)
|
29
|
+
headers.map! { |header| Shellwords.escape header }
|
30
|
+
|
31
|
+
docset_command = [
|
32
|
+
"appledoc",
|
33
|
+
"--project-name #{spec.name}", # name in top left
|
34
|
+
"--project-company '#{spec.or_contributors_to_spec}'", # name in top right
|
35
|
+
"--company-id com.cocoadocs.#{spec.name.downcase}", # the id for the
|
36
|
+
|
37
|
+
"--project-version #{spec.version}", # project version
|
38
|
+
"--no-install-docset", # don't make a duplicate
|
39
|
+
|
40
|
+
"--keep-intermediate-files", # space for now is OK
|
41
|
+
"--create-html", # eh, nice to have
|
42
|
+
"--publish-docset", # this should create atom
|
43
|
+
|
44
|
+
"--docset-feed-url http://www.cocoadocs.org/docsets/#{spec.name}/xcode-docset.atom",
|
45
|
+
"--docset-atom-filename xcode-docset.atom",
|
46
|
+
|
47
|
+
"--docset-package-url http://www.cocoadocs.org/docsets/#{spec.name}/docset.xar",
|
48
|
+
"--docset-package-filename docset",
|
49
|
+
|
50
|
+
"--docset-fallback-url http://www.cocoadocs.org/docsets/#{spec.name}",
|
51
|
+
"--docset-feed-name #{spec.name}",
|
52
|
+
|
53
|
+
# http://gentlebytes.com/appledoc-docs-examples-advanced/
|
54
|
+
"--keep-undocumented-objects", # not everyone will be documenting
|
55
|
+
"--keep-undocumented-members", # so we should at least show something
|
56
|
+
"--search-undocumented-doc", # uh? ( no idea what this does... )
|
57
|
+
|
58
|
+
"--output #{@output}", # where should we throw stuff
|
59
|
+
*headers,
|
60
|
+
" >/dev/null"
|
61
|
+
]
|
62
|
+
|
63
|
+
command docset_command.join(' ')
|
64
|
+
end
|
65
|
+
|
66
|
+
def headers_for_spec_at_location(path, spec)
|
67
|
+
pathlist = Pod::Sandbox::PathList.new( Pathname.new(path) )
|
68
|
+
headers = []
|
69
|
+
|
70
|
+
# https://github.com/CocoaPods/cocoadocs.org/issues/35
|
71
|
+
[spec, *spec.recursive_subspecs].each do |internal_spec|
|
72
|
+
internal_spec.available_platforms.each do |platform|
|
73
|
+
consumer = Pod::Specification::Consumer.new(internal_spec, platform)
|
74
|
+
accessor = Pod::Sandbox::FileAccessor.new(pathlist, consumer)
|
75
|
+
|
76
|
+
if accessor.public_headers
|
77
|
+
headers += accessor.public_headers.map{ |filepath| filepath.to_s }
|
78
|
+
else
|
79
|
+
puts "Skipping headers for #{internal_spec} on platform #{platform} (no headers found).".blue
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
headers.uniq
|
85
|
+
end
|
86
|
+
|
87
|
+
def podspecs_to_check
|
88
|
+
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
|
89
|
+
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero?
|
90
|
+
podspecs
|
91
|
+
end
|
92
|
+
|
93
|
+
def run
|
94
|
+
podspecs_to_check.each do |path|
|
95
|
+
spec = Specification.from_file(path)
|
96
|
+
|
97
|
+
generate_docset(Dir.pwd, spec)
|
98
|
+
|
99
|
+
docset_path = File.join(@output, "com.cocoadocs.#{spec.name.downcase}." +
|
100
|
+
spec.name + '.docset')
|
101
|
+
docstat(docset_path)
|
102
|
+
|
103
|
+
FileUtils.rm_rf(@output)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
|
4
|
+
def or_is_github?
|
5
|
+
self.homepage.include?("github.com") || (self.source[:git] && self.source[:git].include?("github.com"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def or_git_ref
|
9
|
+
self.source[:tag] || self.source[:commit] || self.source[:branch] || 'master'
|
10
|
+
end
|
11
|
+
|
12
|
+
def or_user
|
13
|
+
return nil unless self.or_is_github?
|
14
|
+
self.homepage.split("/")[-2]
|
15
|
+
end
|
16
|
+
|
17
|
+
def or_repo
|
18
|
+
return nil unless self.or_is_github?
|
19
|
+
self.homepage.split("/")[-1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def or_extensionless_homepage
|
23
|
+
return nil unless self.homepage
|
24
|
+
self.homepage.sub('http://', '').sub('https://', '').sub('www.', '').split("/")[0]
|
25
|
+
end
|
26
|
+
|
27
|
+
def or_contributors_to_spec
|
28
|
+
return self.authors if self.authors.is_a? String
|
29
|
+
return self.authors.listify if self.authors.is_a? Array
|
30
|
+
return self.authors.keys.listify if self.authors.is_a? Hash
|
31
|
+
end
|
32
|
+
|
33
|
+
def or_license
|
34
|
+
return self.license if self.license.is_a? String
|
35
|
+
return self.license[:type] if self.license.is_a? Hash
|
36
|
+
return "Unknown License"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-docstats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Boris Bügling
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: docstat
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: CocoaPods plugin for showing documentation metrics of Pods.
|
56
|
+
email:
|
57
|
+
- boris@icculus.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- cocoapods_docstats.gemspec
|
68
|
+
- lib/_utils.rb
|
69
|
+
- lib/cocoapods_docstats.rb
|
70
|
+
- lib/cocoapods_plugin.rb
|
71
|
+
- lib/pod/command/lib/docstats.rb
|
72
|
+
- lib/spec_extensions.rb
|
73
|
+
homepage: https://github.com/neonichu/cocoapods-docstats
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: CocoaPods plugin for showing documentation metrics of Pods.
|
97
|
+
test_files: []
|