ninjadoc 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/ninjadoc +14 -0
- data/lib/ninjadoc.rb +5 -0
- data/lib/ninjadoc/comment.rb +26 -0
- data/lib/ninjadoc/file.rb +34 -0
- data/lib/ninjadoc/ninjadoc.rb +31 -0
- data/lib/ninjadoc/tomdoc.rb +22 -0
- data/lib/ninjadoc/version.rb +3 -0
- data/ninjadoc.gemspec +21 -0
- data/test/test.coffee +30 -0
- metadata +61 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Nick Radford
|
|
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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Ninjadoc
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'ninjadoc'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install ninjadoc
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/ninjadoc
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require File.expand_path('../../lib/ninjadoc/ninjadoc', __FILE__)
|
|
4
|
+
|
|
5
|
+
nd = Ninjadoc::Ninjadoc.new
|
|
6
|
+
|
|
7
|
+
nd.get_files ARGV[0]
|
|
8
|
+
nd.files.each do |f|
|
|
9
|
+
if f.comment_blocks.length > 0
|
|
10
|
+
f.comment_blocks.each do |comments|
|
|
11
|
+
comments.parse
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/ninjadoc.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative './tomdoc'
|
|
2
|
+
|
|
3
|
+
module Ninjadoc
|
|
4
|
+
class Comment
|
|
5
|
+
attr_accessor :src, :lines, :path, :obj
|
|
6
|
+
|
|
7
|
+
def initialize(path)
|
|
8
|
+
@path = path
|
|
9
|
+
@lines = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def push(line)
|
|
13
|
+
@lines.push line
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def parse
|
|
17
|
+
lines = @lines.slice 1...-1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
parser = Tomdoc::Parser.new
|
|
21
|
+
|
|
22
|
+
td = parser.parse lines.join "\n"
|
|
23
|
+
p td
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative './comment'
|
|
2
|
+
|
|
3
|
+
module Ninjadoc
|
|
4
|
+
class NinjaFile
|
|
5
|
+
attr_accessor :path, :src, :comment_blocks
|
|
6
|
+
|
|
7
|
+
def initialize(path)
|
|
8
|
+
@path = path
|
|
9
|
+
f = File.open path, 'r'
|
|
10
|
+
@src = f.read
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_comment_blocks
|
|
14
|
+
lines = @src.split "\n"
|
|
15
|
+
in_comment = false
|
|
16
|
+
@comment_blocks = []
|
|
17
|
+
comment = Comment.new @path
|
|
18
|
+
lines.each_with_index do |line, num|
|
|
19
|
+
line.strip!
|
|
20
|
+
if line.include? '###' and not in_comment
|
|
21
|
+
in_comment = true
|
|
22
|
+
comment.push line
|
|
23
|
+
elsif line.include? '###' and in_comment
|
|
24
|
+
in_comment = false
|
|
25
|
+
comment.push line
|
|
26
|
+
@comment_blocks.push comment
|
|
27
|
+
comment = Comment.new @path
|
|
28
|
+
elsif in_comment
|
|
29
|
+
comment.push line
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'find'
|
|
2
|
+
require_relative './comment'
|
|
3
|
+
require_relative './file'
|
|
4
|
+
|
|
5
|
+
module Ninjadoc
|
|
6
|
+
class Ninjadoc
|
|
7
|
+
attr_accessor :files
|
|
8
|
+
def self.hello_world
|
|
9
|
+
puts "Hello world!"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_files(base_path = '.')
|
|
13
|
+
@files = []
|
|
14
|
+
Find.find(base_path).each do |path|
|
|
15
|
+
next unless path.end_with? '.coffee'
|
|
16
|
+
f = NinjaFile.new path
|
|
17
|
+
|
|
18
|
+
f.get_comment_blocks
|
|
19
|
+
|
|
20
|
+
@files.push f
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def list_files
|
|
25
|
+
@files.each do |file|
|
|
26
|
+
p file.path
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Ninjadoc
|
|
2
|
+
module Tomdoc
|
|
3
|
+
class Tomdoc
|
|
4
|
+
def initialize(args = {})
|
|
5
|
+
@description = args.fetch :description
|
|
6
|
+
@arguments = args.fetch :arguments
|
|
7
|
+
@returns = args.fetch :returns
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Parser
|
|
12
|
+
def parse(string)
|
|
13
|
+
description = string.match(/^(.+)\n\n/)[1]
|
|
14
|
+
arguments = string.scan(/^(\w+)\s+-\s+(.+)/)
|
|
15
|
+
returns = string.match(/^Returns\s+(.+)/)[1]
|
|
16
|
+
|
|
17
|
+
Tomdoc.new(:description => description, :arguments => arguments, :returns => returns)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/ninjadoc.gemspec
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/ninjadoc/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Nick Radford"]
|
|
6
|
+
gem.email = ["nick@nicholasradford.com"]
|
|
7
|
+
gem.description = "Tomdoc for Coffeescript"
|
|
8
|
+
gem.summary = "Tomdoc for Coffeescript"
|
|
9
|
+
gem.homepage = "http://github.com/nickradford/ninjadoc"
|
|
10
|
+
|
|
11
|
+
gem.bindir = 'bin'
|
|
12
|
+
|
|
13
|
+
gem.files = `git ls-files`.split($\)
|
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
16
|
+
gem.name = "ninjadoc"
|
|
17
|
+
gem.require_paths = ["lib"]
|
|
18
|
+
gem.version = Ninjadoc::VERSION
|
|
19
|
+
|
|
20
|
+
gem.rubyforge_project = 'ninjadoc'
|
|
21
|
+
end
|
data/test/test.coffee
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class Area
|
|
2
|
+
###
|
|
3
|
+
Find the area of a Circle.
|
|
4
|
+
|
|
5
|
+
r - The radius of the circle.
|
|
6
|
+
|
|
7
|
+
Returns the area of the circle with radius [r].
|
|
8
|
+
###
|
|
9
|
+
circle: (r) -> Math.pi * r * r
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
###
|
|
13
|
+
Find the area of a square.
|
|
14
|
+
|
|
15
|
+
len - The length of the sides.
|
|
16
|
+
|
|
17
|
+
Returns the area of a square with length [len].
|
|
18
|
+
###
|
|
19
|
+
square: (len) -> len * len
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
###
|
|
23
|
+
Find the area of a rectangle.
|
|
24
|
+
|
|
25
|
+
x - The length of the x axis.
|
|
26
|
+
y - The length of the y axis.
|
|
27
|
+
|
|
28
|
+
Returns the area of rectangle with lengths [x] and [y].
|
|
29
|
+
###
|
|
30
|
+
rectangle: (x, y) -> x * y
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ninjadoc
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Nick Radford
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-05-19 00:00:00.000000000Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Tomdoc for Coffeescript
|
|
15
|
+
email:
|
|
16
|
+
- nick@nicholasradford.com
|
|
17
|
+
executables:
|
|
18
|
+
- ninjadoc
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- .gitignore
|
|
23
|
+
- Gemfile
|
|
24
|
+
- LICENSE
|
|
25
|
+
- README.md
|
|
26
|
+
- Rakefile
|
|
27
|
+
- bin/ninjadoc
|
|
28
|
+
- lib/ninjadoc.rb
|
|
29
|
+
- lib/ninjadoc/comment.rb
|
|
30
|
+
- lib/ninjadoc/file.rb
|
|
31
|
+
- lib/ninjadoc/ninjadoc.rb
|
|
32
|
+
- lib/ninjadoc/tomdoc.rb
|
|
33
|
+
- lib/ninjadoc/version.rb
|
|
34
|
+
- ninjadoc.gemspec
|
|
35
|
+
- test/test.coffee
|
|
36
|
+
homepage: http://github.com/nickradford/ninjadoc
|
|
37
|
+
licenses: []
|
|
38
|
+
post_install_message:
|
|
39
|
+
rdoc_options: []
|
|
40
|
+
require_paths:
|
|
41
|
+
- lib
|
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
|
+
none: false
|
|
44
|
+
requirements:
|
|
45
|
+
- - ! '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
requirements: []
|
|
55
|
+
rubyforge_project: ninjadoc
|
|
56
|
+
rubygems_version: 1.8.10
|
|
57
|
+
signing_key:
|
|
58
|
+
specification_version: 3
|
|
59
|
+
summary: Tomdoc for Coffeescript
|
|
60
|
+
test_files:
|
|
61
|
+
- test/test.coffee
|