roxie 0.0.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.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.editorconfig +8 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +16 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +27 -0
- data/bin/roxie +6 -0
- data/features/cli.feature +9 -0
- data/features/generator.feature +8 -0
- data/features/step_definitions/generator_steps.rb +24 -0
- data/features/support/env.rb +13 -0
- data/lib/roxie/cli/doc.rb +102 -0
- data/lib/roxie/cli.rb +61 -0
- data/lib/roxie/extractor.rb +122 -0
- data/lib/roxie/languages.yml +172 -0
- data/lib/roxie/rake/task.rb +42 -0
- data/lib/roxie/version.rb +3 -0
- data/lib/roxie.rb +35 -0
- data/roxie.gemspec +29 -0
- data/spec/anal_retentive_spec.rb +27 -0
- data/spec/spec_helper.rb +9 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75b077a1a282d969b55de2bae3f50284b5837a02
|
4
|
+
data.tar.gz: 7b0554af4dd65c7d1a05faf361eb62726d89e479
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2dcb1026d2d8e9a85123be6f2057b9e390c04fd0a9d9f7f958e17736ea18c4783792e7340ce410a7b6ce2f867e087a9c8bd9b2e3f8d56bec7fbdff164a2b5754
|
7
|
+
data.tar.gz: e1add78a103d5ea6f8c19a2451ad940a52b3945ff7fe17ef8e5259e066922ec04c9d30c3581383f20c5d795bf43741237e2d3d2f24d84e3b912c3bc3f340ced9
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Gem dependencies
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake', group: [:development, :test]
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'cucumber'
|
10
|
+
gem 'fivemat'
|
11
|
+
gem 'aruba'
|
12
|
+
gem 'rspec'
|
13
|
+
|
14
|
+
gem 'simplecov', :require => false
|
15
|
+
gem 'coveralls', :require => false
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Maxwell Barvian
|
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
|
+
# Roxie
|
2
|
+
|
3
|
+
Minimal [Dox](https://github.com/visionmedia/dox) and [Rocco](https://github.com/rtomayko/rocco)-inspired documentation generator written in Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'roxie'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install roxie
|
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 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
require 'roxie/rake/task'
|
4
|
+
Roxie::Rake::Task.new do |t|
|
5
|
+
t.files = ['lib/**/*.rb']
|
6
|
+
t.options = [
|
7
|
+
'--only-tagged',
|
8
|
+
'--force'
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
desc "Run RSpec"
|
14
|
+
RSpec::Core::RakeTask.new do |t|
|
15
|
+
t.pattern = 'spec/**/*_spec.rb'
|
16
|
+
t.rspec_opts = ['--color', '--format nested']
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'cucumber/rake/task'
|
20
|
+
Cucumber::Rake::Task.new(:cucumber, "Run features that should pass") do |t|
|
21
|
+
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Run all tests, both RSpec and Cucumber"
|
25
|
+
task :test => [:spec, :cucumber]
|
26
|
+
|
27
|
+
task :default => :test
|
data/bin/roxie
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Roxie Base CLI
|
2
|
+
|
3
|
+
Scenario: Retrieve detailed help for subcommands
|
4
|
+
Given I run `roxie help doc`
|
5
|
+
Then the output should contain "Options:"
|
6
|
+
|
7
|
+
Scenario: Print out the version number
|
8
|
+
Given I run `roxie version`
|
9
|
+
Then the output should contain "Roxie"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
Given /^an empty app$/ do
|
4
|
+
step %Q{a directory named "empty_app"}
|
5
|
+
step %Q{I cd to "empty_app"}
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^a fixture app "([^\"]*)"$/ do |path|
|
9
|
+
# This step can be reentered from several places but we don't want
|
10
|
+
# to keep re-copying and re-cd-ing into ever-deeper directories
|
11
|
+
next if File.basename(current_dir) == path
|
12
|
+
|
13
|
+
step %Q{a directory named "#{path}"}
|
14
|
+
|
15
|
+
target_path = File.join(PROJECT_ROOT_PATH, "fixtures", path)
|
16
|
+
FileUtils.cp_r(target_path, current_dir)
|
17
|
+
|
18
|
+
step %Q{I cd to "#{path}"}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Provide this Aruba overload in case we're matching something with quotes in it
|
22
|
+
Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
|
23
|
+
check_file_content(file, partial_content, true)
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/../..'))
|
3
|
+
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
|
7
|
+
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
8
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'roxie')
|
9
|
+
require 'aruba/cucumber'
|
10
|
+
|
11
|
+
Before do
|
12
|
+
@aruba_timeout_seconds = 15
|
13
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'pygments.rb'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Roxie
|
5
|
+
module CLI
|
6
|
+
|
7
|
+
class Doc < Thor::Group
|
8
|
+
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def banner
|
13
|
+
"#{basename} doc [INPUT]"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :doc
|
18
|
+
|
19
|
+
check_unknown_options!
|
20
|
+
add_runtime_options!
|
21
|
+
|
22
|
+
argument 'paths',
|
23
|
+
:type => :array,
|
24
|
+
:default => ['{lib,app}/**/*.rb', 'ext/**/*.c']
|
25
|
+
|
26
|
+
class_option 'base-path',
|
27
|
+
:aliases => '-p',
|
28
|
+
:default => './',
|
29
|
+
:desc => "The path to look for the input files in"
|
30
|
+
class_option 'output',
|
31
|
+
:aliases => '-o',
|
32
|
+
:default => './doc/api.json',
|
33
|
+
:desc => "The output file (JSON)"
|
34
|
+
class_option 'exclude',
|
35
|
+
:aliases => '-x',
|
36
|
+
:type => :array,
|
37
|
+
:desc => "Directories to ignore (regexp)"
|
38
|
+
class_option 'language',
|
39
|
+
:aliases => '-l',
|
40
|
+
:desc => "Language of input files, if it can't be inferred"
|
41
|
+
class_option 'only-tagged',
|
42
|
+
:type => :boolean,
|
43
|
+
:default => false,
|
44
|
+
:desc => "Only extract comments that have @tags in them"
|
45
|
+
class_option 'only-single',
|
46
|
+
:type => :boolean,
|
47
|
+
:default => false,
|
48
|
+
:desc => "Only extract single-line comments"
|
49
|
+
class_option 'only-multi',
|
50
|
+
:type => :boolean,
|
51
|
+
:default => false,
|
52
|
+
:desc => "Only extract multi-line comments"
|
53
|
+
|
54
|
+
def parse_paths
|
55
|
+
excluded = (options[:exclude] || []).map do |path|
|
56
|
+
case path
|
57
|
+
when Regexp; path
|
58
|
+
else Regexp.new(path.to_s, Regexp::IGNORECASE)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
inside options[:'base-path'] do
|
62
|
+
@files = paths.
|
63
|
+
map {|p| File.directory?(p) ? "#{p}/**/*" : p }.
|
64
|
+
map {|p| p.include?("*") ? Dir[p].sort_by {|f| f.length } : p }.flatten.
|
65
|
+
reject {|p| !File.file?(p) || excluded.any? {|re| p =~ re } }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def parse_in_order
|
70
|
+
@docs = {}
|
71
|
+
|
72
|
+
while file = @files.shift
|
73
|
+
language =
|
74
|
+
if detected_lang = Pygments::Lexer.find_by_extname(File.extname(file))
|
75
|
+
detected_lang[:name]
|
76
|
+
else
|
77
|
+
options[:language]
|
78
|
+
end
|
79
|
+
data = File.read(File.join(options['base-path'], file))
|
80
|
+
|
81
|
+
opts = {
|
82
|
+
:language => language,
|
83
|
+
:only_tagged => options[:'only-tagged'],
|
84
|
+
:only_single => options[:'only-single'],
|
85
|
+
:only_multi => options[:'only-multi']
|
86
|
+
}.reject { |k, v| v.nil? }
|
87
|
+
|
88
|
+
# Extract relevant comments out of file
|
89
|
+
@docs[file] = Roxie.extract(data, opts)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def generate_output!
|
94
|
+
create_file options[:output] do
|
95
|
+
JSON.pretty_generate @docs
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
data/lib/roxie/cli.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'roxie'
|
2
|
+
require 'thor'
|
3
|
+
require 'thor/group'
|
4
|
+
|
5
|
+
# Include the core CLI items
|
6
|
+
Dir[File.expand_path('../cli/*.rb', __FILE__)].each { |f| require f }
|
7
|
+
|
8
|
+
module Roxie
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
class Base < Thor
|
12
|
+
|
13
|
+
map ['-v', '--version'] => :version, 'd' => :doc
|
14
|
+
|
15
|
+
class << self
|
16
|
+
alias :old_register :register
|
17
|
+
def register(klass, subcommand_name, usage, description, options={})
|
18
|
+
# Keep track of 'subgroups' as well as subcommands
|
19
|
+
self.subgroups << subcommand_name.to_s if klass <= Thor::Group
|
20
|
+
old_register(klass, subcommand_name, usage, description, options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def subgroups
|
24
|
+
@subgroups ||= from_superclass(:subgroups, [])
|
25
|
+
end
|
26
|
+
|
27
|
+
alias :old_task_help :task_help
|
28
|
+
def task_help(shell, command_name)
|
29
|
+
meth = normalize_task_name(command_name)
|
30
|
+
if subgroups.include?(meth)
|
31
|
+
# Make sure to namespace all subcommands appropriately
|
32
|
+
klass = Thor::Util.find_by_namespace(meth)
|
33
|
+
klass.help(shell)
|
34
|
+
else
|
35
|
+
old_task_help(shell, command_name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
alias :command_help :task_help
|
39
|
+
end
|
40
|
+
|
41
|
+
default_task :doc
|
42
|
+
|
43
|
+
desc "version", "Prints Roxie's version information"
|
44
|
+
def version
|
45
|
+
say "Roxie #{Roxie::VERSION}"
|
46
|
+
klass, task = Thor::Util.find_class_and_command_by_namespace("doc:doc")
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing(meth, *args)
|
50
|
+
# Assume the user typed in a file input for the
|
51
|
+
# :doc command
|
52
|
+
Doc.start(args.unshift(meth.to_s), :shell => self.shell)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# Subcommands
|
58
|
+
Base.register Doc, 'doc', "doc [INPUT]", "Generates documentation from input files"
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module Roxie
|
4
|
+
|
5
|
+
# Extract comments and tags from text
|
6
|
+
class Extractor
|
7
|
+
|
8
|
+
def self.default_options
|
9
|
+
{
|
10
|
+
:language => 'Ruby',
|
11
|
+
:only_tagged => false,
|
12
|
+
:only_single => false,
|
13
|
+
:only_multi => false
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(options = {})
|
18
|
+
@options = self.class.default_options.merge(options)
|
19
|
+
unless @language = LANGUAGES[@options[:language]]
|
20
|
+
logger.warn "Roxie doesn't understand #{@options[:language]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Read up to 100KB
|
25
|
+
BYTE_LIMIT = 100_000
|
26
|
+
|
27
|
+
def extract(text)
|
28
|
+
@code = text.dup
|
29
|
+
@scanner = StringScanner.new(@code)
|
30
|
+
|
31
|
+
# Extract comments from text
|
32
|
+
extract_comments
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
TAG = /^@(\w+)[ \t]*(.*$)/.freeze
|
38
|
+
|
39
|
+
def matchers
|
40
|
+
@_matchers ||= @language[:matchers]
|
41
|
+
end
|
42
|
+
|
43
|
+
def extract_comments
|
44
|
+
comments = []
|
45
|
+
until @scanner.eos?
|
46
|
+
break if @scanner.pos >= BYTE_LIMIT
|
47
|
+
|
48
|
+
# Skip over shebangs and encoding information
|
49
|
+
if @scanner.scan(/^#!.+$/) || @scanner.scan(/^#.*coding[=:]\s*[-\w.]+.*$/)
|
50
|
+
# just consume it
|
51
|
+
elsif comment_block =
|
52
|
+
# Single-line comment
|
53
|
+
if !@options[:only_multi] && matchers[:start_single] &&
|
54
|
+
@scanner.bol? && @scanner.scan(matchers[:start_single])
|
55
|
+
extract_single
|
56
|
+
# Multi-line comment
|
57
|
+
elsif !@options[:only_single] && matchers[:start_multi] &&
|
58
|
+
@scanner.scan(matchers[:start_multi])
|
59
|
+
extract_multi
|
60
|
+
end
|
61
|
+
|
62
|
+
# Now that we have our block, let's strip out our tags and
|
63
|
+
# add it to our list
|
64
|
+
tags = extract_tags!(comment_block)
|
65
|
+
comment = {
|
66
|
+
:description => comment_block.join("\n").strip,
|
67
|
+
:tags => tags
|
68
|
+
}
|
69
|
+
|
70
|
+
# Scan until the next non-whitespace character to get our line #
|
71
|
+
@scanner.scan_until(/(?=\S)/)
|
72
|
+
comment[:line] = @code[0..@scanner.pos].count("\n") + 1 unless @scanner.eos?
|
73
|
+
|
74
|
+
comments << comment unless @options[:only_tagged] && comment[:tags].empty?
|
75
|
+
else
|
76
|
+
# Skip line
|
77
|
+
@scanner.skip_until(/\n|\Z/)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
comments
|
82
|
+
end
|
83
|
+
|
84
|
+
def extract_single
|
85
|
+
block = []
|
86
|
+
loop do
|
87
|
+
block << @scanner.scan_until(/\n|\Z/).rstrip
|
88
|
+
break unless @scanner.scan(matchers[:start_single])
|
89
|
+
end
|
90
|
+
block
|
91
|
+
end
|
92
|
+
|
93
|
+
def extract_multi
|
94
|
+
block = @scanner.scan_until(matchers[:end_multi_with])
|
95
|
+
@scanner.skip_until(matchers[:end_multi])
|
96
|
+
|
97
|
+
block.split("\n").map do |line|
|
98
|
+
matchers[:middle_multi] ? line.sub(matchers[:middle_multi], '') : line
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def extract_tags!(block)
|
103
|
+
tags = []
|
104
|
+
block.reverse_each do |line|
|
105
|
+
if match = line.match(TAG)
|
106
|
+
tag = {
|
107
|
+
:type => match[1],
|
108
|
+
:description => match[2].strip
|
109
|
+
}
|
110
|
+
tags << tag
|
111
|
+
|
112
|
+
# Remove this line from the comment block if we match
|
113
|
+
block.delete line
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
tags.reverse
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# All languages known to Roxie.
|
2
|
+
#
|
3
|
+
# Languages should be looked up by their respective
|
4
|
+
# Pygments::Lexer name.
|
5
|
+
#
|
6
|
+
# Please keep alphabetized.
|
7
|
+
|
8
|
+
ActionScript 3:
|
9
|
+
single: "//"
|
10
|
+
|
11
|
+
AppleScript:
|
12
|
+
single: "--"
|
13
|
+
|
14
|
+
Bash:
|
15
|
+
single: "#"
|
16
|
+
|
17
|
+
Batchfile:
|
18
|
+
single: "@?rem"
|
19
|
+
|
20
|
+
C#:
|
21
|
+
single: "//"
|
22
|
+
multi:
|
23
|
+
start: "/**"
|
24
|
+
middle: "*"
|
25
|
+
end: "*/"
|
26
|
+
|
27
|
+
C++:
|
28
|
+
single: "//"
|
29
|
+
multi:
|
30
|
+
start: "/**"
|
31
|
+
middle: "*"
|
32
|
+
end: "*/"
|
33
|
+
|
34
|
+
Clojure:
|
35
|
+
single: ";"
|
36
|
+
|
37
|
+
CMake:
|
38
|
+
single: "#"
|
39
|
+
|
40
|
+
CoffeeScript:
|
41
|
+
single: "#"
|
42
|
+
multi:
|
43
|
+
start: "###"
|
44
|
+
end: "###"
|
45
|
+
|
46
|
+
Common Lisp:
|
47
|
+
single: ";"
|
48
|
+
|
49
|
+
D:
|
50
|
+
single: "//"
|
51
|
+
multi:
|
52
|
+
start: "/**"
|
53
|
+
middle: "*"
|
54
|
+
end: "*/"
|
55
|
+
|
56
|
+
Delphi:
|
57
|
+
single: "//"
|
58
|
+
|
59
|
+
Erlang:
|
60
|
+
single: "%"
|
61
|
+
|
62
|
+
Go:
|
63
|
+
single: "//"
|
64
|
+
multi:
|
65
|
+
start: "/**"
|
66
|
+
middle: "*"
|
67
|
+
end: "*/"
|
68
|
+
|
69
|
+
Haskell:
|
70
|
+
single: "--"
|
71
|
+
|
72
|
+
HTML:
|
73
|
+
multi:
|
74
|
+
start: "<!--"
|
75
|
+
end: "-->"
|
76
|
+
|
77
|
+
INI:
|
78
|
+
single: ";"
|
79
|
+
|
80
|
+
Java:
|
81
|
+
single: "//"
|
82
|
+
multi:
|
83
|
+
start: "/**"
|
84
|
+
middle: "*"
|
85
|
+
end: "*/"
|
86
|
+
|
87
|
+
JavaScript:
|
88
|
+
single: "//"
|
89
|
+
multi:
|
90
|
+
start: "/**"
|
91
|
+
middle: "*"
|
92
|
+
end: "*/"
|
93
|
+
|
94
|
+
Lua:
|
95
|
+
single: "--"
|
96
|
+
|
97
|
+
Nemerle:
|
98
|
+
single: "//"
|
99
|
+
|
100
|
+
Objective-C:
|
101
|
+
single: "//"
|
102
|
+
multi:
|
103
|
+
start: "/**"
|
104
|
+
middle: "*"
|
105
|
+
end: "*/"
|
106
|
+
|
107
|
+
Objective-C++:
|
108
|
+
single: "//"
|
109
|
+
multi:
|
110
|
+
start: "/**"
|
111
|
+
middle: "*"
|
112
|
+
end: "*/"
|
113
|
+
|
114
|
+
Perl:
|
115
|
+
single: "#"
|
116
|
+
|
117
|
+
PHP:
|
118
|
+
single: "//"
|
119
|
+
|
120
|
+
Python:
|
121
|
+
single: "#"
|
122
|
+
|
123
|
+
REBOL:
|
124
|
+
single: ";"
|
125
|
+
|
126
|
+
Ruby:
|
127
|
+
single: "#"
|
128
|
+
multi:
|
129
|
+
start: "=begin"
|
130
|
+
end: "=end"
|
131
|
+
|
132
|
+
Rust:
|
133
|
+
single: "//"
|
134
|
+
multi:
|
135
|
+
start: "/**"
|
136
|
+
middle: "*"
|
137
|
+
end: "*/"
|
138
|
+
|
139
|
+
Sass:
|
140
|
+
single: "//"
|
141
|
+
|
142
|
+
Scala:
|
143
|
+
single: "//"
|
144
|
+
multi:
|
145
|
+
start: "/**"
|
146
|
+
middle: "*"
|
147
|
+
end: "*/"
|
148
|
+
|
149
|
+
SCSS:
|
150
|
+
single: "//"
|
151
|
+
multi:
|
152
|
+
start: "/**"
|
153
|
+
middle: "*"
|
154
|
+
end: "*/"
|
155
|
+
|
156
|
+
SQL:
|
157
|
+
single: "--"
|
158
|
+
|
159
|
+
TeX:
|
160
|
+
single: "%"
|
161
|
+
|
162
|
+
Vala:
|
163
|
+
single: "//"
|
164
|
+
multi:
|
165
|
+
start: "/**"
|
166
|
+
middle: "*"
|
167
|
+
end: "*/"
|
168
|
+
|
169
|
+
XML:
|
170
|
+
multi:
|
171
|
+
start: "<!--"
|
172
|
+
end: "-->"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'roxie/cli'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
|
5
|
+
module Roxie
|
6
|
+
module Rake
|
7
|
+
|
8
|
+
class Task < ::Rake::TaskLib
|
9
|
+
|
10
|
+
attr_accessor :name
|
11
|
+
|
12
|
+
attr_accessor :options
|
13
|
+
|
14
|
+
attr_accessor :files
|
15
|
+
|
16
|
+
attr_accessor :before
|
17
|
+
|
18
|
+
attr_accessor :after
|
19
|
+
|
20
|
+
def initialize(name = :roxie)
|
21
|
+
@name = name
|
22
|
+
@options = []
|
23
|
+
@files = []
|
24
|
+
|
25
|
+
yield self if block_given?
|
26
|
+
|
27
|
+
define
|
28
|
+
end
|
29
|
+
|
30
|
+
def define
|
31
|
+
desc "Generate documentation with Roxie"
|
32
|
+
task(name) do
|
33
|
+
before.call if before.is_a?(Proc)
|
34
|
+
Roxie::CLI::Doc.start options + files.to_a
|
35
|
+
after.call if after.is_a?(Proc)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/roxie.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'roxie/version'
|
2
|
+
require 'roxie/extractor'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Roxie
|
6
|
+
|
7
|
+
# The root path for Roxie's source libraries
|
8
|
+
ROOT = File.expand_path(File.dirname(__FILE__))
|
9
|
+
|
10
|
+
# Languages that Roxie understands
|
11
|
+
LANGUAGES = YAML.load_file(File.join(ROOT, 'roxie', 'languages.yml')).each do |name, lang|
|
12
|
+
# Generate matchers for the language
|
13
|
+
match = {}
|
14
|
+
match[:start_single] = Regexp.new("^\s*#{Regexp.escape(lang['single'])} ") if lang['single']
|
15
|
+
if lang['multi']
|
16
|
+
match[:start_multi] = Regexp.new("^\s*#{Regexp.escape(lang['multi']['start'])}[ ]?") if lang['multi']['start']
|
17
|
+
match[:middle_multi] = Regexp.new("^\s*#{Regexp.escape(lang['multi']['middle'])}[ ]?") if lang['multi']['middle']
|
18
|
+
if lang['multi']['end']
|
19
|
+
match[:end_multi] = Regexp.new("#{Regexp.escape(lang['multi']['end'])}")
|
20
|
+
match[:end_multi_with] = Regexp.new("(?=#{Regexp.escape(lang['multi']['end'])}.*$)")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
lang[:matchers] ||= {}
|
25
|
+
lang[:matchers].merge!(match)
|
26
|
+
end.freeze
|
27
|
+
|
28
|
+
module_function
|
29
|
+
|
30
|
+
# Extract comments from text
|
31
|
+
def extract(text, options = {})
|
32
|
+
Extractor.new(options).extract(text)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/roxie.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'roxie/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "roxie"
|
9
|
+
spec.version = Roxie::VERSION
|
10
|
+
spec.authors = ["Maxwell Barvian"]
|
11
|
+
spec.email = ["max@barvian.me"]
|
12
|
+
spec.description = %q{Yet another documentation generator}
|
13
|
+
spec.summary = %q{Dox-inspired documentation generator that outputs template-less JSON}
|
14
|
+
spec.homepage = "https://github.com/mbarvian/roxie"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.required_ruby_version = ">= 1.9.2"
|
23
|
+
|
24
|
+
# Language detection
|
25
|
+
spec.add_dependency "pygments.rb", "~> 0.5.1"
|
26
|
+
|
27
|
+
# CLI
|
28
|
+
spec.add_dependency "thor", "~> 0.18.1"
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def file(name)
|
4
|
+
File.read(File.join(Roxie::ROOT, 'roxie', name))
|
5
|
+
end
|
6
|
+
|
7
|
+
def assert_sorted(list)
|
8
|
+
previous = nil
|
9
|
+
list.each do |item|
|
10
|
+
if previous
|
11
|
+
expect(previous).to be < item
|
12
|
+
end
|
13
|
+
previous = item
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Support languages" do
|
18
|
+
it "should be listed alphabetically" do
|
19
|
+
languages = []
|
20
|
+
file("languages.yml").lines.each do |line|
|
21
|
+
if line =~ /^([a-zA-Z][\w+\-\# ]*):$/
|
22
|
+
languages << $1.downcase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
assert_sorted languages
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: roxie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maxwell Barvian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pygments.rb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.18.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.18.1
|
41
|
+
description: Yet another documentation generator
|
42
|
+
email:
|
43
|
+
- max@barvian.me
|
44
|
+
executables:
|
45
|
+
- roxie
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .coveralls.yml
|
50
|
+
- .editorconfig
|
51
|
+
- .gitignore
|
52
|
+
- .travis.yml
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/roxie
|
58
|
+
- features/cli.feature
|
59
|
+
- features/generator.feature
|
60
|
+
- features/step_definitions/generator_steps.rb
|
61
|
+
- features/support/env.rb
|
62
|
+
- lib/roxie.rb
|
63
|
+
- lib/roxie/cli.rb
|
64
|
+
- lib/roxie/cli/doc.rb
|
65
|
+
- lib/roxie/extractor.rb
|
66
|
+
- lib/roxie/languages.yml
|
67
|
+
- lib/roxie/rake/task.rb
|
68
|
+
- lib/roxie/version.rb
|
69
|
+
- roxie.gemspec
|
70
|
+
- spec/anal_retentive_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
homepage: https://github.com/mbarvian/roxie
|
73
|
+
licenses:
|
74
|
+
- MIT
|
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: 1.9.2
|
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.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Dox-inspired documentation generator that outputs template-less JSON
|
96
|
+
test_files:
|
97
|
+
- features/cli.feature
|
98
|
+
- features/generator.feature
|
99
|
+
- features/step_definitions/generator_steps.rb
|
100
|
+
- features/support/env.rb
|
101
|
+
- spec/anal_retentive_spec.rb
|
102
|
+
- spec/spec_helper.rb
|