yard 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/{LICENSE.txt → LICENSE} +1 -1
- data/README +211 -0
- data/Rakefile +31 -0
- data/benchmarks/builtins_vs_eval.rb +23 -0
- data/benchmarks/erb_vs_erubis.rb +53 -0
- data/benchmarks/generation.rb +37 -0
- data/benchmarks/parsing.rb +33 -0
- data/bin/view_generator +17 -0
- data/bin/yard-graph +4 -0
- data/bin/yardoc +1 -93
- data/bin/yri +12 -3
- data/lib/yard.rb +10 -5
- data/lib/yard/autoload.rb +116 -0
- data/lib/yard/cli/yard_graph.rb +86 -0
- data/lib/yard/cli/yardoc.rb +131 -0
- data/lib/yard/code_objects/base.rb +321 -0
- data/lib/yard/code_objects/class_object.rb +89 -0
- data/lib/yard/code_objects/class_variable_object.rb +4 -0
- data/lib/yard/code_objects/constant_object.rb +4 -0
- data/lib/yard/code_objects/method_object.rb +51 -0
- data/lib/yard/code_objects/module_object.rb +4 -0
- data/lib/yard/code_objects/namespace_object.rb +88 -0
- data/lib/yard/code_objects/proxy.rb +183 -0
- data/lib/yard/code_objects/root_object.rb +8 -0
- data/lib/yard/core_ext/file.rb +26 -0
- data/lib/yard/core_ext/logger.rb +5 -0
- data/lib/yard/core_ext/module.rb +9 -0
- data/lib/yard/core_ext/string.rb +13 -0
- data/lib/yard/core_ext/symbol_hash.rb +24 -0
- data/lib/yard/generators/attributes_generator.rb +22 -0
- data/lib/yard/generators/base.rb +285 -0
- data/lib/yard/generators/class_generator.rb +25 -0
- data/lib/yard/generators/constants_generator.rb +73 -0
- data/lib/yard/generators/constructor_generator.rb +25 -0
- data/lib/yard/generators/deprecated_generator.rb +15 -0
- data/lib/yard/generators/docstring_generator.rb +15 -0
- data/lib/yard/generators/full_doc_generator.rb +59 -0
- data/lib/yard/generators/helpers/base_helper.rb +52 -0
- data/lib/yard/generators/helpers/filter_helper.rb +21 -0
- data/lib/yard/generators/helpers/html_helper.rb +137 -0
- data/lib/yard/generators/helpers/method_helper.rb +27 -0
- data/lib/yard/generators/helpers/uml_helper.rb +16 -0
- data/lib/yard/generators/inheritance_generator.rb +16 -0
- data/lib/yard/generators/method_details_generator.rb +18 -0
- data/lib/yard/generators/method_generator.rb +31 -0
- data/lib/yard/generators/method_listing_generator.rb +105 -0
- data/lib/yard/generators/method_missing_generator.rb +25 -0
- data/lib/yard/generators/method_signature_generator.rb +19 -0
- data/lib/yard/generators/method_summary_generator.rb +21 -0
- data/lib/yard/generators/mixins_generator.rb +15 -0
- data/lib/yard/generators/module_generator.rb +22 -0
- data/lib/yard/generators/quick_doc_generator.rb +31 -0
- data/lib/yard/generators/source_generator.rb +26 -0
- data/lib/yard/generators/tags_generator.rb +50 -0
- data/lib/yard/generators/uml_generator.rb +92 -0
- data/lib/yard/generators/visibility_group_generator.rb +26 -0
- data/lib/yard/handlers/alias_handler.rb +32 -0
- data/lib/yard/handlers/attribute_handler.rb +54 -0
- data/lib/yard/handlers/base.rb +509 -0
- data/lib/yard/handlers/class_handler.rb +44 -0
- data/lib/yard/handlers/class_variable_handler.rb +13 -0
- data/lib/yard/handlers/constant_handler.rb +13 -0
- data/lib/yard/handlers/exception_handler.rb +12 -0
- data/lib/yard/handlers/method_handler.rb +27 -0
- data/lib/yard/handlers/mixin_handler.rb +16 -0
- data/lib/yard/handlers/module_handler.rb +9 -0
- data/lib/yard/handlers/visibility_handler.rb +14 -0
- data/lib/yard/handlers/yield_handler.rb +26 -0
- data/lib/yard/logging.rb +27 -0
- data/lib/yard/parser/ruby_lex.rb +1344 -0
- data/lib/yard/parser/source_parser.rb +109 -0
- data/lib/yard/parser/statement.rb +36 -0
- data/lib/yard/parser/statement_list.rb +167 -0
- data/lib/yard/parser/token_list.rb +58 -0
- data/lib/yard/rake/yardoc_task.rb +30 -0
- data/lib/yard/registry.rb +136 -0
- data/lib/yard/serializers/base.rb +16 -0
- data/lib/yard/serializers/file_system_serializer.rb +48 -0
- data/lib/yard/serializers/process_serializer.rb +14 -0
- data/lib/yard/serializers/stdout_serializer.rb +21 -0
- data/lib/yard/tags/default_factory.rb +98 -0
- data/lib/yard/tags/library.rb +109 -0
- data/lib/yard/tags/merbdoc_factory.rb +47 -0
- data/lib/yard/tags/tag.rb +35 -0
- data/spec/code_objects/base_spec.rb +219 -0
- data/spec/code_objects/class_object_spec.rb +176 -0
- data/spec/code_objects/code_object_list_spec.rb +33 -0
- data/spec/code_objects/constants_spec.rb +79 -0
- data/spec/code_objects/method_object_spec.rb +30 -0
- data/spec/code_objects/module_object_spec.rb +73 -0
- data/spec/code_objects/namespace_object_spec.rb +129 -0
- data/spec/code_objects/proxy_spec.rb +80 -0
- data/spec/code_objects/spec_helper.rb +3 -0
- data/spec/core_ext/file_spec.rb +20 -0
- data/spec/core_ext/string_spec.rb +4 -0
- data/spec/core_ext/symbol_hash_spec.rb +80 -0
- data/spec/generators/base_spec.rb +64 -0
- data/spec/generators/helpers/base_helper_spec.rb +15 -0
- data/spec/generators/helpers/html_helper_spec.rb +56 -0
- data/spec/generators/quick_doc_generator_spec.rb +13 -0
- data/spec/handlers/alias_handler_spec.rb +50 -0
- data/spec/handlers/attribute_handler_spec.rb +78 -0
- data/spec/handlers/base_spec.rb +165 -0
- data/spec/handlers/class_handler_spec.rb +68 -0
- data/spec/handlers/class_variable_handler_spec.rb +9 -0
- data/spec/handlers/constant_handler_spec.rb +13 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +24 -0
- data/spec/handlers/examples/attribute_handler_001.rb.txt +19 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +39 -0
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +42 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +35 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +12 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +16 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +20 -0
- data/spec/handlers/examples/yield_handler_001.rb.txt +55 -0
- data/spec/handlers/exception_handler_spec.rb +35 -0
- data/spec/handlers/method_handler_spec.rb +35 -0
- data/spec/handlers/mixin_handler_spec.rb +30 -0
- data/spec/handlers/module_handler_spec.rb +25 -0
- data/spec/handlers/spec_helper.rb +21 -0
- data/spec/handlers/visibility_handler_spec.rb +24 -0
- data/spec/handlers/yield_handler_spec.rb +51 -0
- data/spec/parser/examples/example1.rb.txt +8 -0
- data/spec/parser/examples/tag_handler_001.rb.txt +8 -0
- data/spec/parser/source_parser_spec.rb +43 -0
- data/spec/parser/tag_parsing_spec.rb +18 -0
- data/spec/parser/token_list_spec.rb +35 -0
- data/spec/registry_spec.rb +70 -0
- data/spec/serializers/file_system_serializer_spec.rb +91 -0
- data/spec/serializers/spec_helper.rb +2 -0
- data/spec/spec_helper.rb +77 -0
- data/templates/default/attributes/html/header.erb +35 -0
- data/templates/default/attributes/text/header.erb +10 -0
- data/templates/default/class/html/header.erb +4 -0
- data/templates/default/constants/html/constants.erb +9 -0
- data/templates/default/constants/html/header.erb +3 -0
- data/templates/default/constants/html/included.erb +9 -0
- data/templates/default/constants/html/inherited.erb +9 -0
- data/templates/default/constructor/html/header.erb +10 -0
- data/templates/default/deprecated/html/main.erb +4 -0
- data/templates/default/deprecated/text/main.erb +3 -0
- data/templates/default/docstring/html/main.erb +3 -0
- data/templates/default/docstring/text/main.erb +3 -0
- data/templates/default/fulldoc/html/all_methods.erb +25 -0
- data/templates/default/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/default/fulldoc/html/app.js +18 -0
- data/templates/default/fulldoc/html/header.erb +15 -0
- data/templates/default/fulldoc/html/html_head.erb +3 -0
- data/templates/default/fulldoc/html/index.erb +18 -0
- data/templates/default/fulldoc/html/jquery.js +11 -0
- data/templates/default/fulldoc/html/readme.erb +15 -0
- data/templates/default/fulldoc/html/style.css +65 -0
- data/templates/default/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/default/inheritance/html/header.erb +8 -0
- data/templates/default/inheritance/text/header.erb +3 -0
- data/templates/default/method/html/aliases.erb +6 -0
- data/templates/default/method/html/header.erb +3 -0
- data/templates/default/method/html/title.erb +3 -0
- data/templates/default/methoddetails/html/header.erb +8 -0
- data/templates/default/methoddetails/html/method_header.erb +3 -0
- data/templates/default/methodmissing/html/header.erb +12 -0
- data/templates/default/methodsignature/html/main.erb +8 -0
- data/templates/default/methodsignature/text/main.erb +5 -0
- data/templates/default/methodsummary/html/header.erb +5 -0
- data/templates/default/methodsummary/html/included.erb +9 -0
- data/templates/default/methodsummary/html/inherited.erb +9 -0
- data/templates/default/methodsummary/html/summary.erb +25 -0
- data/templates/default/methodsummary/text/header.erb +5 -0
- data/templates/default/methodsummary/text/included.erb +0 -0
- data/templates/default/methodsummary/text/inherited.erb +0 -0
- data/templates/default/methodsummary/text/summary.erb +3 -0
- data/templates/default/mixins/html/header.erb +4 -0
- data/templates/default/module/html/header.erb +4 -0
- data/templates/default/quickdoc/html/header.erb +15 -0
- data/templates/default/quickdoc/text/header.erb +12 -0
- data/templates/default/source/html/main.erb +15 -0
- data/templates/default/source/text/main.erb +4 -0
- data/templates/default/tags/html/header.erb +4 -0
- data/templates/default/tags/html/see.erb +13 -0
- data/templates/default/tags/html/tags.erb +20 -0
- data/templates/default/tags/text/header.erb +3 -0
- data/templates/default/tags/text/see.erb +5 -0
- data/templates/default/tags/text/tags.erb +7 -0
- data/templates/default/uml/dot/child.erb +1 -0
- data/templates/default/uml/dot/dependencies.erb +10 -0
- data/templates/default/uml/dot/header.erb +6 -0
- data/templates/default/uml/dot/info.erb +14 -0
- data/templates/default/uml/dot/subgraph.erb +6 -0
- data/templates/default/uml/dot/superclasses.erb +9 -0
- data/templates/default/uml/dot/unknown.erb +3 -0
- data/templates/default/uml/dot/unknown_child.erb +1 -0
- data/templates/default/visibilitygroup/html/header.erb +6 -0
- data/templates/javadoc/attributes/html/header.erb +16 -0
- data/templates/javadoc/class/html/header.erb +4 -0
- data/templates/javadoc/constants/html/constants.erb +9 -0
- data/templates/javadoc/constants/html/header.erb +3 -0
- data/templates/javadoc/constants/html/included.erb +12 -0
- data/templates/javadoc/constants/html/inherited.erb +12 -0
- data/templates/javadoc/constructor/html/header.erb +10 -0
- data/templates/javadoc/deprecated/html/main.erb +0 -0
- data/templates/javadoc/docstring/html/main.erb +6 -0
- data/templates/javadoc/fulldoc/html/all_methods.erb +25 -0
- data/templates/javadoc/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/javadoc/fulldoc/html/app.js +18 -0
- data/templates/javadoc/fulldoc/html/header.erb +15 -0
- data/templates/javadoc/fulldoc/html/html_head.erb +3 -0
- data/templates/javadoc/fulldoc/html/index.erb +18 -0
- data/templates/javadoc/fulldoc/html/jquery.js +11 -0
- data/templates/javadoc/fulldoc/html/readme.erb +15 -0
- data/templates/javadoc/fulldoc/html/style.css +22 -0
- data/templates/javadoc/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/javadoc/inheritance/html/header.erb +6 -0
- data/templates/javadoc/method/html/aliases.erb +6 -0
- data/templates/javadoc/method/html/header.erb +4 -0
- data/templates/javadoc/method/html/title.erb +4 -0
- data/templates/javadoc/methoddetails/html/header.erb +8 -0
- data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
- data/templates/javadoc/methodmissing/html/header.erb +12 -0
- data/templates/javadoc/methodsignature/html/main.erb +8 -0
- data/templates/javadoc/methodsummary/html/header.erb +5 -0
- data/templates/javadoc/methodsummary/html/included.erb +12 -0
- data/templates/javadoc/methodsummary/html/inherited.erb +12 -0
- data/templates/javadoc/methodsummary/html/summary.erb +25 -0
- data/templates/javadoc/mixins/html/header.erb +5 -0
- data/templates/javadoc/module/html/header.erb +4 -0
- data/templates/javadoc/source/html/main.erb +15 -0
- data/templates/javadoc/tags/html/header.erb +5 -0
- data/templates/javadoc/tags/html/see.erb +8 -0
- data/templates/javadoc/tags/html/tags.erb +19 -0
- data/templates/javadoc/visibilitygroup/html/header.erb +5 -0
- metadata +352 -50
- data/README.pdf +0 -0
- data/lib/code_object.rb +0 -337
- data/lib/extra.rb +0 -8
- data/lib/formatter.rb +0 -90
- data/lib/handlers/all_handlers.rb +0 -2
- data/lib/handlers/attribute_handler.rb +0 -51
- data/lib/handlers/class_handler.rb +0 -30
- data/lib/handlers/class_variable_handler.rb +0 -9
- data/lib/handlers/code_object_handler.rb +0 -104
- data/lib/handlers/constant_handler.rb +0 -11
- data/lib/handlers/exception_handler.rb +0 -20
- data/lib/handlers/method_handler.rb +0 -28
- data/lib/handlers/mixin_handler.rb +0 -15
- data/lib/handlers/module_handler.rb +0 -9
- data/lib/handlers/visibility_handler.rb +0 -7
- data/lib/handlers/yield_handler.rb +0 -33
- data/lib/logger.rb +0 -19
- data/lib/namespace.rb +0 -98
- data/lib/quick_doc.rb +0 -104
- data/lib/ruby_lex.rb +0 -1321
- data/lib/source_parser.rb +0 -253
- data/lib/tag_library.rb +0 -175
- data/lib/tag_type.rb +0 -155
- data/templates/default/html/_fulldoc.erb +0 -64
- data/templates/default/html/class.erb +0 -226
- data/templates/default/html/method.erb +0 -20
- data/templates/default/html/module.erb +0 -126
- data/test/fixtures/docstring.txt +0 -23
- data/test/fixtures/docstring2.txt +0 -4
- data/test/test_code_object.rb +0 -66
- data/test/test_namespace.rb +0 -10
@@ -1,30 +0,0 @@
|
|
1
|
-
class YARD::ClassHandler < YARD::CodeObjectHandler
|
2
|
-
handles YARD::RubyToken::TkCLASS
|
3
|
-
|
4
|
-
def process
|
5
|
-
words = statement.tokens.to_s.strip.split(/\s+/)
|
6
|
-
class_name, superclass = words[1], (words[3] || "Object")
|
7
|
-
if class_name == "<<"
|
8
|
-
if words[2] == "self"
|
9
|
-
class_name = nil
|
10
|
-
else
|
11
|
-
class_name = "Anonymous$#{class_name}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
if class_name.nil?
|
16
|
-
# This is a class << self block. We change the scope to class level methods
|
17
|
-
# and reset the visibility to public, but we don't enter a new namespace.
|
18
|
-
scope, vis = current_namespace.attributes[:scope], current_visibility
|
19
|
-
current_visibility = :public
|
20
|
-
current_namespace.attributes[:scope] = :class
|
21
|
-
parse_block
|
22
|
-
current_namespace.attributes[:scope], current_visibility = scope, vis
|
23
|
-
else
|
24
|
-
class_name = move_to_namespace(class_name)
|
25
|
-
class_obj = Namespace.find_from_path(object, class_name)
|
26
|
-
class_obj ||= YARD::ClassObject.new(class_name, superclass, object, statement.comments)
|
27
|
-
enter_namespace(class_obj) { parse_block }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
class YARD::CodeObjectHandler
|
2
|
-
class << self
|
3
|
-
def subclasses
|
4
|
-
@@subclasses || []
|
5
|
-
end
|
6
|
-
|
7
|
-
def inherited(subclass)
|
8
|
-
@@subclasses ||= []
|
9
|
-
@@subclasses << subclass
|
10
|
-
end
|
11
|
-
|
12
|
-
def handles(token)
|
13
|
-
@handler = token
|
14
|
-
end
|
15
|
-
|
16
|
-
def handles?(tokens)
|
17
|
-
case @handler
|
18
|
-
when String
|
19
|
-
tokens.first.text == @handler
|
20
|
-
when Regexp
|
21
|
-
tokens.to_s =~ @handler
|
22
|
-
else
|
23
|
-
@handler <= tokens.first.class
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :parser, :statement
|
29
|
-
|
30
|
-
def initialize(source_parser, stmt)
|
31
|
-
@parser = source_parser
|
32
|
-
@statement = stmt
|
33
|
-
end
|
34
|
-
|
35
|
-
def process
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
def current_visibility
|
40
|
-
current_namespace.attributes[:visibility]
|
41
|
-
end
|
42
|
-
|
43
|
-
def current_visibility=(value)
|
44
|
-
current_namespace.attributes[:visibility] = value
|
45
|
-
end
|
46
|
-
|
47
|
-
def current_scope
|
48
|
-
current_namespace.attributes[:scope]
|
49
|
-
end
|
50
|
-
|
51
|
-
def current_scope=(value)
|
52
|
-
current_namespace.attributes[:scope] = value
|
53
|
-
end
|
54
|
-
|
55
|
-
def object
|
56
|
-
current_namespace.object
|
57
|
-
end
|
58
|
-
|
59
|
-
def attributes
|
60
|
-
current_namespace.attributes
|
61
|
-
end
|
62
|
-
|
63
|
-
def current_namespace
|
64
|
-
parser.current_namespace
|
65
|
-
end
|
66
|
-
|
67
|
-
def current_namespace=(value)
|
68
|
-
parser.current_namespace = value
|
69
|
-
end
|
70
|
-
|
71
|
-
def enter_namespace(name, *args, &block)
|
72
|
-
namespace = parser.current_namespace
|
73
|
-
if name.is_a? YARD::CodeObject
|
74
|
-
self.current_namespace = YARD::NameStruct.new(name)
|
75
|
-
#object.add_child(name)
|
76
|
-
yield(name)
|
77
|
-
else
|
78
|
-
object.add_child(name, *args) do |obj|
|
79
|
-
self.current_namespace = YARD::NameStruct.new(obj)
|
80
|
-
obj.attach_source(statement.tokens.to_s, parser.file, statement.tokens.first.line_no)
|
81
|
-
obj.attach_docstring(statement.comments)
|
82
|
-
yield(obj)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
self.current_namespace = namespace
|
86
|
-
end
|
87
|
-
|
88
|
-
def move_to_namespace(namespace)
|
89
|
-
# If the class extends over a namespace, go to the proper object
|
90
|
-
if namespace.include? "::"
|
91
|
-
path = namespace.split("::")
|
92
|
-
name = path.pop
|
93
|
-
path = path.join("::")
|
94
|
-
full_namespace = [object.path, path].compact.join("::").gsub(/^::/, '')
|
95
|
-
current_namespace.object = YARD::Namespace.find_or_create_namespace(full_namespace)
|
96
|
-
namespace = name
|
97
|
-
end
|
98
|
-
namespace
|
99
|
-
end
|
100
|
-
|
101
|
-
def parse_block
|
102
|
-
parser.parse(statement.block) if statement.block
|
103
|
-
end
|
104
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class YARD::ConstantHandler < YARD::CodeObjectHandler
|
2
|
-
HANDLER_MATCH = /\A[^@\$]\S*\s*=[^=]\s*/m
|
3
|
-
handles HANDLER_MATCH
|
4
|
-
|
5
|
-
def process
|
6
|
-
return unless object.is_a? YARD::CodeObjectWithMethods
|
7
|
-
const, expr = *statement.tokens.to_s.split(/\s*=\s*/, 2)
|
8
|
-
#expr.gsub!(/\/s+/,' ')
|
9
|
-
obj = YARD::ConstantObject.new(const, object, statement)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class YARD::ExceptionHandler < YARD::CodeObjectHandler
|
2
|
-
handles 'raise'
|
3
|
-
|
4
|
-
def process
|
5
|
-
tokens = statement.tokens.reject {|tk| [RubyToken::TkSPACE, RubyToken::TkLPAREN].include? tk }
|
6
|
-
from = tokens.each_with_index do |token, index|
|
7
|
-
break index if token.class == RubyToken::TkIDENTIFIER && token.text == 'raise'
|
8
|
-
end
|
9
|
-
if from.is_a? Fixnum
|
10
|
-
exception_class = tokens[(from+1)..-1].to_s[/^\W+(\w+)/, 1]
|
11
|
-
# RuntimeError for Strings or no parameter
|
12
|
-
exception_class = "RuntimeError" if exception_class =~ /^\"/ || exception_class.nil?
|
13
|
-
|
14
|
-
# Only add the tag if it hasn't already been added (by exception class).
|
15
|
-
unless object.tags("raise").any? {|tag| tag.name == exception_class }
|
16
|
-
object.tags << YARD::TagLibrary.raise_tag(exception_class)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class YARD::MethodHandler < YARD::CodeObjectHandler
|
2
|
-
handles YARD::RubyToken::TkDEF
|
3
|
-
|
4
|
-
def process
|
5
|
-
return unless object.is_a? YARD::CodeObjectWithMethods
|
6
|
-
stmt_nospace = statement.tokens.reject {|t| t.is_a? RubyToken::TkSPACE }
|
7
|
-
method_name, method_scope = stmt_nospace[1].text, current_scope
|
8
|
-
holding_object = object
|
9
|
-
|
10
|
-
# Use the third token (after the period) if statement begins with a "Constant." or "self."
|
11
|
-
if [RubyToken::TkCOLON2,RubyToken::TkDOT].include?(stmt_nospace[2].class)
|
12
|
-
method_class = stmt_nospace[1].text
|
13
|
-
holding_object = YARD::Namespace.find_from_path(object.path, method_class)
|
14
|
-
holding_object = YARD::Namespace.find_or_create_namespace(method_class) if holding_object.nil?
|
15
|
-
method_name = stmt_nospace[3..-1].to_s[/\A(.+?)(?:\(|;|$)/,1]
|
16
|
-
method_scope = :class
|
17
|
-
end
|
18
|
-
|
19
|
-
method_object = YARD::MethodObject.new(method_name, current_visibility,
|
20
|
-
method_scope, holding_object, statement.comments)
|
21
|
-
enter_namespace(method_object) do |obj|
|
22
|
-
#puts "->\tMethod #{obj.path} (visibility: #{obj.visibility})"
|
23
|
-
# Attach better source code
|
24
|
-
obj.attach_source(statement, parser.file)
|
25
|
-
parse_block
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class YARD::MixinHandler < YARD::CodeObjectHandler
|
2
|
-
handles /\Ainclude\b/
|
3
|
-
|
4
|
-
def process
|
5
|
-
return unless object.is_a? YARD::CodeObjectWithMethods
|
6
|
-
begin
|
7
|
-
object.mixins.push eval("[ " + statement.tokens[1..-1].to_s + " ]").to_s
|
8
|
-
rescue NameError
|
9
|
-
object.mixins.push statement.tokens[1..-1].to_s
|
10
|
-
end
|
11
|
-
object.mixins.map! {|mixin| mixin.trim }
|
12
|
-
object.mixins.flatten!
|
13
|
-
object.mixins.uniq!
|
14
|
-
end
|
15
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
class YARD::ModuleHandler < YARD::CodeObjectHandler
|
2
|
-
handles YARD::RubyToken::TkMODULE
|
3
|
-
|
4
|
-
def process
|
5
|
-
module_name = move_to_namespace(statement.tokens[2].text)
|
6
|
-
child = YARD::ModuleObject.new(module_name, object, statement.comments)
|
7
|
-
enter_namespace(child) { parse_block }
|
8
|
-
end
|
9
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module YARD
|
2
|
-
class YieldHandler < CodeObjectHandler
|
3
|
-
handles 'yield'
|
4
|
-
|
5
|
-
def process
|
6
|
-
tokens = statement.tokens.reject {|tk| [RubyToken::TkSPACE, RubyToken::TkLPAREN].include? tk.class }
|
7
|
-
from = tokens.each_with_index do |token, index|
|
8
|
-
break index if token.class == RubyToken::TkYIELD
|
9
|
-
end
|
10
|
-
if from.is_a? Fixnum
|
11
|
-
params = []
|
12
|
-
(from+1).step(tokens.size-1, 2) do |index|
|
13
|
-
# FIXME: This won't work if the yield has a method call or complex constant name (A::B)
|
14
|
-
params << tokens[index].text
|
15
|
-
break unless tokens[index+1].is_a? RubyToken::TkCOMMA
|
16
|
-
end
|
17
|
-
|
18
|
-
# Only add the tags if none were added at all
|
19
|
-
if object.tags("yieldparam").empty? && object.tags("yield").empty?
|
20
|
-
params.each do |param|
|
21
|
-
# TODO: We can technically introspect any constant to find out parameter types,
|
22
|
-
# not just self.
|
23
|
-
# If parameter is self, we have a chance to get some extra information
|
24
|
-
if param == "self"
|
25
|
-
param = "[#{object.parent.path}] _self the object that yields the value (self)"
|
26
|
-
end
|
27
|
-
object.tags << YARD::TagLibrary.yieldparam_tag(param)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/logger.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class Logger
|
2
|
-
class << self
|
3
|
-
attr_accessor :notices, :warnings, :errors
|
4
|
-
@notices, @warnings, @errors = true, true, true
|
5
|
-
|
6
|
-
def notice
|
7
|
-
puts "Notice: #{msg}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def warning(msg)
|
11
|
-
puts "Warning: #{msg}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def error(msg)
|
15
|
-
puts "Error: #{msg}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
data/lib/namespace.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'find'
|
3
|
-
require 'yaml'
|
4
|
-
require File.dirname(__FILE__) + '/code_object'
|
5
|
-
require File.dirname(__FILE__) + '/source_parser'
|
6
|
-
|
7
|
-
module YARD
|
8
|
-
class Namespace
|
9
|
-
DEFAULT_YARDOC_FILE = "_Yardoc"
|
10
|
-
|
11
|
-
include Singleton
|
12
|
-
|
13
|
-
class << self
|
14
|
-
##
|
15
|
-
# Attempt to find a namespace and return it if it exists. Similar
|
16
|
-
# to the {YARD::Namsepace::at} method but creates the namespace
|
17
|
-
# as a module if it does not exist, and return it.
|
18
|
-
#
|
19
|
-
# @param [String] namespace the namespace to search for.
|
20
|
-
# @return [CodeObject] the namespace that was found or created.
|
21
|
-
def find_or_create_namespace(namespace)
|
22
|
-
return at(namespace) if at(namespace)
|
23
|
-
name = namespace.split("::").last
|
24
|
-
object = ModuleObject.new(name)
|
25
|
-
instance.namespace.update(namespace => object)
|
26
|
-
object
|
27
|
-
end
|
28
|
-
|
29
|
-
def add_object(object)
|
30
|
-
instance.add_object(object)
|
31
|
-
end
|
32
|
-
|
33
|
-
def at(name)
|
34
|
-
instance.at(name)
|
35
|
-
end
|
36
|
-
alias_method :[], :at
|
37
|
-
|
38
|
-
def root
|
39
|
-
at('')
|
40
|
-
end
|
41
|
-
|
42
|
-
def all
|
43
|
-
instance.namespace.keys
|
44
|
-
end
|
45
|
-
|
46
|
-
def each_object
|
47
|
-
instance.namespace.each do |name, object|
|
48
|
-
yield(name, object)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def load(file = DEFAULT_YARDOC_FILE, reload = false)
|
53
|
-
if File.exists?(file) && !reload
|
54
|
-
instance.namespace.replace(Marshal.load(IO.read(file)))
|
55
|
-
else
|
56
|
-
Find.find(".") do |path|
|
57
|
-
SourceParser.parse(path) if path =~ /\.rb$/
|
58
|
-
end
|
59
|
-
end
|
60
|
-
save
|
61
|
-
end
|
62
|
-
|
63
|
-
def save(file = DEFAULT_YARDOC_FILE)
|
64
|
-
File.open(file, "w") {|f| Marshal.dump(instance.namespace, f) }
|
65
|
-
end
|
66
|
-
|
67
|
-
def find_from_path(object, name)
|
68
|
-
object = at(object) unless object.is_a? CodeObject
|
69
|
-
return object if name == 'self'
|
70
|
-
|
71
|
-
while object
|
72
|
-
["::", ""].each do |type|
|
73
|
-
obj = at(object.path + type + name)
|
74
|
-
return obj if obj
|
75
|
-
end
|
76
|
-
object = object.parent
|
77
|
-
end
|
78
|
-
nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
attr_reader :namespace
|
83
|
-
|
84
|
-
def initialize
|
85
|
-
@namespace = { '' => CodeObjectWithMethods.new('', :root) }
|
86
|
-
end
|
87
|
-
|
88
|
-
def add_object(object)
|
89
|
-
return object if namespace[object.path] && object.docstring.nil?
|
90
|
-
namespace.update(object.path => object)
|
91
|
-
object
|
92
|
-
end
|
93
|
-
|
94
|
-
def at(name)
|
95
|
-
namespace[name]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/quick_doc.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/namespace'
|
2
|
-
|
3
|
-
module YARD
|
4
|
-
class QuickDoc
|
5
|
-
def initialize(name)
|
6
|
-
Namespace.load
|
7
|
-
if name.nil?
|
8
|
-
puts "Method Listing:"
|
9
|
-
puts "---------------"
|
10
|
-
puts Namespace.all.select {|n| Namespace.at(n).is_a? MethodObject }.sort.join("\n")
|
11
|
-
return
|
12
|
-
end
|
13
|
-
|
14
|
-
meth = Namespace.at(name)
|
15
|
-
if meth.nil?
|
16
|
-
puts "No entry for #{name}"
|
17
|
-
return
|
18
|
-
end
|
19
|
-
|
20
|
-
ns = meth.path
|
21
|
-
rvalue = meth.tag('return')
|
22
|
-
return_type = rvalue && rvalue.type ? rvalue.type : "undefined"
|
23
|
-
block = nil
|
24
|
-
unless meth.tags("yieldparam").empty?
|
25
|
-
block = " {|" + meth.tags("yieldparam").collect {|tag| tag.name }.join(", ") + "| ... }"
|
26
|
-
end
|
27
|
-
|
28
|
-
puts "Documentation for #{ns}"
|
29
|
-
puts "==================#{'=' * ns.length}"
|
30
|
-
if meth.file
|
31
|
-
puts "File: '#{meth.file}' (on line #{meth.line})"
|
32
|
-
end
|
33
|
-
puts "Type: #{return_type}\t\tVisibility: #{meth.visibility}"
|
34
|
-
puts
|
35
|
-
if meth.tag('deprecated')
|
36
|
-
desc = meth.tag('deprecrated').text
|
37
|
-
puts
|
38
|
-
puts "!! This method is deprecated" + (desc ? ": #{desc}" : ".")
|
39
|
-
puts
|
40
|
-
end
|
41
|
-
if meth.docstring
|
42
|
-
puts word_wrap(meth.docstring, ns.length + 18)
|
43
|
-
puts
|
44
|
-
end
|
45
|
-
unless meth.tags("param").empty? && meth.tags("raise").empty? && meth.tags("return").empty?
|
46
|
-
puts "Meta Tags:"
|
47
|
-
puts "----------"
|
48
|
-
meth.tags("param").each do |tag|
|
49
|
-
types = tag.types.empty? ? "" : "[#{tag.types.join(", ")}] "
|
50
|
-
puts "> Parameter: #{types}#{tag.name} => #{tag.text}"
|
51
|
-
end
|
52
|
-
meth.tags("raise").each do |tag|
|
53
|
-
puts "> Raises #{tag.name} exception#{tag.text ? ': ' + tag.text : ''}"
|
54
|
-
end
|
55
|
-
meth.tags("return").each do |tag|
|
56
|
-
puts "> Returns #{tag.types.empty? ? "" : "(as " + tag.types.join(", ") + ')'} #{tag.text}"
|
57
|
-
end
|
58
|
-
puts
|
59
|
-
unless meth.tags("yieldparam").empty?
|
60
|
-
puts "Yields:"
|
61
|
-
puts "-------"
|
62
|
-
meth.tags("yieldparam").each do |tag|
|
63
|
-
types = tag.types.empty? ? "" : "[#{tag.types.join(", ")}] "
|
64
|
-
puts "> Block parameter: #{types}#{tag.name} => #{tag.text}"
|
65
|
-
puts
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
if meth.source
|
70
|
-
puts "Definition:"
|
71
|
-
puts "-----------"
|
72
|
-
puts format_code(meth.source.sub("\n", "#{block}" + (return_type ? " # -> " + return_type : "") + "\n"))
|
73
|
-
puts
|
74
|
-
end
|
75
|
-
unless meth.tags("see").empty?
|
76
|
-
puts "See Also:"
|
77
|
-
puts "---------"
|
78
|
-
meth.tags("see").each do |tag|
|
79
|
-
puts "\t- #{tag.text}"
|
80
|
-
end
|
81
|
-
puts
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
protected
|
86
|
-
def word_wrap(text, length = 80)
|
87
|
-
text.gsub(/(.{0,#{length - 3}}\s)/, "\n" + '\1')
|
88
|
-
end
|
89
|
-
|
90
|
-
def format_code(text, indent_size = 2)
|
91
|
-
last_indent, tab = nil, 0
|
92
|
-
text.split(/\r?\n/).collect do |line|
|
93
|
-
indent = line[/^(\s*)/, 1].length
|
94
|
-
if last_indent && indent > last_indent
|
95
|
-
tab += indent_size
|
96
|
-
elsif last_indent && indent < last_indent
|
97
|
-
tab -= indent_size
|
98
|
-
end
|
99
|
-
last_indent = indent
|
100
|
-
(" " * tab) + line.sub(/^\s*/, '')
|
101
|
-
end.join("\n")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|