distil 0.11.6 → 0.11.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/assets/distil.js +2 -1
- data/bin/distil +2 -0
- data/distil.gemspec +152 -2
- data/lib/distil/configurable.rb +3 -1
- data/lib/distil/error-reporter.rb +2 -0
- data/lib/distil/product/concatenated.rb +1 -3
- data/lib/distil/product/debug.rb +1 -3
- data/lib/distil/product/javascript-product.rb +2 -8
- data/lib/distil/product.rb +5 -5
- data/lib/distil/project/distil-project.rb +18 -1
- data/lib/distil/project/external-project.rb +1 -1
- data/lib/distil/project/remote-project.rb +39 -0
- data/lib/distil/project.rb +18 -9
- data/lib/distil/target.rb +13 -12
- data/lib/distil/task/css-dependency-task.rb +1 -1
- data/lib/distil/task/validate-js-task.rb +6 -1
- data/lib/distil.rb +1 -0
- data/vendor/pdoc/LICENSE +16 -0
- data/vendor/pdoc/PDoc.tmbundle/Commands/Continue PDoc Comment.tmCommand +39 -0
- data/vendor/pdoc/PDoc.tmbundle/Macros/Collapse PDoc Blocks.tmMacro +4084 -0
- data/vendor/pdoc/PDoc.tmbundle/Macros/Expand PDoc Blocks.tmMacro +1388 -0
- data/vendor/pdoc/PDoc.tmbundle/Preferences/PDoc.tmPreferences +50 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/class.tmSnippet +24 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/constant.tmSnippet +22 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/event.tmSnippet +16 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/method.tmSnippet +22 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/mixin.tmSnippet +23 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/namespace.tmSnippet +24 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/param.tmSnippet +16 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/property.tmSnippet +22 -0
- data/vendor/pdoc/PDoc.tmbundle/Snippets/section.tmSnippet +23 -0
- data/vendor/pdoc/PDoc.tmbundle/Syntaxes/PDoc.tmLanguage +33 -0
- data/vendor/pdoc/PDoc.tmbundle/info.plist +22 -0
- data/vendor/pdoc/README.markdown +34 -0
- data/vendor/pdoc/Rakefile +46 -0
- data/vendor/pdoc/bin/pdoc +58 -0
- data/vendor/pdoc/lib/pdoc/error.rb +4 -0
- data/vendor/pdoc/lib/pdoc/generators/abstract_generator.rb +16 -0
- data/vendor/pdoc/lib/pdoc/generators/html/helpers.rb +256 -0
- data/vendor/pdoc/lib/pdoc/generators/html/page.rb +71 -0
- data/vendor/pdoc/lib/pdoc/generators/html/syntax_highlighter.rb +41 -0
- data/vendor/pdoc/lib/pdoc/generators/html/template.rb +37 -0
- data/vendor/pdoc/lib/pdoc/generators/html/website.rb +194 -0
- data/vendor/pdoc/lib/pdoc/generators/html.rb +8 -0
- data/vendor/pdoc/lib/pdoc/generators/json.rb +15 -0
- data/vendor/pdoc/lib/pdoc/generators/pythonesque.rb +105 -0
- data/vendor/pdoc/lib/pdoc/generators.rb +6 -0
- data/vendor/pdoc/lib/pdoc/models/argument.rb +37 -0
- data/vendor/pdoc/lib/pdoc/models/base.rb +107 -0
- data/vendor/pdoc/lib/pdoc/models/callable.rb +19 -0
- data/vendor/pdoc/lib/pdoc/models/class.rb +28 -0
- data/vendor/pdoc/lib/pdoc/models/class_method.rb +18 -0
- data/vendor/pdoc/lib/pdoc/models/class_property.rb +9 -0
- data/vendor/pdoc/lib/pdoc/models/constant.rb +9 -0
- data/vendor/pdoc/lib/pdoc/models/constructor.rb +14 -0
- data/vendor/pdoc/lib/pdoc/models/container.rb +114 -0
- data/vendor/pdoc/lib/pdoc/models/entity.rb +54 -0
- data/vendor/pdoc/lib/pdoc/models/instance_method.rb +18 -0
- data/vendor/pdoc/lib/pdoc/models/instance_property.rb +9 -0
- data/vendor/pdoc/lib/pdoc/models/mixin.rb +10 -0
- data/vendor/pdoc/lib/pdoc/models/namespace.rb +10 -0
- data/vendor/pdoc/lib/pdoc/models/root.rb +27 -0
- data/vendor/pdoc/lib/pdoc/models/section.rb +19 -0
- data/vendor/pdoc/lib/pdoc/models/signature.rb +27 -0
- data/vendor/pdoc/lib/pdoc/models/utility.rb +11 -0
- data/vendor/pdoc/lib/pdoc/models.rb +47 -0
- data/vendor/pdoc/lib/pdoc/parser/argument_description_nodes.rb +21 -0
- data/vendor/pdoc/lib/pdoc/parser/basic_nodes.rb +31 -0
- data/vendor/pdoc/lib/pdoc/parser/description_nodes.rb +42 -0
- data/vendor/pdoc/lib/pdoc/parser/documentation_nodes.rb +483 -0
- data/vendor/pdoc/lib/pdoc/parser/ebnf_arguments_nodes.rb +58 -0
- data/vendor/pdoc/lib/pdoc/parser/ebnf_expression_nodes.rb +227 -0
- data/vendor/pdoc/lib/pdoc/parser/fragment.rb +55 -0
- data/vendor/pdoc/lib/pdoc/parser/section_content_nodes.rb +19 -0
- data/vendor/pdoc/lib/pdoc/parser/tags_nodes.rb +14 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/argument_description.treetop +31 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/basic.treetop +41 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/description.treetop +7 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/documentation.treetop +75 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_arguments.treetop +33 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_expression.treetop +70 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_javascript.treetop +54 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/events.treetop +17 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/section_content.treetop +8 -0
- data/vendor/pdoc/lib/pdoc/parser/treetop_files/tags.treetop +31 -0
- data/vendor/pdoc/lib/pdoc/parser.rb +109 -0
- data/vendor/pdoc/lib/pdoc/runner.rb +110 -0
- data/vendor/pdoc/lib/pdoc/treemaker.rb +94 -0
- data/vendor/pdoc/lib/pdoc.rb +32 -0
- data/vendor/pdoc/pdoc-0.2.0.gem +0 -0
- data/vendor/pdoc/pdoc.gemspec +31 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/alias.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/class.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/class_deprecated.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/class_method.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/class_property.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/constant.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/constructor.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/deprecated.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/description.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/information.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/instance_method.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/instance_property.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/method.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/method_deprecated.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/mixin.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/namespace.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/property.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/related_to.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/search-background.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/section-background.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/section.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/selected-section-background.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/subclass.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/superclass.png +0 -0
- data/vendor/pdoc/templates/html/assets/images/pdoc/utility.png +0 -0
- data/vendor/pdoc/templates/html/assets/javascripts/pdoc/application.js +478 -0
- data/vendor/pdoc/templates/html/assets/javascripts/pdoc/prototype.js +4874 -0
- data/vendor/pdoc/templates/html/assets/javascripts/pdoc/tabs.js +506 -0
- data/vendor/pdoc/templates/html/assets/stylesheets/pdoc/api.css +677 -0
- data/vendor/pdoc/templates/html/assets/stylesheets/pdoc/pygments.css +62 -0
- data/vendor/pdoc/templates/html/helpers.rb +35 -0
- data/vendor/pdoc/templates/html/index.erb +18 -0
- data/vendor/pdoc/templates/html/item_index.js.erb +6 -0
- data/vendor/pdoc/templates/html/layout.erb +67 -0
- data/vendor/pdoc/templates/html/leaf.erb +22 -0
- data/vendor/pdoc/templates/html/node.erb +30 -0
- data/vendor/pdoc/templates/html/partials/class_relationships.erb +19 -0
- data/vendor/pdoc/templates/html/partials/classes.erb +7 -0
- data/vendor/pdoc/templates/html/partials/constructor.erb +5 -0
- data/vendor/pdoc/templates/html/partials/description.erb +5 -0
- data/vendor/pdoc/templates/html/partials/link_list.erb +1 -0
- data/vendor/pdoc/templates/html/partials/method_signatures.erb +14 -0
- data/vendor/pdoc/templates/html/partials/methodized_note.erb +9 -0
- data/vendor/pdoc/templates/html/partials/mixins.erb +7 -0
- data/vendor/pdoc/templates/html/partials/namespaces.erb +7 -0
- data/vendor/pdoc/templates/html/partials/related_utilities.erb +5 -0
- data/vendor/pdoc/templates/html/partials/relationships.erb +11 -0
- data/vendor/pdoc/templates/html/partials/short_description_list.erb +7 -0
- data/vendor/pdoc/templates/html/partials/title.erb +22 -0
- data/vendor/pdoc/templates/html/section.erb +18 -0
- data/vendor/pdoc/test/fixtures/ajax.js +809 -0
- data/vendor/pdoc/test/fixtures/prototype.js +5789 -0
- data/vendor/pdoc/test/fixtures/test.txt +1 -0
- data/vendor/pdoc/test/fixtures/text.txt +13 -0
- data/vendor/pdoc/test/unit/parser/argument_description_test.rb +40 -0
- data/vendor/pdoc/test/unit/parser/basic_test.rb +55 -0
- data/vendor/pdoc/test/unit/parser/description_test.rb +34 -0
- data/vendor/pdoc/test/unit/parser/documentation_test.rb +520 -0
- data/vendor/pdoc/test/unit/parser/ebnf_arguments_test.rb +81 -0
- data/vendor/pdoc/test/unit/parser/ebnf_expression_test.rb +382 -0
- data/vendor/pdoc/test/unit/parser/ebnf_javascript_test.rb +37 -0
- data/vendor/pdoc/test/unit/parser/events_test.rb +27 -0
- data/vendor/pdoc/test/unit/parser/section_content_test.rb +44 -0
- data/vendor/pdoc/test/unit/parser/tags_test.rb +39 -0
- data/vendor/pdoc/test/unit/parser/test_fragment.rb +80 -0
- data/vendor/pdoc/test/unit/parser_test_helper.rb +62 -0
- data/vendor/pdoc/test/unit/runner/basic_test.rb +14 -0
- data/vendor/pdoc/test/unit/templates/html_helpers_test.rb +25 -0
- data/vendor/pdoc/vendor/albino.rb +122 -0
- data/vendor/pdoc/website/html/documentation.html +280 -0
- data/vendor/pdoc/website/html/images/pdoc.jpg +0 -0
- data/vendor/pdoc/website/html/index.html +84 -0
- data/vendor/pdoc/website/html/stylesheets/main.css +73 -0
- data/vendor/pdoc/website/html/stylesheets/reset.css +18 -0
- data/vendor/pdoc/website/markdown/syntax.markdown +226 -0
- metadata +153 -3
@@ -0,0 +1,80 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "../../../lib/pdoc/parser/fragment"
|
3
|
+
require "../../../lib/pdoc/error"
|
4
|
+
|
5
|
+
class TestFragment < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_normalize_empty_fragment
|
8
|
+
fragment =<<EOF
|
9
|
+
/**
|
10
|
+
*
|
11
|
+
*
|
12
|
+
**/
|
13
|
+
EOF
|
14
|
+
fragment = PDoc::Fragment.new(fragment, 0)
|
15
|
+
lines = fragment.normalize
|
16
|
+
assert_equal("", lines[0])
|
17
|
+
assert_equal("", lines[1])
|
18
|
+
assert_equal("", lines.last)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_normalize_basic_fragment
|
22
|
+
fragment =<<EOF
|
23
|
+
/**
|
24
|
+
* foo
|
25
|
+
* bar
|
26
|
+
**/
|
27
|
+
EOF
|
28
|
+
fragment = PDoc::Fragment.new(fragment, 0)
|
29
|
+
lines = fragment.normalize
|
30
|
+
assert_equal("", lines[0])
|
31
|
+
assert_equal("foo", lines[1])
|
32
|
+
assert_equal(" bar", lines[2])
|
33
|
+
assert_equal("", lines.last)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_normalize_broken_fragment
|
37
|
+
fragment =<<EOF
|
38
|
+
/**
|
39
|
+
* foo
|
40
|
+
*bar
|
41
|
+
**/
|
42
|
+
EOF
|
43
|
+
assert_raise PDoc::Fragment::InconsistentPrefixError do
|
44
|
+
PDoc::Fragment.new(fragment, 0).normalize
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_empty_prefix
|
49
|
+
fragment =<<EOF
|
50
|
+
/**
|
51
|
+
foo
|
52
|
+
bar
|
53
|
+
**/
|
54
|
+
EOF
|
55
|
+
fragment = PDoc::Fragment.new(fragment, 0)
|
56
|
+
assert_equal("", fragment.prefix)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_whitespace_prefix
|
60
|
+
fragment =<<EOF
|
61
|
+
/**
|
62
|
+
foo
|
63
|
+
bar
|
64
|
+
**/
|
65
|
+
EOF
|
66
|
+
fragment = PDoc::Fragment.new(fragment, 0)
|
67
|
+
assert_equal(" ", fragment.prefix)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_mixed_prefix
|
71
|
+
fragment =<<EOF
|
72
|
+
/**
|
73
|
+
* foo
|
74
|
+
* bar
|
75
|
+
**/
|
76
|
+
EOF
|
77
|
+
fragment = PDoc::Fragment.new(fragment, 0)
|
78
|
+
assert_equal(" * ", fragment.prefix)
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "pdoc")) unless defined?(PDoc)
|
4
|
+
|
5
|
+
class Treetop::Runtime::SyntaxNode
|
6
|
+
def method_missing(method, *args)
|
7
|
+
raise "Node representing '#{text_value}' does not respond to '#{method}'"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module PDocTestHelper
|
12
|
+
def parse(input)
|
13
|
+
result = @parser.parse(input)
|
14
|
+
unless result
|
15
|
+
puts "\n" << @parser.terminal_failures.join("\n") << "\n"
|
16
|
+
end
|
17
|
+
assert !result.nil?
|
18
|
+
result
|
19
|
+
end
|
20
|
+
|
21
|
+
def blank_line
|
22
|
+
"\n * \n "
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse_file(filename)
|
26
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), "..", "fixtures", filename))
|
27
|
+
file = File.open(path){ |f| f.read }
|
28
|
+
file.gsub!(/\r\n/, "\n")
|
29
|
+
file = file.split("\n").map do |line|
|
30
|
+
line.gsub(/\s+$/, '')
|
31
|
+
end.join("\n")
|
32
|
+
parse(file)
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert_parsed(input)
|
36
|
+
assert !parse(input).nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
def assert_file_parsed(filename)
|
40
|
+
assert !parse_file(filename).nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_not_parsed(input)
|
44
|
+
assert @parser.parse(input).nil?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stolen from Rails
|
49
|
+
unless :test.respond_to?(:to_proc)
|
50
|
+
class Symbol
|
51
|
+
# Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
|
52
|
+
#
|
53
|
+
# # The same as people.collect { |p| p.name }
|
54
|
+
# people.collect(&:name)
|
55
|
+
#
|
56
|
+
# # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
|
57
|
+
# people.select(&:manager?).collect(&:salary)
|
58
|
+
def to_proc
|
59
|
+
Proc.new { |*args| args.shift.__send__(self, *args) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
|
2
|
+
|
3
|
+
class BasicTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_restores_original_dir
|
6
|
+
original_dir = Dir.pwd
|
7
|
+
puts "*** #{original_dir}"
|
8
|
+
PDoc::Runner.new("test/fixtures/test.txt",
|
9
|
+
:output => 'test/output',
|
10
|
+
:templates => 'templates/html'
|
11
|
+
).run
|
12
|
+
assert_equal original_dir, Dir.pwd
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. .. templates html helpers]))
|
3
|
+
|
4
|
+
class HtmlHelpersTest < Test::Unit::TestCase
|
5
|
+
include PDocTestHelper
|
6
|
+
# include EbnfExpression
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@helper = Object.new
|
10
|
+
class << @helper
|
11
|
+
attr_accessor :root
|
12
|
+
include PDoc::Generators::Html::Helpers::BaseHelper
|
13
|
+
include PDoc::Generators::Html::Helpers::LinkHelper
|
14
|
+
include PDoc::Generators::Html::Helpers::CodeHelper
|
15
|
+
|
16
|
+
def path_to(foo)
|
17
|
+
'/some/path' # Not tested here, although it should
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_truth
|
23
|
+
assert true
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
##
|
2
|
+
# Wrapper for the Pygments command line tool, pygmentize.
|
3
|
+
#
|
4
|
+
# Pygments: http://pygments.org/
|
5
|
+
#
|
6
|
+
# Assumes pygmentize is in the path. If not, set its location
|
7
|
+
# with Albino.bin = '/path/to/pygmentize'
|
8
|
+
#
|
9
|
+
# Use like so:
|
10
|
+
#
|
11
|
+
# @syntaxer = Albino.new('/some/file.rb', :ruby)
|
12
|
+
# puts @syntaxer.colorize
|
13
|
+
#
|
14
|
+
# This'll print out an HTMLized, Ruby-highlighted version
|
15
|
+
# of '/some/file.rb'.
|
16
|
+
#
|
17
|
+
# To use another formatter, pass it as the third argument:
|
18
|
+
#
|
19
|
+
# @syntaxer = Albino.new('/some/file.rb', :ruby, :bbcode)
|
20
|
+
# puts @syntaxer.colorize
|
21
|
+
#
|
22
|
+
# You can also use the #colorize class method:
|
23
|
+
#
|
24
|
+
# puts Albino.colorize('/some/file.rb', :ruby)
|
25
|
+
#
|
26
|
+
# Another also: you get a #to_s, for somewhat nicer use in Rails views.
|
27
|
+
#
|
28
|
+
# ... helper file ...
|
29
|
+
# def highlight(text)
|
30
|
+
# Albino.new(text, :ruby)
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# ... view file ...
|
34
|
+
# <%= highlight text %>
|
35
|
+
#
|
36
|
+
# The default lexer is 'text'. You need to specify a lexer yourself;
|
37
|
+
# because we are using STDIN there is no auto-detect.
|
38
|
+
#
|
39
|
+
# To see all lexers and formatters available, run `pygmentize -L`.
|
40
|
+
#
|
41
|
+
# Chris Wanstrath // chris@ozmm.org
|
42
|
+
# GitHub // http://github.com
|
43
|
+
#
|
44
|
+
require 'open4'
|
45
|
+
|
46
|
+
class Albino
|
47
|
+
@@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
|
48
|
+
|
49
|
+
def self.bin=(path)
|
50
|
+
@@bin = path
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.colorize(*args)
|
54
|
+
new(*args).colorize
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(target, lexer = :text, format = :html)
|
58
|
+
@target = File.exists?(target) ? File.read(target) : target rescue target
|
59
|
+
@options = { :l => lexer, :f => format, :O => 'encoding=utf-8' }
|
60
|
+
end
|
61
|
+
|
62
|
+
def execute(command)
|
63
|
+
output = ''
|
64
|
+
Open4.popen4(command) do |pid, stdin, stdout, stderr|
|
65
|
+
stdin.puts @target
|
66
|
+
stdin.close
|
67
|
+
output = stdout.read.strip
|
68
|
+
[stdout, stderr].each { |io| io.close }
|
69
|
+
end
|
70
|
+
output
|
71
|
+
end
|
72
|
+
|
73
|
+
def colorize(options = {})
|
74
|
+
html = execute(@@bin + convert_options(options))
|
75
|
+
# Work around an RDiscount bug: http://gist.github.com/97682
|
76
|
+
html.to_s.sub(%r{</pre></div>\Z}, "</pre>\n</div>")
|
77
|
+
end
|
78
|
+
alias_method :to_s, :colorize
|
79
|
+
|
80
|
+
def convert_options(options = {})
|
81
|
+
@options.merge(options).inject('') do |string, (flag, value)|
|
82
|
+
string + " -#{flag} #{value}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
if $0 == __FILE__
|
88
|
+
require 'rubygems'
|
89
|
+
require 'test/spec'
|
90
|
+
require 'mocha'
|
91
|
+
begin require 'redgreen'; rescue LoadError; end
|
92
|
+
|
93
|
+
context "Albino" do
|
94
|
+
setup do
|
95
|
+
@syntaxer = Albino.new(__FILE__, :ruby)
|
96
|
+
end
|
97
|
+
|
98
|
+
specify "defaults to text" do
|
99
|
+
syntaxer = Albino.new(__FILE__)
|
100
|
+
syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
|
101
|
+
syntaxer.colorize
|
102
|
+
end
|
103
|
+
|
104
|
+
specify "accepts options" do
|
105
|
+
@syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
|
106
|
+
@syntaxer.colorize
|
107
|
+
end
|
108
|
+
|
109
|
+
specify "works with strings" do
|
110
|
+
syntaxer = Albino.new('class New; end', :ruby)
|
111
|
+
assert_match %r(highlight), syntaxer.colorize
|
112
|
+
end
|
113
|
+
|
114
|
+
specify "aliases to_s" do
|
115
|
+
assert_equal @syntaxer.colorize, @syntaxer.to_s
|
116
|
+
end
|
117
|
+
|
118
|
+
specify "class method colorize" do
|
119
|
+
assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
|
4
|
+
<html lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
7
|
+
<title>PDoc</title>
|
8
|
+
<meta name="generator" content="TextMate http://macromates.com/">
|
9
|
+
<meta name="author" content="Tobie Langel">
|
10
|
+
<!-- Date: 2008-02-25 -->
|
11
|
+
<link rel="stylesheet" href="/stylesheets/reset.css" type="text/css" media="screen" charset="utf-8">
|
12
|
+
<link rel="stylesheet" href="/stylesheets/main.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
13
|
+
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div id="wrapper">
|
17
|
+
<div id="header">
|
18
|
+
<h1><a href="/"><img src="/images/pdoc.jpg" alt="PDoc" /></a></h1>
|
19
|
+
</div>
|
20
|
+
<div id="navigation">
|
21
|
+
<ul>
|
22
|
+
<li><a href="/documentation.html">documentation</a></li>
|
23
|
+
<li><a href="http://github.com/tobie/pdoc/tree/master">source code</a></li>
|
24
|
+
<li><a href="http://prototype.lighthouseapp.com/projects/8889-pdoc/">bug tracker</a></li>
|
25
|
+
<li><a href="http://groups.google.com/group/pdoc">mailing list</a></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
<div id="content">
|
29
|
+
<h1 id="documentation">Documentation</h1>
|
30
|
+
|
31
|
+
<h2 id="comments">Comments</h2>
|
32
|
+
|
33
|
+
<p>Documentation comments start with <code>/**</code> and end with <code>**/</code>. Each new line starts with <code>*</code>. </p>
|
34
|
+
|
35
|
+
<pre><code>/** ...
|
36
|
+
* ...
|
37
|
+
**/
|
38
|
+
</code></pre>
|
39
|
+
|
40
|
+
<h2 id="tags">Tags</h2>
|
41
|
+
|
42
|
+
<p>The first line of a comment is reserved for tags. Tags are separated by a comma followed by whitespace (“, “). They can be either a tag name or a key / value pair separated by a colon and a space (<code>:</code>).</p>
|
43
|
+
|
44
|
+
<p>Currently accepted tags are: <code>deprecated</code>, <code>section:</code>, <code>alias of:</code>, <code>related to:</code></p>
|
45
|
+
|
46
|
+
<pre><code>/** deprecated, section: DOM, alias of: Element#descendantOf
|
47
|
+
* Element#childOf(@element, className) -> Element
|
48
|
+
* ...
|
49
|
+
**/
|
50
|
+
</code></pre>
|
51
|
+
|
52
|
+
<h2 id="ebnf">EBNF</h2>
|
53
|
+
|
54
|
+
<p>The lines directly following tags are reserved for the EBNF description of the documented object. Typically, there’s only one EBNF per documented object. However, some objects might require more than one.</p>
|
55
|
+
|
56
|
+
<pre><code>/**
|
57
|
+
* Element#down(@element[, cssSelector][, index]) -> Element | null
|
58
|
+
* ...
|
59
|
+
**/
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Element#writeAttribute(@element, attribute[, value = true]) -> Element
|
63
|
+
* Element#writeAttribute(@element, attributes) -> Element
|
64
|
+
* ...
|
65
|
+
**/
|
66
|
+
</code></pre>
|
67
|
+
|
68
|
+
<h3 id="arguments">Arguments</h3>
|
69
|
+
|
70
|
+
<p>For all methods, functions, etc. parentheses around the arguments are required even if no arguments are present.
|
71
|
+
The syntax for arguments is as follows:</p>
|
72
|
+
|
73
|
+
<h4 id="required_arguments">required arguments</h4>
|
74
|
+
|
75
|
+
<pre><code>/**
|
76
|
+
* Event.stop(event) -> Event
|
77
|
+
* ...
|
78
|
+
**/
|
79
|
+
</code></pre>
|
80
|
+
|
81
|
+
<h4 id="optional_arguments">optional arguments</h4>
|
82
|
+
|
83
|
+
<p>Optional arguments are surrounded by squared brackets (<code>[]</code>).</p>
|
84
|
+
|
85
|
+
<pre><code>/**
|
86
|
+
* String#evalJSON([sanitize]) -> Object | Array
|
87
|
+
* ...
|
88
|
+
**/
|
89
|
+
</code></pre>
|
90
|
+
|
91
|
+
<p>A default value may be indicated using the equal sign (<code>=</code>).</p>
|
92
|
+
|
93
|
+
<pre><code>/**
|
94
|
+
* String#evalJSON([sanitize = false]) -> Object | Array
|
95
|
+
* ...
|
96
|
+
**/
|
97
|
+
</code></pre>
|
98
|
+
|
99
|
+
<p>Note that the argument separating comas belong <em>inside</em> the brackets.</p>
|
100
|
+
|
101
|
+
<pre><code>/**
|
102
|
+
* Event.findElement(event[, cssSelector]) -> Element | null
|
103
|
+
* ...
|
104
|
+
**/
|
105
|
+
</code></pre>
|
106
|
+
|
107
|
+
<p>Arguments can be described below the EBNF description using the following syntax:</p>
|
108
|
+
|
109
|
+
<pre><code>- argumentName (acceptedTypes...): description.
|
110
|
+
</code></pre>
|
111
|
+
|
112
|
+
<p>For example (notice the 4 space indent in the last line): </p>
|
113
|
+
|
114
|
+
<pre><code>/**
|
115
|
+
* Event.findElement(event[, cssSelector]) -> Element | null
|
116
|
+
* - event (Event): a native Event instance
|
117
|
+
* - cssSelector (String): a optional CSS selector which uses
|
118
|
+
* the same syntax found in regular CSS.
|
119
|
+
**/
|
120
|
+
</code></pre>
|
121
|
+
|
122
|
+
<h3 id="supported_ebnf_types">Supported EBNF types</h3>
|
123
|
+
|
124
|
+
<h4 id="namespace">Namespace</h4>
|
125
|
+
|
126
|
+
<pre><code>/**
|
127
|
+
* Ajax
|
128
|
+
* ...
|
129
|
+
**/
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Prototype.Browser
|
133
|
+
* ...
|
134
|
+
**/
|
135
|
+
</code></pre>
|
136
|
+
|
137
|
+
<h4 id="classes">Classes</h4>
|
138
|
+
|
139
|
+
<p>Classes require a <code>class</code> prefix:</p>
|
140
|
+
|
141
|
+
<pre><code>/**
|
142
|
+
* class Ajax.Base
|
143
|
+
* ...
|
144
|
+
**/
|
145
|
+
</code></pre>
|
146
|
+
|
147
|
+
<p>Sub-classes can indicate their parent just like in the Ruby syntax:</p>
|
148
|
+
|
149
|
+
<pre><code>/**
|
150
|
+
* class Ajax.Request < Ajax.Base
|
151
|
+
* ...
|
152
|
+
**/
|
153
|
+
</code></pre>
|
154
|
+
|
155
|
+
<p>Where <code>Ajax.Base</code> is the parent class and <code>Ajax.Request</code> the subclass.</p>
|
156
|
+
|
157
|
+
<p>Included mixins are indicated like so:</p>
|
158
|
+
|
159
|
+
<pre><code>/**
|
160
|
+
* class CustomHash
|
161
|
+
* includes Enumerable, Comparable
|
162
|
+
**/
|
163
|
+
</code></pre>
|
164
|
+
|
165
|
+
<h4 id="mixins">Mixins</h4>
|
166
|
+
|
167
|
+
<p>Mixins are indicated by a <code>mixin</code> prefix:</p>
|
168
|
+
|
169
|
+
<pre><code>/**
|
170
|
+
* mixin Enumerable
|
171
|
+
* ...
|
172
|
+
**/
|
173
|
+
</code></pre>
|
174
|
+
|
175
|
+
<h4 id="constructors">Constructors</h4>
|
176
|
+
|
177
|
+
<p>Constructors require the <code>new</code> prefix and their arguments.</p>
|
178
|
+
|
179
|
+
<pre><code>/**
|
180
|
+
* new Element(tagName[, attributes])
|
181
|
+
* ...
|
182
|
+
**/
|
183
|
+
|
184
|
+
/**
|
185
|
+
* new Foobar()
|
186
|
+
* ...
|
187
|
+
**/
|
188
|
+
</code></pre>
|
189
|
+
|
190
|
+
<h4 id="klass_methods">Klass Methods</h4>
|
191
|
+
|
192
|
+
<p>Klass methods are identified by a dot (<code>.</code>).</p>
|
193
|
+
|
194
|
+
<pre><code>/**
|
195
|
+
* Array.from([iterable]) -> Array
|
196
|
+
* ...
|
197
|
+
**/
|
198
|
+
</code></pre>
|
199
|
+
|
200
|
+
<h4 id="instance_methods">Instance Methods</h4>
|
201
|
+
|
202
|
+
<p>Instance methods are identified by the hash symbol (<code>#</code>).</p>
|
203
|
+
|
204
|
+
<pre><code>/**
|
205
|
+
* Array#first() -> Array element
|
206
|
+
* ...
|
207
|
+
**/
|
208
|
+
</code></pre>
|
209
|
+
|
210
|
+
<h4 id="utilities">Utilities</h4>
|
211
|
+
|
212
|
+
<p>Utilities are global functions starting with a dollar-sign (<code>$</code>).</p>
|
213
|
+
|
214
|
+
<pre><code>/**
|
215
|
+
* $w(string) -> Array
|
216
|
+
* ...
|
217
|
+
**/
|
218
|
+
</code></pre>
|
219
|
+
|
220
|
+
<h4 id="methodized_methods">Methodized Methods</h4>
|
221
|
+
|
222
|
+
<p>Methodized methods are methods which are both available as a class method and an instance method, in which case the first argument becomes the instance object itself. For example, all of <code>Element</code>’s instance methods are methodized and thus also available as class methods of <code>Element</code>. Methodized methods are indicated by prefixing their first argument with the <code>@</code> symbol.</p>
|
223
|
+
|
224
|
+
<pre><code>/**
|
225
|
+
* Element#hide(@element) -> Element
|
226
|
+
* ...
|
227
|
+
**/
|
228
|
+
</code></pre>
|
229
|
+
|
230
|
+
<h4 id="klass_properties">Klass Properties</h4>
|
231
|
+
|
232
|
+
<p>Klass properties are identified by a dot (<code>.</code>).</p>
|
233
|
+
|
234
|
+
<pre><code>/**
|
235
|
+
* Ajax.Responders.responders -> Array
|
236
|
+
* ...
|
237
|
+
**/
|
238
|
+
</code></pre>
|
239
|
+
|
240
|
+
<h4 id="instance_properties">Instance Properties</h4>
|
241
|
+
|
242
|
+
<p>Instance properties are identified by the hash symbol (<code>#</code>).</p>
|
243
|
+
|
244
|
+
<pre><code>/**
|
245
|
+
* Ajax.Response#responseText -> String
|
246
|
+
* ...
|
247
|
+
**/
|
248
|
+
</code></pre>
|
249
|
+
|
250
|
+
<h4 id="constants">Constants</h4>
|
251
|
+
|
252
|
+
<p>Constant must have their value specified using the equal sign (<code>=</code>).</p>
|
253
|
+
|
254
|
+
<pre><code>/**
|
255
|
+
* Prototype.JSONFilter = /^\/\*-secure-([\s\S]*)\*\/\s*$/
|
256
|
+
* ...
|
257
|
+
**/
|
258
|
+
</code></pre>
|
259
|
+
|
260
|
+
<h3 id="events">Events</h3>
|
261
|
+
|
262
|
+
<p>Some methods can fire native or custom events. These are indicated below the arguments descriptions:</p>
|
263
|
+
|
264
|
+
<pre><code>/**
|
265
|
+
* Ajax.Request#respondToReadyState(readyState) -> undefined
|
266
|
+
* - readyState (Number): a number from 0 to 4 corresponding to the state of the request.
|
267
|
+
* fires ajax:created, ajax:completed
|
268
|
+
**/
|
269
|
+
</code></pre>
|
270
|
+
|
271
|
+
</div>
|
272
|
+
<div id="sidebar">
|
273
|
+
|
274
|
+
</div>
|
275
|
+
<div id="footer">
|
276
|
+
<p>© 2008 Tobie Langel. PDoc logo © 2008 Sam Stephenson.</p>
|
277
|
+
</div>
|
278
|
+
</div>
|
279
|
+
</body>
|
280
|
+
</html>
|
Binary file
|
@@ -0,0 +1,84 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
|
4
|
+
<html lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
7
|
+
<title>PDoc</title>
|
8
|
+
<meta name="generator" content="TextMate http://macromates.com/">
|
9
|
+
<meta name="author" content="Tobie Langel">
|
10
|
+
<!-- Date: 2008-02-25 -->
|
11
|
+
<link rel="stylesheet" href="/stylesheets/reset.css" type="text/css" media="screen" charset="utf-8">
|
12
|
+
<link rel="stylesheet" href="/stylesheets/main.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
13
|
+
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div id="wrapper">
|
17
|
+
<div id="header">
|
18
|
+
<h1><a href="/"><img src="/images/pdoc.jpg" alt="PDoc" /></a></h1>
|
19
|
+
</div>
|
20
|
+
<div id="navigation">
|
21
|
+
<ul>
|
22
|
+
<li><a href="/documentation.html">documentation</a></li>
|
23
|
+
<li><a href="http://github.com/tobie/pdoc/tree/master">source code</a></li>
|
24
|
+
<li><a href="/doc/index.html">rdoc</a></li>
|
25
|
+
<li><a href="http://prototype.lighthouseapp.com/projects/8889-pdoc/">bug tracker</a></li>
|
26
|
+
<li><a href="http://groups.google.com/group/pdoc">mailing list</a></li>
|
27
|
+
</ul>
|
28
|
+
</div>
|
29
|
+
<div id="content">
|
30
|
+
<h1>PDoc</h1>
|
31
|
+
|
32
|
+
<p>PDoc is an inline comment parser and JavaScript documentation generator written in Ruby. It is designed for documenting <a href="http://prototypejs.org">Prototype</a> and Prototype-based libraries.</p>
|
33
|
+
|
34
|
+
<p>PDoc uses <a href="http://treetop.rubyforge.org/">Treetop</a>, a Ruby-based DSL for text parsing and interpretation, and its own ActionView-inspired, ERB-based templating system for HTML generation. Other documentation generators (e.g., DocBook XML) are planned.</p>
|
35
|
+
|
36
|
+
<p>Unlike other inline-doc parsers, PDoc does not rely on the JavaScript source code at all; it only parses the comments. This approach, though slightly more verbose, is much better at generating consistent, reliable documentation, and avoids the headaches encountered when documenting highly dynamic languages.</p>
|
37
|
+
|
38
|
+
<h2>Installation</h2>
|
39
|
+
|
40
|
+
<p>PDoc depends on Rake, <a href="http://maruku.rubyforge.org/">Maruku</a>, and treetop, all of which can be obtained through RubyGems:</p>
|
41
|
+
|
42
|
+
<pre><code>gem install rake maruku treetop
|
43
|
+
</code></pre>
|
44
|
+
|
45
|
+
<p>Maruku is a more solid alternative to BlueCloth and is compatible with Ruby 1.9.1.</p>
|
46
|
+
|
47
|
+
<h2>Usage</h2>
|
48
|
+
|
49
|
+
<p>For hints on how to run PDoc on the command line, consult the built-in Rake tasks (in <code>Rakefile</code>) and the <code>PDoc::Runner</code> class (in <code>lib/pdoc/runner.rb</code>).</p>
|
50
|
+
|
51
|
+
<h2>How it works</h2>
|
52
|
+
|
53
|
+
<p>The process of turning inline PDoc comments into a human-friendly document has two phases.</p>
|
54
|
+
|
55
|
+
<h3>Parsing phase</h3>
|
56
|
+
|
57
|
+
<p>In this phase, the source files are scanned for PDoc comments, then parsed with the Ruby files generated from the Treetop language grammar. The product of this phase is a tree full of specialized classes, all of which inherit from <code>Treetop::Runtime::SyntaxNode</code>.</p>
|
58
|
+
|
59
|
+
<p>The root of the tree is an instance of <code>Documentation::Doc</code>. It comprises one or more instances of <code>Documentation::Section</code>; which in turn comprise language elements like namespaces, classes, constants, etc., all of which have class representations.</p>
|
60
|
+
|
61
|
+
<h3>Rendering phase</h3>
|
62
|
+
|
63
|
+
<p>Next, PDoc asks a <em>generator</em> how to translate this abstract tree into a hierarchical document. The default generator outputs organized HTML in a manner similar to <a href="http://rdoc.sourceforge.net/" title="RDoc - Document Generator for Ruby Source">RDoc</a>’s.</p>
|
64
|
+
|
65
|
+
<p>The HTML generator (<code>PDoc::Generators::Html</code>) has associated <em>templates</em> (in the <code>templates</code> directory) that accept syntax nodes and echo their metadata onto the page using <a href="http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/index.html" title="erb: Ruby Standard Library Documentation">ERB</a>. Templates are modular, so it’s quite easy to apply a custom “skin” to one’s documentation pages.</p>
|
66
|
+
|
67
|
+
<p>Furthermore, generators themselves are modular; PDoc can, theoretically, parse once and render to several different targets (HTML, <a href="http://www.docbook.org/" title="DocBook.org">DocBook XML</a>, CHM, PDF, even <a href="http://www.scriptdoc.org/" title="ScriptDoc.org: Dynamic Language Documentation">ScriptDoc</a>.) We hope many such generators will exist in the future.</p>
|
68
|
+
|
69
|
+
<div id="twitter_div">
|
70
|
+
<h2 class="twitter-title">Twitter Updates</h2>
|
71
|
+
<ul id="twitter_update_list"></ul>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
<div id="sidebar">
|
75
|
+
|
76
|
+
</div>
|
77
|
+
<div id="footer">
|
78
|
+
<p>© 2008 Tobie Langel. PDoc logo © 2008 Sam Stephenson.</p>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
|
82
|
+
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/pdoc.json?callback=twitterCallback2&count=5"></script>
|
83
|
+
</body>
|
84
|
+
</html>
|