docjs 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -63
- data/bin/docjs +30 -8
- data/bin/docjs.rb +30 -8
- data/docjs.gemspec +2 -2
- data/docs/ARCHITECTURE.md +0 -0
- data/{CONCEPT.md → docs/CONCEPT.md} +0 -0
- data/{DOCUMENTATION.md → docs/DOCUMENTATION.md} +2 -4
- data/docs/PATTERNS.md +101 -0
- data/docs/guides/CUSTOMIZE.md +158 -0
- data/docs/guides/TRY.md +63 -0
- data/docs/guides/USE.md +256 -0
- data/lib/boot.rb +2 -6
- data/lib/code_object/base.rb +5 -0
- data/lib/dom/node.rb +1 -1
- data/lib/{tasks/render_task.rb → generator/generator.rb} +15 -9
- data/lib/helper/helper.rb +2 -2
- data/lib/helper/linker.rb +7 -13
- data/lib/processor.rb +3 -12
- data/lib/renderer.rb +2 -0
- data/lib/token/container.rb +2 -1
- data/lib/token/handler.rb +187 -115
- data/lib/token/token.rb +35 -3
- data/templates/application.rb +7 -5
- data/templates/{tasks/api_index_task.rb → generators/api_index_generator.rb} +2 -2
- data/templates/{tasks/typed_task.rb → generators/api_pages_generator.rb} +2 -2
- data/templates/{tasks/docs_task.rb → generators/docs_generator.rb} +9 -2
- data/templates/{tasks/json_data_task.rb → generators/json_generator.rb} +2 -2
- data/templates/tokens/tokens.rb +2 -2
- data/{lib/code_object → templates/types}/function.rb +5 -3
- data/{lib/code_object → templates/types}/object.rb +0 -2
- data/templates/types/prototype.rb +2 -3
- data/templates/views/tokens/_default.html.erb +0 -2
- data/test/code_object/prototype.rb +1 -1
- data/test/dom/dom.absolute_nodes.rb +2 -3
- data/test/dom/dom.rb +3 -3
- data/test/dom/node.rb +9 -9
- data/test/integration/converter.rb +3 -3
- data/test/token/handler.rb +12 -9
- data/test/token/tokens.rb +1 -1
- metadata +16 -12
- data/RENDERING.md +0 -8
data/lib/token/token.rb
CHANGED
@@ -1,17 +1,49 @@
|
|
1
1
|
module Token
|
2
|
+
|
3
|
+
# Serves as Base-Class for all registered tokens.
|
4
|
+
# Registering a token with
|
5
|
+
#
|
6
|
+
# Token:Handler.register :awesome, :template => :foo, :description => "Description"
|
7
|
+
#
|
8
|
+
# is pretty much equivalent to
|
9
|
+
#
|
10
|
+
# class Token::AwesomeToken < Token::Token; end
|
11
|
+
# Token::AwesomeToken.process_options({
|
12
|
+
# :token => :awesome,
|
13
|
+
# :template => :foo,
|
14
|
+
# :description => "Description"
|
15
|
+
# })
|
2
16
|
class Token
|
3
17
|
|
4
18
|
attr_reader :name, :content, :types, :children
|
5
19
|
|
6
|
-
def initialize(args = {})
|
7
|
-
|
20
|
+
def initialize(args = {})
|
8
21
|
@name = args[:name]
|
9
22
|
@types = args[:types]
|
10
23
|
@children = args[:children]
|
11
24
|
@content = args[:content] || ""
|
12
25
|
end
|
13
26
|
|
14
|
-
#
|
27
|
+
# Processes the options, which are added while registering the new token-handler
|
28
|
+
#
|
29
|
+
# Token:Handler.register :awesome, :template => :foo, :description => "Description"
|
30
|
+
#
|
31
|
+
# This will create a class Token::AwesomeToken, which extends {Token::Token}. After creating the class
|
32
|
+
# {.process_options} will be called with all provided options to apply those to the class.
|
33
|
+
#
|
34
|
+
# Because the options are valid for all instances of a tokenclass, the contents are stored in
|
35
|
+
# class-variables and class-methods are defined as accessors:
|
36
|
+
#
|
37
|
+
# - handler
|
38
|
+
# - token
|
39
|
+
# - template
|
40
|
+
# - html
|
41
|
+
# - area
|
42
|
+
# - description
|
43
|
+
#
|
44
|
+
# Further information about this options can be found at {Token::Handler.register}
|
45
|
+
#
|
46
|
+
# @note Because class-methods are defined in this method, it should only be performed once!!!
|
15
47
|
def self.process_options(options = {})
|
16
48
|
|
17
49
|
# pushing defaults
|
data/templates/application.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Load CodeObject::Types
|
2
|
+
require_relative 'types/object'
|
3
|
+
require_relative 'types/function'
|
2
4
|
require_relative 'types/prototype'
|
3
5
|
|
4
6
|
# Load Default Tokens
|
@@ -7,8 +9,8 @@ require_relative 'tokens/tokens'
|
|
7
9
|
# Load Helpers
|
8
10
|
require_relative 'helpers/template'
|
9
11
|
|
10
|
-
# Load
|
11
|
-
require_relative '
|
12
|
-
require_relative '
|
13
|
-
require_relative '
|
14
|
-
require_relative '
|
12
|
+
# Load Generators
|
13
|
+
require_relative 'generators/api_pages_generator'
|
14
|
+
require_relative 'generators/docs_generator'
|
15
|
+
require_relative 'generators/api_index_generator'
|
16
|
+
require_relative 'generators/json_generator'
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Generator
|
2
2
|
|
3
|
-
class
|
3
|
+
class DocsGenerator < Generator
|
4
4
|
|
5
5
|
describe 'renders all specified Markdown files to static documentation'
|
6
6
|
layout 'application'
|
@@ -15,6 +15,13 @@ module Tasks
|
|
15
15
|
|
16
16
|
render_document doc
|
17
17
|
end
|
18
|
+
|
19
|
+
|
20
|
+
readme = Dom.docs.find('README')
|
21
|
+
in_context readme do
|
22
|
+
@document = readme
|
23
|
+
render 'doc_page', :to_file => "index.html"
|
24
|
+
end unless readme.nil?
|
18
25
|
end
|
19
26
|
|
20
27
|
def render_document(document)
|
data/templates/tokens/tokens.rb
CHANGED
@@ -5,14 +5,14 @@ module Token::Handler
|
|
5
5
|
register :private, :area => :sidebar
|
6
6
|
register :version, :area => :sidebar
|
7
7
|
|
8
|
-
register :see, :area => :
|
8
|
+
register :see, :area => :footnote
|
9
9
|
|
10
10
|
register :deprecated, :area => :notification
|
11
11
|
register :todo, :area => :notification
|
12
12
|
register :note, :area => :notification
|
13
13
|
register :warn, :area => :notification
|
14
14
|
|
15
|
-
register :example, :template =>
|
15
|
+
register :example, :template => :examples, :handler => :named_multiline
|
16
16
|
|
17
17
|
# Every @overload can contain **text-documentation**, **@param**- and **@return**-tokens
|
18
18
|
#
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative 'object'
|
2
|
-
|
3
1
|
module CodeObject
|
4
2
|
|
5
3
|
class Function < CodeObject::Object
|
@@ -16,6 +14,10 @@ module CodeObject
|
|
16
14
|
children[:prototype]
|
17
15
|
end
|
18
16
|
|
17
|
+
def display_name
|
18
|
+
@name + '()'
|
19
|
+
end
|
20
|
+
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -56,6 +58,6 @@ Token::Handler.register :throws, :handler => :typed
|
|
56
58
|
class CodeObject::Method < CodeObject::Function; end
|
57
59
|
Token::Handler.register :method, :handler => :noop, :area => :none
|
58
60
|
|
59
|
-
#
|
61
|
+
# ConstructorAlias
|
60
62
|
class CodeObject::Constructor < CodeObject::Function; end
|
61
63
|
Token::Handler.register(:constructor) { |token, content| @constructor = true }
|
data/test/dom/dom.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# ../data.img#1811393:1
|
2
2
|
require_relative '../../lib/dom/dom'
|
3
|
-
require_relative '../../lib/code_object/
|
3
|
+
require_relative '../../lib/code_object/base'
|
4
4
|
|
5
5
|
describe Dom, ".add_child" do
|
6
6
|
|
7
7
|
before do
|
8
8
|
Dom.clear
|
9
|
-
@o1 = CodeObject::
|
10
|
-
@o2 = CodeObject::
|
9
|
+
@o1 = CodeObject::Base.new
|
10
|
+
@o2 = CodeObject::Base.new
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should add absolute nodes" do
|
data/test/dom/node.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# ../data.img#1772233:1
|
2
2
|
require_relative '../../lib/dom/dom'
|
3
|
-
require_relative '../../lib/code_object/
|
3
|
+
require_relative '../../lib/code_object/base'
|
4
4
|
|
5
5
|
describe Dom::Node, "#resolve" do
|
6
6
|
|
7
7
|
before do
|
8
8
|
Dom.clear
|
9
|
-
@o1 = CodeObject::
|
10
|
-
@o2 = CodeObject::
|
11
|
-
@o3 = CodeObject::
|
12
|
-
@o4 = CodeObject::
|
9
|
+
@o1 = CodeObject::Base.new
|
10
|
+
@o2 = CodeObject::Base.new
|
11
|
+
@o3 = CodeObject::Base.new
|
12
|
+
@o4 = CodeObject::Base.new
|
13
13
|
|
14
14
|
Dom.add_node "Foo.bar" , @o1
|
15
15
|
@o1.add_node ".baz" , @o2
|
@@ -33,10 +33,10 @@ describe Dom::Node, "#qualified_name" do
|
|
33
33
|
|
34
34
|
before do
|
35
35
|
Dom.clear
|
36
|
-
@o1 = CodeObject::
|
37
|
-
@o2 = CodeObject::
|
38
|
-
@o3 = CodeObject::
|
39
|
-
@o4 = CodeObject::
|
36
|
+
@o1 = CodeObject::Base.new "bar"
|
37
|
+
@o2 = CodeObject::Base.new "baz"
|
38
|
+
@o3 = CodeObject::Base.new "bam"
|
39
|
+
@o4 = CodeObject::Base.new "poo"
|
40
40
|
|
41
41
|
Dom.add_node "Foo.bar" , @o1
|
42
42
|
@o1.add_node ".baz" , @o2
|
@@ -21,7 +21,7 @@ describe CodeObject::Converter, "#to_code_object" do
|
|
21
21
|
subject { @objects[0] }
|
22
22
|
|
23
23
|
it "should be a function named 'say_hello'" do
|
24
|
-
subject.
|
24
|
+
subject.is_a?(CodeObject::Function).should == true
|
25
25
|
subject.name.should == "say_hello"
|
26
26
|
end
|
27
27
|
|
@@ -45,7 +45,7 @@ describe CodeObject::Converter, "#to_code_object" do
|
|
45
45
|
subject { @objects[1] }
|
46
46
|
|
47
47
|
it "should be an Object named 'FOO'" do
|
48
|
-
subject.
|
48
|
+
subject.is_a?(CodeObject::Object).should == true
|
49
49
|
subject.name.should == "FOO"
|
50
50
|
end
|
51
51
|
end
|
@@ -54,7 +54,7 @@ describe CodeObject::Converter, "#to_code_object" do
|
|
54
54
|
subject { @objects[2] }
|
55
55
|
|
56
56
|
it "should be an Function named 'some_function'" do
|
57
|
-
subject.
|
57
|
+
subject.is_a?(CodeObject::Function).should == true
|
58
58
|
subject.name.should == "some_function"
|
59
59
|
end
|
60
60
|
|
data/test/token/handler.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# ../data.img#1771563:1
|
2
2
|
require_relative '../../lib/parser/comment'
|
3
|
-
require_relative '../../
|
3
|
+
require_relative '../../templates/types/function'
|
4
|
+
|
5
|
+
# Warning! This Tests have some sideeffects. All registered Tokens will create Classes, that are not
|
6
|
+
# removed on unregister
|
4
7
|
|
5
8
|
describe Token::Handler, ".register" do
|
6
9
|
|
@@ -36,7 +39,7 @@ describe Token::Handler, ".register" do
|
|
36
39
|
context "using a typed handler" do
|
37
40
|
|
38
41
|
before do
|
39
|
-
Token::Handler.register :test_handler, :typed
|
42
|
+
Token::Handler.register :test_handler, :handler => :typed
|
40
43
|
token = Parser::Tokenline.new :test_handler, "[MyType] This is some content"
|
41
44
|
@object.process_token(token)
|
42
45
|
end
|
@@ -56,7 +59,7 @@ describe Token::Handler, ".register" do
|
|
56
59
|
context "using a typed_with_name handler" do
|
57
60
|
|
58
61
|
before do
|
59
|
-
Token::Handler.register :test_handler, :typed_with_name
|
62
|
+
Token::Handler.register :test_handler, :handler => :typed_with_name
|
60
63
|
token = Parser::Tokenline.new :test_handler, "[Foo, Bar, Baz] MyName This is some content"
|
61
64
|
@object.process_token(token)
|
62
65
|
end
|
@@ -76,7 +79,7 @@ describe Token::Handler, ".register" do
|
|
76
79
|
|
77
80
|
context "processing a token without handler" do
|
78
81
|
|
79
|
-
token = Parser::Tokenline.new :
|
82
|
+
token = Parser::Tokenline.new :some_not_known_handler, "[Foo, Bar, Baz] MyName This is some content"
|
80
83
|
|
81
84
|
it "should raise an error" do
|
82
85
|
should_raise Token::NoTokenHandler do
|
@@ -111,24 +114,24 @@ describe Token::Handler, ".register" do
|
|
111
114
|
context "using a user-defined block as token-handler" do
|
112
115
|
|
113
116
|
before do
|
114
|
-
Token::Handler.register(:
|
117
|
+
Token::Handler.register(:test) do |tokenklass, content|
|
115
118
|
define_singleton_method :test_token do
|
116
|
-
|
119
|
+
tokenklass
|
117
120
|
end
|
118
121
|
|
119
122
|
define_singleton_method :test_content do
|
120
123
|
content
|
121
124
|
end
|
122
125
|
end
|
123
|
-
@object.process_token Parser::Tokenline.new :
|
126
|
+
@object.process_token Parser::Tokenline.new :test, "This is some content"
|
124
127
|
end
|
125
128
|
|
126
129
|
it "should be added to the list of handlers" do
|
127
|
-
Token::Handler.handlers.include?(:
|
130
|
+
Token::Handler.handlers.include?(:test).should == true
|
128
131
|
end
|
129
132
|
|
130
133
|
it "should be evaled in CodeObject context" do
|
131
|
-
@object.test_token.should ==
|
134
|
+
@object.test_token.should == Token::Token::TestToken
|
132
135
|
@object.test_content.should == "This is some content"
|
133
136
|
end
|
134
137
|
|
data/test/token/tokens.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: docjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Jonathan Brachth\xC3\xA4user"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-25 00:00:00 +02:00
|
14
14
|
default_executable: bin/docjs
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -44,26 +44,29 @@ extensions: []
|
|
44
44
|
extra_rdoc_files: []
|
45
45
|
|
46
46
|
files:
|
47
|
-
- CONCEPT.md
|
48
|
-
- DOCUMENTATION.md
|
49
47
|
- LICENSE.md
|
50
48
|
- README.md
|
51
|
-
- RENDERING.md
|
52
49
|
- bin/docjs
|
53
50
|
- bin/docjs.rb
|
54
51
|
- docjs.gemspec
|
52
|
+
- docs/ARCHITECTURE.md
|
53
|
+
- docs/CONCEPT.md
|
54
|
+
- docs/DOCUMENTATION.md
|
55
|
+
- docs/PATTERNS.md
|
56
|
+
- docs/guides/CUSTOMIZE.md
|
57
|
+
- docs/guides/TRY.md
|
58
|
+
- docs/guides/USE.md
|
55
59
|
- lib/boot.rb
|
56
60
|
- lib/code_object/base.rb
|
57
61
|
- lib/code_object/converter.rb
|
58
62
|
- lib/code_object/exceptions.rb
|
59
|
-
- lib/code_object/function.rb
|
60
|
-
- lib/code_object/object.rb
|
61
63
|
- lib/configs.rb
|
62
64
|
- lib/document/document.rb
|
63
65
|
- lib/dom/dom.rb
|
64
66
|
- lib/dom/exceptions.rb
|
65
67
|
- lib/dom/no_doc.rb
|
66
68
|
- lib/dom/node.rb
|
69
|
+
- lib/generator/generator.rb
|
67
70
|
- lib/helper/helper.rb
|
68
71
|
- lib/helper/linker.rb
|
69
72
|
- lib/logger.rb
|
@@ -74,13 +77,16 @@ files:
|
|
74
77
|
- lib/parser/parser.rb
|
75
78
|
- lib/processor.rb
|
76
79
|
- lib/renderer.rb
|
77
|
-
- lib/tasks/render_task.rb
|
78
80
|
- lib/thor.rb
|
79
81
|
- lib/token/container.rb
|
80
82
|
- lib/token/exceptions.rb
|
81
83
|
- lib/token/handler.rb
|
82
84
|
- lib/token/token.rb
|
83
85
|
- templates/application.rb
|
86
|
+
- templates/generators/api_index_generator.rb
|
87
|
+
- templates/generators/api_pages_generator.rb
|
88
|
+
- templates/generators/docs_generator.rb
|
89
|
+
- templates/generators/json_generator.rb
|
84
90
|
- templates/helpers/template.rb
|
85
91
|
- templates/resources/css/.sass-cache/98c121fba905284c2c8ca6220fe3c590e5c9ec19/application.scssc
|
86
92
|
- templates/resources/css/application.css
|
@@ -112,11 +118,9 @@ files:
|
|
112
118
|
- templates/resources/scss/_resets.scss
|
113
119
|
- templates/resources/scss/_tooltip.scss
|
114
120
|
- templates/resources/scss/application.scss
|
115
|
-
- templates/tasks/api_index_task.rb
|
116
|
-
- templates/tasks/docs_task.rb
|
117
|
-
- templates/tasks/json_data_task.rb
|
118
|
-
- templates/tasks/typed_task.rb
|
119
121
|
- templates/tokens/tokens.rb
|
122
|
+
- templates/types/function.rb
|
123
|
+
- templates/types/object.rb
|
120
124
|
- templates/types/prototype.rb
|
121
125
|
- templates/views/api_index.html.erb
|
122
126
|
- templates/views/doc_page.html.erb
|