docstat 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +53 -0
- data/bin/docstat +13 -0
- data/lib/docstat/container.rb +67 -0
- data/lib/docstat/token.rb +53 -0
- data/lib/docstat.rb +57 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df01644c316c2876021d45299e9dcf1dca78b826
|
4
|
+
data.tar.gz: 996f490dd4e4bed15e86d4aea9d40cf2c0d14fca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd02e766736729bad497005e67b6671815d8d52832f5091b491f0dd2dde9b0cc896db49cff4e95b3c30ae81cb9a639ec7644de044b1f0574ec52ada58896defc
|
7
|
+
data.tar.gz: f97ebd1de84def67a09c7581b3fc9a78ce61c91dac94da897f674c3741e139be81d6d5fe183e2e6704060141a28b9439b797ab4ffb29e5231f7b59f450da3bbc
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Delisa Mason
|
2
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
3
|
+
a copy of this software and associated documentation files (the
|
4
|
+
"Software"), to deal in the Software without restriction, including
|
5
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
6
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
7
|
+
permit persons to whom the Software is furnished to do so, subject to
|
8
|
+
the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be
|
11
|
+
included in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
16
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
17
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
18
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
19
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# docstat [![Build Status](https://travis-ci.org/kattrali/docstat.svg?branch=master)](https://travis-ci.org/kattrali/docstat)
|
2
|
+
|
3
|
+
Documentation metrics for libraries, optimized for Cocoa. `docstat` takes documentation sets (*.docset) generated via `appledoc` and similar tools and extracts general statistics. It also includes a binary for testing that coverage exceeds a given ratio.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
### Printing token statistics
|
8
|
+
|
9
|
+
The included `docstat` binary prints the number of tokens and coverage in a given documentation set
|
10
|
+
|
11
|
+
### Testing for coverage
|
12
|
+
|
13
|
+
The included `docstat-test` binary tests a given documentation set for a specified coverage level:
|
14
|
+
|
15
|
+
$ docstat-test [docset path] (expected coverage ratio)
|
16
|
+
|
17
|
+
If no expected coverage ratio is specified, the default is '0.9'. On failure, the process exits with a status code of 1.
|
18
|
+
|
19
|
+
### Processing coverage data
|
20
|
+
|
21
|
+
`DocStat.process(docset_path)` returns a Hash containing information about all of the documented tokens in the following structure:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
{
|
25
|
+
'ratio': decimal
|
26
|
+
'containers': [
|
27
|
+
{
|
28
|
+
'name': 'class name',
|
29
|
+
'ratio': decimal,
|
30
|
+
'tokens': [
|
31
|
+
{
|
32
|
+
'name': 'name of token',
|
33
|
+
'type': 'property or message type',
|
34
|
+
'abstract': 'description of token',
|
35
|
+
'declaration': 'formal declaration',
|
36
|
+
'returns': 'description of return value',
|
37
|
+
'documented': boolean
|
38
|
+
}, ...
|
39
|
+
]
|
40
|
+
}, ...
|
41
|
+
]
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
45
|
+
## Installation
|
46
|
+
|
47
|
+
Run `gem install docstat` in a terminal. `docstat` depends on the `sqlite3` ruby library.
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
`docstat` is tested using [bacon](https://github.com/chneukirchen/bacon).
|
52
|
+
|
53
|
+
Install development dependencies via `bundle install`.
|
data/bin/docstat
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/docstat'))
|
4
|
+
|
5
|
+
if docset_path = ARGV[0]
|
6
|
+
stats = DocStat.process(docset_path)
|
7
|
+
tokens = stats['containers'].map {|c| c['tokens']}.flatten
|
8
|
+
ratio = stats['ratio']
|
9
|
+
print "#{tokens.size} tokens, #{((ratio*1000).to_i/1000.0) * 100}% documented"
|
10
|
+
else
|
11
|
+
print "No Documentation Set (*.docset) directory specified\n"
|
12
|
+
exit(1)
|
13
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
|
3
|
+
require 'token'
|
4
|
+
|
5
|
+
module DocStat
|
6
|
+
class Container
|
7
|
+
attr_reader :name, :tokens
|
8
|
+
|
9
|
+
QUERY = "select ZCONTAINERNAME,ZTOKENNAME,ZTYPENAME,ZTOKENMETAINFORMATION.ZABSTRACT,ZDECLARATION,ZRETURNVALUE.ZABSTRACT from ZTOKEN \
|
10
|
+
inner join ZCONTAINER on ZTOKEN.ZCONTAINER = ZCONTAINER.Z_PK \
|
11
|
+
inner join ZTOKENTYPE on ZTOKEN.ZTOKENTYPE = ZTOKENTYPE.Z_PK \
|
12
|
+
inner join ZTOKENMETAINFORMATION on ZTOKEN.Z_PK = ZTOKENMETAINFORMATION.ZTOKEN \
|
13
|
+
left join ZRETURNVALUE on (ZTOKENMETAINFORMATION.ZRETURNVALUE = ZRETURNVALUE.Z_PK) \
|
14
|
+
order by ZCONTAINERNAME"
|
15
|
+
|
16
|
+
def self.from_sqlite path
|
17
|
+
db = SQLite3::Database.new(path)
|
18
|
+
rows = db.execute(QUERY).to_a
|
19
|
+
container_groups = rows.group_by {|r| r.first }
|
20
|
+
groups = container_groups.map do |name, tokens|
|
21
|
+
self.new(name, tokens)
|
22
|
+
end
|
23
|
+
db.close
|
24
|
+
groups
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize name, tokens
|
28
|
+
@name, @tokens = name, tokens.map {|t| Token.new(t)}
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_hash
|
32
|
+
{
|
33
|
+
"name" => name,
|
34
|
+
"tokens" => tokens.map(&:to_hash),
|
35
|
+
"ratio" => ratio
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def ratio
|
40
|
+
documentation_ratio(tokens)
|
41
|
+
end
|
42
|
+
|
43
|
+
def method_documentation_ratio
|
44
|
+
documentation_ratio(tokens.select(:method?))
|
45
|
+
end
|
46
|
+
|
47
|
+
def property_documentation_ratio
|
48
|
+
documentation_ratio(tokens.select(:property?))
|
49
|
+
end
|
50
|
+
|
51
|
+
def description
|
52
|
+
token_description = tokens.map {|t| t.description}.join("\n")
|
53
|
+
"#{name}:\n#{token_description}"
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def documentation_ratio token_set
|
59
|
+
if token_set.size > 0
|
60
|
+
documented = token_set.select(&:documented?)
|
61
|
+
documented.size.to_f / token_set.size
|
62
|
+
else
|
63
|
+
1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
module DocStat
|
3
|
+
class Token
|
4
|
+
attr_reader :name, :type, :abstract, :declaration, :return_value
|
5
|
+
|
6
|
+
METHOD_TYPES = ['clm','clfm','instm','intfm']
|
7
|
+
PROPERTY_TYPES = ['instp','intfp']
|
8
|
+
TYPE_MAPPING = {
|
9
|
+
'clm' => 'class method',
|
10
|
+
'clfm' => 'class category method',
|
11
|
+
'instm' => 'instance method',
|
12
|
+
'intfm' => 'instance method',
|
13
|
+
'instp' => 'instance property',
|
14
|
+
'intfp' => 'instance property'
|
15
|
+
}
|
16
|
+
|
17
|
+
def initialize property_ary
|
18
|
+
_, @name, @type, @abstract, @declaration, @return_value = *property_ary
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_hash
|
22
|
+
{
|
23
|
+
"name" => name,
|
24
|
+
"type" => pretty_type,
|
25
|
+
"abstract" => abstract,
|
26
|
+
"declaration" => declaration,
|
27
|
+
"returns" => return_value,
|
28
|
+
"documented" => documented?
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def documented?
|
33
|
+
# TODO: check parameter docs as well?
|
34
|
+
!((abstract.nil? || abstract.empty?) && (return_value.nil? || return_value.empty?))
|
35
|
+
end
|
36
|
+
|
37
|
+
def method?
|
38
|
+
METHOD_TYPES.include?(type)
|
39
|
+
end
|
40
|
+
|
41
|
+
def property?
|
42
|
+
PROPERTY_TYPES.include?(type)
|
43
|
+
end
|
44
|
+
|
45
|
+
def pretty_type
|
46
|
+
TYPE_MAPPING[type]
|
47
|
+
end
|
48
|
+
|
49
|
+
def description
|
50
|
+
"#{name} (#{type}) - #{abstract}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/docstat.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'sqlite3'
|
4
|
+
require 'docstat/container'
|
5
|
+
|
6
|
+
module DocStat
|
7
|
+
|
8
|
+
# Parses a docset and returns a representation of the
|
9
|
+
# documented tokens within the library.
|
10
|
+
# The general structure is as follows:
|
11
|
+
#
|
12
|
+
# {
|
13
|
+
# 'ratio': decimal
|
14
|
+
# 'containers': [
|
15
|
+
# {
|
16
|
+
# 'name': 'class name',
|
17
|
+
# 'ratio': decimal
|
18
|
+
# 'tokens': [
|
19
|
+
# {
|
20
|
+
# 'name': 'name of token',
|
21
|
+
# 'type': 'property or message type',
|
22
|
+
# 'abstract': 'description of token',
|
23
|
+
# 'declaration': 'formal declaration',
|
24
|
+
# 'returns': 'description of return value',
|
25
|
+
# 'documented': boolean
|
26
|
+
# }, ...
|
27
|
+
# ]
|
28
|
+
# }, ...
|
29
|
+
# ]
|
30
|
+
# }
|
31
|
+
def self.process docset_path
|
32
|
+
containers = containers_from_docset(docset_path)
|
33
|
+
{ "containers" => containers.map(&:to_hash) , "ratio" => overall_ratio(containers) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.test_ratio docset_path, passing_ratio
|
37
|
+
containers = containers_from_docset(docset_path)
|
38
|
+
overall_ratio(containers) >= passing_ratio
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def self.containers_from_docset docset_path
|
44
|
+
db_path = File.join(docset_path, 'Contents/Resources/docSet.dsidx')
|
45
|
+
Container.from_sqlite(db_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.overall_ratio containers
|
49
|
+
tokens = containers.map(&:tokens).flatten
|
50
|
+
if tokens.size > 0
|
51
|
+
overall_ratio = tokens.select(&:documented?).size.to_f/tokens.size
|
52
|
+
else
|
53
|
+
overall_ratio = 1
|
54
|
+
end
|
55
|
+
overall_ratio
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docstat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Delisa Mason
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bacon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Coverage statistics for Cocoa documentation sets
|
56
|
+
email:
|
57
|
+
- iskanamagus@gmail.com
|
58
|
+
executables:
|
59
|
+
- docstat
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README.md
|
63
|
+
- CHANGELOG.md
|
64
|
+
files:
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- CHANGELOG.md
|
68
|
+
- README.md
|
69
|
+
- bin/docstat
|
70
|
+
- lib/docstat.rb
|
71
|
+
- lib/docstat/container.rb
|
72
|
+
- lib/docstat/token.rb
|
73
|
+
homepage: https://github.com/docstat
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A command-line utility for checking the documentation coverage of a Cocoa
|
96
|
+
library
|
97
|
+
test_files: []
|
98
|
+
has_rdoc:
|