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
data/bin/yri
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require File.dirname(__FILE__) + '/../lib/yard'
|
3
|
-
|
4
|
-
YARD::
|
3
|
+
|
4
|
+
YARD::Registry.load
|
5
|
+
|
6
|
+
object = YARD::Registry.at(ARGV[0])
|
7
|
+
options = {
|
8
|
+
:format => :text,
|
9
|
+
:template => :default,
|
10
|
+
:serializer => YARD::Serializers::ProcessSerializer.new('less')
|
11
|
+
}
|
12
|
+
|
13
|
+
YARD::Generators::QuickDocGenerator.new(options).generate(object)
|
data/lib/yard.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module YARD
|
2
|
-
VERSION = "0.2.
|
2
|
+
VERSION = "0.2.2"
|
3
|
+
ROOT = File.dirname(__FILE__)
|
4
|
+
TEMPLATE_ROOT = File.join(File.dirname(__FILE__), '..', 'templates')
|
5
|
+
|
6
|
+
def self.parse(*args) Parser::SourceParser.parse(*args) end
|
3
7
|
end
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
$:.unshift(YARD::ROOT)
|
10
|
+
|
11
|
+
files = ['yard/logging', 'yard/autoload']
|
12
|
+
files += Dir.glob File.join(YARD::ROOT, 'yard/core_ext/*')
|
13
|
+
files.each {|file| require file.gsub(/\.rb$/, '') }
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module YARD
|
2
|
+
module CLI
|
3
|
+
autoload :YardGraph, 'yard/cli/yard_graph.rb'
|
4
|
+
autoload :Yardoc, 'yard/cli/yardoc.rb'
|
5
|
+
end
|
6
|
+
|
7
|
+
module CodeObjects
|
8
|
+
autoload :Base, 'yard/code_objects/base'
|
9
|
+
autoload :CodeObjectList, 'yard/code_objects/base'
|
10
|
+
autoload :ClassObject, 'yard/code_objects/class_object'
|
11
|
+
autoload :ClassVariableObject, 'yard/code_objects/class_variable_object'
|
12
|
+
autoload :ConstantObject, 'yard/code_objects/constant_object'
|
13
|
+
autoload :MethodObject, 'yard/code_objects/method_object'
|
14
|
+
autoload :ModuleObject, 'yard/code_objects/module_object'
|
15
|
+
autoload :NamespaceObject, 'yard/code_objects/namespace_object'
|
16
|
+
autoload :Proxy, 'yard/code_objects/proxy'
|
17
|
+
autoload :ProxyMethodError, 'yard/code_objects/proxy'
|
18
|
+
autoload :RootObject, 'yard/code_objects/root_object'
|
19
|
+
|
20
|
+
autoload :BUILTIN_ALL, 'yard/code_objects/base'
|
21
|
+
autoload :BUILTIN_CLASSES, 'yard/code_objects/base'
|
22
|
+
autoload :BUILTIN_MODULES, 'yard/code_objects/base'
|
23
|
+
autoload :BUILTIN_EXCEPTIONS, 'yard/code_objects/base'
|
24
|
+
autoload :CONSTANTMATCH, 'yard/code_objects/base'
|
25
|
+
autoload :ISEP, 'yard/code_objects/base'
|
26
|
+
autoload :METHODMATCH, 'yard/code_objects/base'
|
27
|
+
autoload :METHODNAMEMATCH, 'yard/code_objects/base'
|
28
|
+
autoload :NAMESPACEMATCH, 'yard/code_objects/base'
|
29
|
+
autoload :NSEP, 'yard/code_objects/base'
|
30
|
+
end
|
31
|
+
|
32
|
+
module Generators
|
33
|
+
module Helpers
|
34
|
+
autoload :BaseHelper, 'yard/generators/helpers/base_helper'
|
35
|
+
autoload :FilterHelper, 'yard/generators/helpers/filter_helper'
|
36
|
+
autoload :HtmlHelper, 'yard/generators/helpers/html_helper'
|
37
|
+
autoload :MethodHelper, 'yard/generators/helpers/method_helper'
|
38
|
+
autoload :UMLHelper, 'yard/generators/helpers/uml_helper'
|
39
|
+
end
|
40
|
+
|
41
|
+
autoload :AttributesGenerator, 'yard/generators/attributes_generator'
|
42
|
+
autoload :Base, 'yard/generators/base'
|
43
|
+
autoload :ClassGenerator, 'yard/generators/class_generator'
|
44
|
+
autoload :ConstantsGenerator, 'yard/generators/constants_generator'
|
45
|
+
autoload :ConstructorGenerator, 'yard/generators/constructor_generator'
|
46
|
+
autoload :DeprecatedGenerator, 'yard/generators/deprecated_generator'
|
47
|
+
autoload :DocstringGenerator, 'yard/generators/docstring_generator'
|
48
|
+
autoload :FullDocGenerator, 'yard/generators/full_doc_generator'
|
49
|
+
autoload :InheritanceGenerator, 'yard/generators/inheritance_generator'
|
50
|
+
autoload :MethodGenerator, 'yard/generators/method_generator'
|
51
|
+
autoload :MethodDetailsGenerator, 'yard/generators/method_details_generator'
|
52
|
+
autoload :MethodListingGenerator, 'yard/generators/method_listing_generator'
|
53
|
+
autoload :MethodMissingGenerator, 'yard/generators/method_missing_generator'
|
54
|
+
autoload :MethodSignatureGenerator, 'yard/generators/method_signature_generator'
|
55
|
+
autoload :MethodSummaryGenerator, 'yard/generators/method_summary_generator'
|
56
|
+
autoload :MixinsGenerator, 'yard/generators/mixins_generator'
|
57
|
+
autoload :ModuleGenerator, 'yard/generators/module_generator'
|
58
|
+
autoload :QuickDocGenerator, 'yard/generators/quick_doc_generator'
|
59
|
+
autoload :SourceGenerator, 'yard/generators/source_generator'
|
60
|
+
autoload :TagsGenerator, 'yard/generators/tags_generator'
|
61
|
+
autoload :UMLGenerator, 'yard/generators/uml_generator'
|
62
|
+
autoload :VisibilityGroupGenerator, 'yard/generators/visibility_group_generator'
|
63
|
+
end
|
64
|
+
|
65
|
+
module Handlers
|
66
|
+
autoload :AliasHandler, 'yard/handlers/alias_handler'
|
67
|
+
autoload :AttributeHandler, 'yard/handlers/attribute_handler'
|
68
|
+
autoload :Base, 'yard/handlers/base'
|
69
|
+
autoload :ClassHandler, 'yard/handlers/class_handler'
|
70
|
+
autoload :ClassVariableHandler, 'yard/handlers/class_variable_handler'
|
71
|
+
autoload :ConstantHandler, 'yard/handlers/constant_handler'
|
72
|
+
autoload :ExceptionHandler, 'yard/handlers/exception_handler'
|
73
|
+
autoload :MethodHandler, 'yard/handlers/method_handler'
|
74
|
+
autoload :MixinHandler, 'yard/handlers/mixin_handler'
|
75
|
+
autoload :ModuleHandler, 'yard/handlers/module_handler'
|
76
|
+
autoload :VisibilityHandler, 'yard/handlers/visibility_handler'
|
77
|
+
autoload :UndocumentableError, 'yard/handlers/base'
|
78
|
+
autoload :YieldHandler, 'yard/handlers/yield_handler'
|
79
|
+
end
|
80
|
+
|
81
|
+
module Parser
|
82
|
+
module RubyToken
|
83
|
+
require 'yard/parser/ruby_lex' # Too much to include manually
|
84
|
+
end
|
85
|
+
|
86
|
+
autoload :SourceParser, 'yard/parser/source_parser'
|
87
|
+
autoload :Statement, 'yard/parser/statement'
|
88
|
+
autoload :StatementList, 'yard/parser/statement_list'
|
89
|
+
autoload :TokenList, 'yard/parser/token_list'
|
90
|
+
end
|
91
|
+
|
92
|
+
module Rake
|
93
|
+
autoload :YardocTask, 'yard/rake/yardoc_task'
|
94
|
+
end
|
95
|
+
|
96
|
+
module Serializers
|
97
|
+
autoload :Base, 'yard/serializers/base'
|
98
|
+
autoload :FileSystemSerializer, 'yard/serializers/file_system_serializer'
|
99
|
+
autoload :ProcessSerializer, 'yard/serializers/process_serializer'
|
100
|
+
autoload :StdoutSerializer, 'yard/serializers/stdout_serializer'
|
101
|
+
end
|
102
|
+
|
103
|
+
module Tags
|
104
|
+
autoload :DefaultFactory, 'yard/tags/default_factory'
|
105
|
+
autoload :Library, 'yard/tags/library'
|
106
|
+
autoload :Tag, 'yard/tags/tag'
|
107
|
+
end
|
108
|
+
|
109
|
+
autoload :Registry, 'yard/registry'
|
110
|
+
end
|
111
|
+
|
112
|
+
# Load handlers immediately
|
113
|
+
YARD::Handlers.constants.each {|c| YARD::Handlers.const_get(c) }
|
114
|
+
|
115
|
+
# P() needs to be loaded right away
|
116
|
+
YARD::CodeObjects::Proxy
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module CLI
|
5
|
+
class YardGraph
|
6
|
+
attr_reader :options, :visibilities
|
7
|
+
|
8
|
+
def self.run(*args) new.run(*args) end
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@options = SymbolHash[
|
12
|
+
:format => :dot,
|
13
|
+
:template => :default,
|
14
|
+
:serializer => YARD::Serializers::StdoutSerializer.new,
|
15
|
+
:visibility => [:public]
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def run(*args)
|
20
|
+
optparse(*args)
|
21
|
+
Registry.load
|
22
|
+
Generators::UMLGenerator.new(options).generate Registry.root
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def optparse(*args)
|
28
|
+
opts = OptionParser.new
|
29
|
+
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "General Options:"
|
32
|
+
|
33
|
+
opts.on('-b', '--db FILE', 'Use a specified .yardoc db to load from or save to. (defaults to .yardoc)') do |yfile|
|
34
|
+
YARD::Registry.yardoc_file = yfile
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('--full', 'Full class diagrams (show methods and attributes).') do
|
38
|
+
options[:full] = true
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-d', '--dependencies', 'Show mixins in dependency graph.') do
|
42
|
+
options[:dependencies] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('--no-public', "Don't show public methods. (default shows public)") do
|
46
|
+
options[:visibility].delete(:public)
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('--protected', "Show or don't show protected methods. (default hides protected)") do
|
50
|
+
options[:visibility].push(:protected)
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('--private', "Show or don't show private methods. (default hides private)") do
|
54
|
+
options[:visibility].push(:private)
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.separator ""
|
58
|
+
opts.separator "Output options:"
|
59
|
+
|
60
|
+
opts.on('--dot [OPTIONS]', 'Send the results direclty to `dot` with optional arguments.') do |dotopts|
|
61
|
+
options[:serializer] = Serializers::ProcessSerializer.new('dot ' + dotopts.to_s)
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on('-f', '--file [FILE]', 'Writes output to a file instead of stdout.') do |file|
|
65
|
+
options[:serializer] = Serializers::FileSystemSerializer.new(:basepath => '.', :extension => nil)
|
66
|
+
options[:serializer].instance_eval "def serialized_path(object) #{file.inspect} end"
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.separator ""
|
70
|
+
opts.separator "Other options:"
|
71
|
+
opts.on_tail('-q', '--quiet', 'Show no warnings') { log.level = Logger::ERROR }
|
72
|
+
opts.on_tail('--verbose', 'Show debugging information') { log.level = Logger::DEBUG }
|
73
|
+
opts.on_tail('-v', '--version', 'Show version.') { puts "yard #{YARD::VERSION}"; exit }
|
74
|
+
opts.on_tail('-h', '--help', 'Show this help.') { puts opts; exit }
|
75
|
+
|
76
|
+
begin
|
77
|
+
opts.parse!(args)
|
78
|
+
rescue => e
|
79
|
+
STDERR.puts e.message
|
80
|
+
STDERR << "\n" << opts
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module CLI
|
5
|
+
class Yardoc
|
6
|
+
attr_reader :options, :visibilities
|
7
|
+
attr_accessor :files, :reload, :generate
|
8
|
+
|
9
|
+
def self.run(*args) new.run(*args) end
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@options = SymbolHash[
|
13
|
+
:format => :html,
|
14
|
+
:template => :default,
|
15
|
+
:serializer => YARD::Serializers::FileSystemSerializer.new,
|
16
|
+
:readme => ['README', 'README.txt'],
|
17
|
+
:verifier => lambda do |gen, obj|
|
18
|
+
return false if gen.respond_to?(:visibility) && !visibilities.include?(gen.visibility)
|
19
|
+
end
|
20
|
+
]
|
21
|
+
@visibilities = [:public]
|
22
|
+
@reload = true
|
23
|
+
@generate = true
|
24
|
+
@files = ['lib/**/*.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(*args)
|
28
|
+
optparse(*args)
|
29
|
+
Registry.load(files, reload)
|
30
|
+
|
31
|
+
if generate
|
32
|
+
Generators::FullDocGenerator.new(options).generate Registry.all(:module, :class)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def optparse(*args)
|
39
|
+
serialopts = SymbolHash.new
|
40
|
+
|
41
|
+
opts = OptionParser.new
|
42
|
+
opts.banner = "Usage: yardoc [options] [source files]"
|
43
|
+
|
44
|
+
opts.separator "(if a list of source files is omitted, lib/**/*.rb is used.)"
|
45
|
+
opts.separator ""
|
46
|
+
opts.separator "General Options:"
|
47
|
+
|
48
|
+
opts.on('-c', '--use-cache [FILE]',
|
49
|
+
'Use the cached .yardoc db to generate documentation. (defaults to no cache)') do |file|
|
50
|
+
YARD::Registry.yardoc_file = file if file
|
51
|
+
self.reload = false
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on('-b', '--db FILE', 'Use a specified .yardoc db to load from or save to. (defaults to .yardoc)') do |yfile|
|
55
|
+
YARD::Registry.yardoc_file = yfile
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('-n', '--no-output', 'Only generate .yardoc database, no documentation.') do
|
59
|
+
self.generate = false
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
|
63
|
+
if !require(file.gsub(/\.rb$/, ''))
|
64
|
+
log.error "The file `#{file}' was already loaded, perhaps you need to specify the absolute path to avoid name collisions."
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.separator ""
|
70
|
+
opts.separator "Output options:"
|
71
|
+
|
72
|
+
opts.on('--no-public', "Don't show public methods. (default shows public)") do
|
73
|
+
visibilities.delete(:public)
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on('--protected', "Show or don't show protected methods. (default hides protected)") do
|
77
|
+
visibilities.push(:protected)
|
78
|
+
end
|
79
|
+
|
80
|
+
opts.on('--private', "Show or don't show private methods. (default hides private)") do
|
81
|
+
visibilities.push(:private)
|
82
|
+
end
|
83
|
+
|
84
|
+
opts.on('-r', '--readme FILE', 'The readme file used as the title page of documentation.') do |readme|
|
85
|
+
options[:readme] = readme
|
86
|
+
end
|
87
|
+
|
88
|
+
opts.on('-d', '--output-dir PATH',
|
89
|
+
'The output directory. (defaults to ./doc)') do |dir|
|
90
|
+
serialopts[:basepath] = dir
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.on('-t', '--template TEMPLATE',
|
94
|
+
'The template to use. (defaults to "default")') do |template|
|
95
|
+
options[:template] = template.to_sym
|
96
|
+
end
|
97
|
+
|
98
|
+
opts.on('-p', '--template-path PATH',
|
99
|
+
'The template path to look for templates in. (used with -t).') do |path|
|
100
|
+
YARD::Generator::Base.register_template_path(path)
|
101
|
+
end
|
102
|
+
|
103
|
+
opts.on('-f', '--format FORMAT',
|
104
|
+
'The output format for the template. (defaults to html)') do |format|
|
105
|
+
options[:format] = format
|
106
|
+
end
|
107
|
+
|
108
|
+
opts.separator ""
|
109
|
+
opts.separator "Other options:"
|
110
|
+
opts.on_tail('-q', '--quiet', 'Show no warnings.') { log.level = Logger::ERROR }
|
111
|
+
opts.on_tail('--verbose', 'Show debugging information.') { log.level = Logger::DEBUG }
|
112
|
+
opts.on_tail('-v', '--version', 'Show version.') { puts "yard #{YARD::VERSION}"; exit }
|
113
|
+
opts.on_tail('-h', '--help', 'Show this help.') { puts opts; exit }
|
114
|
+
|
115
|
+
begin
|
116
|
+
opts.parse!(args)
|
117
|
+
rescue OptionParser::InvalidOption => e
|
118
|
+
STDERR.puts e.message
|
119
|
+
STDERR << "\n" << opts
|
120
|
+
exit
|
121
|
+
end
|
122
|
+
|
123
|
+
# Last minute modifications
|
124
|
+
self.files = args unless args.empty?
|
125
|
+
self.reload = false if self.files.empty?
|
126
|
+
visibilities.uniq!
|
127
|
+
options[:serializer] = Serializers::FileSystemSerializer.new(serialopts)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,321 @@
|
|
1
|
+
module YARD
|
2
|
+
module CodeObjects
|
3
|
+
class CodeObjectList < Array
|
4
|
+
def initialize(owner = Registry.root)
|
5
|
+
@owner = owner
|
6
|
+
end
|
7
|
+
|
8
|
+
def push(value)
|
9
|
+
value = Proxy.new(@owner, value) if value.is_a?(String) || value.is_a?(Symbol)
|
10
|
+
if value.is_a?(CodeObjects::Base) || value.is_a?(Proxy)
|
11
|
+
super(value) unless include?(value)
|
12
|
+
else
|
13
|
+
raise ArgumentError, "#{value.class} is not a valid CodeObject"
|
14
|
+
end
|
15
|
+
self
|
16
|
+
end
|
17
|
+
alias_method :<<, :push
|
18
|
+
end
|
19
|
+
|
20
|
+
NSEP = '::'
|
21
|
+
ISEP = '#'
|
22
|
+
CONSTANTMATCH = /[A-Z]\w*/
|
23
|
+
NAMESPACEMATCH = /(?:(?:#{Regexp.quote NSEP})?#{CONSTANTMATCH})+/
|
24
|
+
METHODNAMEMATCH = /[a-zA-Z_]\w*[!?]?|[-+~]\@|<<|>>|=~|===?|[<>]=?|\*\*|[-\/+%^&*~`|]|\[\]=?/
|
25
|
+
METHODMATCH = /(?:(?:#{NAMESPACEMATCH}|self)\s*(?:\.|#{Regexp.quote NSEP})\s*)?#{METHODNAMEMATCH}/
|
26
|
+
|
27
|
+
BUILTIN_EXCEPTIONS = ["SecurityError", "Exception", "NoMethodError", "FloatDomainError",
|
28
|
+
"IOError", "TypeError", "NotImplementedError", "SystemExit", "Interrupt", "SyntaxError",
|
29
|
+
"RangeError", "NoMemoryError", "ArgumentError", "ThreadError", "EOFError", "RuntimeError",
|
30
|
+
"ZeroDivisionError", "StandardError", "LoadError", "NameError", "LocalJumpError", "SystemCallError",
|
31
|
+
"SignalException", "ScriptError", "SystemStackError", "RegexpError", "IndexError"]
|
32
|
+
BUILTIN_CLASSES = ["TrueClass", "Array", "Dir", "Struct", "UnboundMethod", "Object", "Fixnum", "Float",
|
33
|
+
"ThreadGroup", "MatchData", "Proc", "Binding", "Class", "Time", "Bignum", "NilClass", "Symbol",
|
34
|
+
"Numeric", "String", "Data", "MatchingData", "Regexp", "Integer", "File", "IO", "Range", "FalseClass",
|
35
|
+
"Method", "Continuation", "Thread", "Hash", "Module"] + BUILTIN_EXCEPTIONS
|
36
|
+
BUILTIN_MODULES = ["ObjectSpace", "Signal", "Marshal", "Kernel", "Process", "GC", "FileTest", "Enumerable",
|
37
|
+
"Comparable", "Errno", "Precision", "Math", "DTracer"]
|
38
|
+
BUILTIN_ALL = BUILTIN_CLASSES + BUILTIN_MODULES
|
39
|
+
|
40
|
+
BUILTIN_EXCEPTIONS_HASH = BUILTIN_EXCEPTIONS.inject({}) {|h,n| h.update(n => true) }
|
41
|
+
|
42
|
+
class Base
|
43
|
+
attr_reader :name
|
44
|
+
attr_accessor :namespace
|
45
|
+
attr_accessor :source, :signature, :file, :line, :docstring, :dynamic
|
46
|
+
|
47
|
+
def dynamic?; @dynamic end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
def new(namespace, name, *args, &block)
|
51
|
+
if name =~ /(?:#{NSEP}|#{ISEP})([^#{NSEP}#{ISEP}]+)$/
|
52
|
+
return new(Proxy.new(namespace, $`), $1, *args, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
keyname = namespace && namespace.respond_to?(:path) ? namespace.path : ''
|
56
|
+
if self == RootObject
|
57
|
+
keyname = :root
|
58
|
+
elsif keyname.empty?
|
59
|
+
keyname = name.to_s
|
60
|
+
elsif self == MethodObject
|
61
|
+
keyname += (!args.first || args.first.to_sym == :instance ? ISEP : NSEP) + name.to_s
|
62
|
+
else
|
63
|
+
keyname += NSEP + name.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
if self != RootObject && obj = Registry[keyname]
|
67
|
+
yield(obj) if block_given?
|
68
|
+
obj
|
69
|
+
else
|
70
|
+
Registry.objects[keyname] = super(namespace, name, *args, &block)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def initialize(namespace, name, *args)
|
76
|
+
if namespace && namespace != :root &&
|
77
|
+
!namespace.is_a?(NamespaceObject) && !namespace.is_a?(Proxy)
|
78
|
+
raise ArgumentError, "Invalid namespace object: #{namespace}"
|
79
|
+
end
|
80
|
+
|
81
|
+
@name = name.to_sym
|
82
|
+
@tags = []
|
83
|
+
@docstring = ""
|
84
|
+
self.namespace = namespace
|
85
|
+
yield(self) if block_given?
|
86
|
+
end
|
87
|
+
|
88
|
+
def ==(other)
|
89
|
+
if other.is_a?(Proxy)
|
90
|
+
path == other.path
|
91
|
+
else
|
92
|
+
super
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def [](key)
|
97
|
+
if respond_to?(key)
|
98
|
+
send(key)
|
99
|
+
else
|
100
|
+
instance_variable_get("@#{key}")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def []=(key, value)
|
105
|
+
if respond_to?("#{key}=")
|
106
|
+
send("#{key}=", value)
|
107
|
+
else
|
108
|
+
instance_variable_set("@#{key}", value)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def method_missing(meth, *args, &block)
|
113
|
+
if meth.to_s =~ /=$/
|
114
|
+
self[meth.to_s[0..-2]] = *args
|
115
|
+
elsif instance_variable_get("@#{meth}")
|
116
|
+
self[meth]
|
117
|
+
else
|
118
|
+
super
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Attaches source code to a code object with an optional file location
|
124
|
+
#
|
125
|
+
# @param [Parser::Statement, String] statement
|
126
|
+
# the +Parser::Statement+ holding the source code or the raw source
|
127
|
+
# as a +String+ for the definition of the code object only (not the block)
|
128
|
+
def source=(statement)
|
129
|
+
if statement.is_a? Parser::Statement
|
130
|
+
src = statement.tokens.to_s
|
131
|
+
blk = statement.block ? statement.block.to_s : ""
|
132
|
+
if src =~ /^def\s.*[^\)]$/ && blk[0,1] !~ /\r|\n/
|
133
|
+
blk = ";" + blk
|
134
|
+
end
|
135
|
+
|
136
|
+
@source = format_source(src + blk)
|
137
|
+
self.line = statement.tokens.first.line_no
|
138
|
+
self.signature = src
|
139
|
+
else
|
140
|
+
@source = format_source(statement.to_s)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Attaches a docstring to a code oject by parsing the comments attached to the statement
|
146
|
+
# and filling the {#tags} and {#docstring} methods with the parsed information.
|
147
|
+
#
|
148
|
+
# @param [String, Array<String>] comments
|
149
|
+
# the comments attached to the code object to be parsed
|
150
|
+
# into a docstring and meta tags.
|
151
|
+
def docstring=(comments)
|
152
|
+
@short_docstring = nil
|
153
|
+
parse_comments(comments) if comments
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Gets the first line of a docstring to the period or the first paragraph.
|
158
|
+
#
|
159
|
+
# @return [String] The first line or paragraph of the docstring; always ends with a period.
|
160
|
+
def short_docstring
|
161
|
+
@short_docstring ||= (docstring.split(/\.|\r?\n\r?\n/).first || '')
|
162
|
+
@short_docstring += '.' unless @short_docstring.empty?
|
163
|
+
@short_docstring
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Default type is the lowercase class name without the "Object" suffix
|
168
|
+
#
|
169
|
+
# Override this method to provide a custom object type
|
170
|
+
#
|
171
|
+
# @return [Symbol] the type of code object this represents
|
172
|
+
def type
|
173
|
+
self.class.name.split(/#{NSEP}/).last.gsub(/Object$/, '').downcase.to_sym
|
174
|
+
end
|
175
|
+
|
176
|
+
def path
|
177
|
+
if parent && parent != Registry.root
|
178
|
+
[parent.path, name.to_s].join(sep)
|
179
|
+
else
|
180
|
+
name.to_s
|
181
|
+
end
|
182
|
+
end
|
183
|
+
alias_method :to_s, :path
|
184
|
+
|
185
|
+
def inspect
|
186
|
+
"#<yardoc #{type} #{path}>"
|
187
|
+
end
|
188
|
+
|
189
|
+
def namespace=(obj)
|
190
|
+
if @namespace
|
191
|
+
@namespace.children.delete(self)
|
192
|
+
Registry.delete(self)
|
193
|
+
end
|
194
|
+
|
195
|
+
@namespace = (obj == :root ? Registry.root : obj)
|
196
|
+
|
197
|
+
if @namespace
|
198
|
+
@namespace.children << self unless @namespace.is_a?(Proxy)
|
199
|
+
Registry.register(self)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
alias_method :parent, :namespace
|
204
|
+
alias_method :parent=, :namespace=
|
205
|
+
|
206
|
+
##
|
207
|
+
# Convenience method to return the first tag
|
208
|
+
# object in the list of tag objects of that name
|
209
|
+
#
|
210
|
+
# Example:
|
211
|
+
# doc = YARD::Documentation.new("@return zero when nil")
|
212
|
+
# doc.tag("return").text # => "zero when nil"
|
213
|
+
#
|
214
|
+
# @param [#to_s] name the tag name to return data for
|
215
|
+
# @return [Tags::Tag] the first tag in the list of {#tags}
|
216
|
+
def tag(name)
|
217
|
+
@tags.find {|tag| tag.tag_name.to_s == name.to_s }
|
218
|
+
end
|
219
|
+
|
220
|
+
##
|
221
|
+
# Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
222
|
+
#
|
223
|
+
# @param name the tag name to return data for, or nil for all tags
|
224
|
+
# @return [Array<Tags::Tag>] the list of tags by the specified tag name
|
225
|
+
def tags(name = nil)
|
226
|
+
return @tags if name.nil?
|
227
|
+
@tags.select {|tag| tag.tag_name.to_s == name.to_s }
|
228
|
+
end
|
229
|
+
|
230
|
+
##
|
231
|
+
# Returns true if at least one tag by the name +name+ was declared
|
232
|
+
#
|
233
|
+
# @param [String] name the tag name to search for
|
234
|
+
# @return [Boolean] whether or not the tag +name+ was declared
|
235
|
+
def has_tag?(name)
|
236
|
+
@tags.any? {|tag| tag.tag_name.to_s == name.to_s }
|
237
|
+
end
|
238
|
+
|
239
|
+
protected
|
240
|
+
|
241
|
+
def sep; NSEP end
|
242
|
+
|
243
|
+
private
|
244
|
+
|
245
|
+
##
|
246
|
+
# Parses out comments split by newlines into a new code object
|
247
|
+
#
|
248
|
+
# @param [Array<String>, String] comments
|
249
|
+
# the newline delimited array of comments. If the comments
|
250
|
+
# are passed as a String, they will be split by newlines.
|
251
|
+
def parse_comments(comments)
|
252
|
+
return if comments.empty?
|
253
|
+
meta_match = /^@(\S+)\s*(.*)/
|
254
|
+
comments = comments.split(/\r?\n/) if comments.is_a? String
|
255
|
+
@tags, @docstring = [], ""
|
256
|
+
|
257
|
+
indent, last_indent = comments.first[/^\s*/].length, 0
|
258
|
+
orig_indent = 0
|
259
|
+
last_line = ""
|
260
|
+
tag_name, tag_klass, tag_buf, raw_buf = nil, nil, "", []
|
261
|
+
|
262
|
+
(comments+['']).each_with_index do |line, index|
|
263
|
+
indent = line[/^\s*/].length
|
264
|
+
empty = (line =~ /^\s*$/ ? true : false)
|
265
|
+
done = comments.size == index
|
266
|
+
|
267
|
+
if tag_name && (((indent < orig_indent && !empty) || done) ||
|
268
|
+
(indent <= last_indent && line =~ meta_match))
|
269
|
+
tagfactory = Tags::Library.new
|
270
|
+
tag_method = "#{tag_name}_tag"
|
271
|
+
if tag_name && tagfactory.respond_to?(tag_method)
|
272
|
+
if tagfactory.method(tag_method).arity == 2
|
273
|
+
@tags << tagfactory.send(tag_method, tag_buf, raw_buf.join("\n"))
|
274
|
+
else
|
275
|
+
@tags << tagfactory.send(tag_method, tag_buf)
|
276
|
+
end
|
277
|
+
else
|
278
|
+
log.warn "Unknown tag @#{tag_name} in documentation for `#{path}`"
|
279
|
+
end
|
280
|
+
tag_name, tag_buf, raw_buf = nil, '', []
|
281
|
+
orig_indent = 0
|
282
|
+
end
|
283
|
+
|
284
|
+
# Found a meta tag
|
285
|
+
if line =~ meta_match
|
286
|
+
orig_indent = indent
|
287
|
+
tag_name, tag_buf = $1, $2
|
288
|
+
raw_buf = [tag_buf.dup]
|
289
|
+
elsif tag_name && indent >= orig_indent && !empty
|
290
|
+
# Extra data added to the tag on the next line
|
291
|
+
last_empty = last_line =~ /^[ \t]*$/ ? true : false
|
292
|
+
|
293
|
+
if last_empty
|
294
|
+
tag_buf << "\n\n"
|
295
|
+
raw_buf << ''
|
296
|
+
end
|
297
|
+
|
298
|
+
tag_buf << line.gsub(/^[ \t]{#{indent}}/, last_empty ? '' : ' ')
|
299
|
+
raw_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
|
300
|
+
elsif !tag_name
|
301
|
+
# Regular docstring text
|
302
|
+
@docstring << line << "\n"
|
303
|
+
end
|
304
|
+
|
305
|
+
last_indent = indent
|
306
|
+
last_line = line
|
307
|
+
end
|
308
|
+
|
309
|
+
# Remove trailing/leading whitespace / newlines
|
310
|
+
@docstring.gsub!(/\A[\r\n\s]+|[\r\n\s]+\Z/, '')
|
311
|
+
end
|
312
|
+
|
313
|
+
# Formats source code by removing leading indentation
|
314
|
+
def format_source(source)
|
315
|
+
source.chomp!
|
316
|
+
indent = source.split(/\r?\n/).last[/^([ \t]*)/, 1].length
|
317
|
+
source.gsub(/^[ \t]{#{indent}}/, '')
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|