docjs 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONCEPT.md +80 -0
- data/DOCUMENTATION.md +41 -0
- data/LICENSE.md +19 -0
- data/README.md +19 -0
- data/RENDERING.md +8 -0
- data/bin/docjs +190 -0
- data/docjs.gemspec +32 -0
- data/lib/boot.rb +34 -0
- data/lib/code_object/base.rb +48 -0
- data/lib/code_object/converter.rb +48 -0
- data/lib/code_object/exceptions.rb +5 -0
- data/lib/code_object/function.rb +84 -0
- data/lib/code_object/object.rb +18 -0
- data/lib/code_object/type.rb +43 -0
- data/lib/configs.rb +53 -0
- data/lib/document/document.rb +25 -0
- data/lib/dom/dom.rb +188 -0
- data/lib/dom/exceptions.rb +12 -0
- data/lib/dom/no_doc.rb +26 -0
- data/lib/dom/node.rb +415 -0
- data/lib/helper/helper.rb +120 -0
- data/lib/helper/linker.rb +130 -0
- data/lib/logger.rb +49 -0
- data/lib/parser/comment.rb +69 -0
- data/lib/parser/comment_parser.rb +90 -0
- data/lib/parser/exceptions.rb +6 -0
- data/lib/parser/meta_container.rb +20 -0
- data/lib/parser/parser.rb +269 -0
- data/lib/processor.rb +123 -0
- data/lib/renderer.rb +108 -0
- data/lib/tasks/render_task.rb +112 -0
- data/lib/thor.rb +27 -0
- data/lib/token/container.rb +84 -0
- data/lib/token/exceptions.rb +6 -0
- data/lib/token/handler.rb +242 -0
- data/lib/token/token.rb +46 -0
- data/templates/application.rb +14 -0
- data/templates/helpers/template.rb +66 -0
- data/templates/resources/css/.sass-cache/98c121fba905284c2c8ca6220fe3c590e5c9ec19/application.scssc +0 -0
- data/templates/resources/css/application.css +836 -0
- data/templates/resources/img/arrow_down.png +0 -0
- data/templates/resources/img/arrow_right.png +0 -0
- data/templates/resources/img/arrow_up.png +0 -0
- data/templates/resources/img/bullet_toggle_minus.png +0 -0
- data/templates/resources/img/bullet_toggle_plus.png +0 -0
- data/templates/resources/img/constructor.png +0 -0
- data/templates/resources/img/function.png +0 -0
- data/templates/resources/img/object.png +0 -0
- data/templates/resources/img/page.png +0 -0
- data/templates/resources/img/prototype.png +0 -0
- data/templates/resources/img/tag.png +0 -0
- data/templates/resources/js/application.js +318 -0
- data/templates/resources/js/jcore.js +129 -0
- data/templates/resources/js/jquery.cookie.js +92 -0
- data/templates/resources/js/jquery.js +16 -0
- data/templates/resources/js/jquery.tooltip.js +77 -0
- data/templates/resources/js/jquery.treeview.js +238 -0
- data/templates/resources/scss/_footer.scss +10 -0
- data/templates/resources/scss/_header.scss +184 -0
- data/templates/resources/scss/_helpers.scss +91 -0
- data/templates/resources/scss/_print.scss +20 -0
- data/templates/resources/scss/_resets.scss +132 -0
- data/templates/resources/scss/_tooltip.scss +26 -0
- data/templates/resources/scss/application.scss +442 -0
- data/templates/tasks/api_index_task.rb +26 -0
- data/templates/tasks/docs_task.rb +33 -0
- data/templates/tasks/json_data_task.rb +55 -0
- data/templates/tasks/typed_task.rb +54 -0
- data/templates/tokens/tokens.rb +22 -0
- data/templates/types/prototype.rb +20 -0
- data/templates/views/api_index.html.erb +21 -0
- data/templates/views/doc_page.html.erb +11 -0
- data/templates/views/function/_detail.html.erb +8 -0
- data/templates/views/function/index.html.erb +53 -0
- data/templates/views/index.html.erb +0 -0
- data/templates/views/layout/application.html.erb +73 -0
- data/templates/views/layout/json.html.erb +3 -0
- data/templates/views/object/index.html.erb +63 -0
- data/templates/views/tokens/_default.html.erb +11 -0
- data/templates/views/tokens/_default_token.html.erb +19 -0
- data/templates/views/tokens/_example.html.erb +2 -0
- data/templates/views/tokens/_examples.html.erb +1 -0
- data/test/code_object/converter.rb +78 -0
- data/test/code_object/prototype.rb +70 -0
- data/test/configs.rb +65 -0
- data/test/docs/README.CONCEPT.md +83 -0
- data/test/docs/README.md +14 -0
- data/test/dom/dom.absolute_nodes.rb +40 -0
- data/test/dom/dom.rb +72 -0
- data/test/dom/node.rb +53 -0
- data/test/integration/converter.rb +72 -0
- data/test/integration/parser_factory.rb +28 -0
- data/test/interactive.rb +7 -0
- data/test/js-files/absolute.js +11 -0
- data/test/js-files/comments_in_strings.js +31 -0
- data/test/js-files/core-doc-relative.js +77 -0
- data/test/js-files/core-doc.js +145 -0
- data/test/js-files/nested.js +34 -0
- data/test/js-files/nested_with_strings.js +35 -0
- data/test/js-files/prototype.js +33 -0
- data/test/js-files/simple.js +17 -0
- data/test/js-files/tokens.js +32 -0
- data/test/parser/comments_in_strings.rb +51 -0
- data/test/parser/intelligent_skip_until.rb +110 -0
- data/test/parser/parser.rb +273 -0
- data/test/rspec_helper.rb +23 -0
- data/test/token/handler.rb +136 -0
- data/test/token/tokens.rb +52 -0
- metadata +184 -0
data/CONCEPT.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
Concept of the Documententation
|
2
|
+
===============================
|
3
|
+
|
4
|
+
There are only two build-in types, we want to pay attention to:
|
5
|
+
|
6
|
+
1. Objects
|
7
|
+
2. Functions
|
8
|
+
|
9
|
+
|
10
|
+
Object
|
11
|
+
------
|
12
|
+
By **Objects** we mean all kind of *things*, that can contain other things. Those containted ones, we call **properties** of the Object.
|
13
|
+
|
14
|
+
In JavaScript this may look like:
|
15
|
+
|
16
|
+
var obj = {
|
17
|
+
property_one: function() { ... },
|
18
|
+
property_two: {
|
19
|
+
// another object
|
20
|
+
},
|
21
|
+
property_three: 3
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
Function
|
26
|
+
--------
|
27
|
+
**Functions** are *things*, that can be executed. They can have **parameters** and **return-values** There are two types of Functions: plain functions and **constructors**.
|
28
|
+
|
29
|
+
Example for a plain function:
|
30
|
+
|
31
|
+
function my_func(param) {
|
32
|
+
return "Hello world!";
|
33
|
+
}
|
34
|
+
|
35
|
+
Example for a function as a constructor
|
36
|
+
|
37
|
+
function my_constructor() {
|
38
|
+
this.message = "Hello world!";
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
Remember: any return-value of a constructor-function will be ignored and replaced by this
|
43
|
+
|
44
|
+
But a function can be an object at the same time. For example:
|
45
|
+
|
46
|
+
function my_func_two() {
|
47
|
+
return "fancy function";
|
48
|
+
}
|
49
|
+
my_func_two.message = "Say hello to Mr. Foo";
|
50
|
+
|
51
|
+
Most important a function can contain one special property **prototype**.
|
52
|
+
|
53
|
+
Remember: In this case the function has to be a constructor. Otherwise prototype would be useless, because it is only used when creating instances of the function using new. After creating an instance the prototype-object is accessible in the this-context of the instance.
|
54
|
+
|
55
|
+
function my_constructor() {
|
56
|
+
this.message = "Hello world!";
|
57
|
+
}
|
58
|
+
my_constructor.prop1 = 456;
|
59
|
+
my_constructor.prototype = {
|
60
|
+
some_proto_prop: 123
|
61
|
+
}
|
62
|
+
|
63
|
+
Revealing Module Pattern
|
64
|
+
------------------------
|
65
|
+
But what about revealing modules?
|
66
|
+
|
67
|
+
function my_module() {
|
68
|
+
|
69
|
+
// some private stuff here
|
70
|
+
|
71
|
+
return {
|
72
|
+
property_of_the: "returned object"
|
73
|
+
};
|
74
|
+
}
|
75
|
+
|
76
|
+
One should pay attention to this pattern while creating a documentation tool.
|
77
|
+
|
78
|
+
Conclusion
|
79
|
+
----------
|
80
|
+
So we can break it down to Functions and Objects. Objects can have properties. Functions can, at the same time, be Objects. There are special functions, called *constructors*, which in turn have one special property called *prototype*. This property has to be handled special in documentation.
|
data/DOCUMENTATION.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Fullqualifier
|
2
|
+
-------------
|
3
|
+
Like an absolute path (/etc/init.d/apache2) we use `FOO.bar` as fullqualifier to
|
4
|
+
an object or function.
|
5
|
+
|
6
|
+
A leading dot suggests filling the empty leading space with the current parsing-context
|
7
|
+
without modifying it. As such `.something_else` would be resolved to
|
8
|
+
`FOO.bar.something_else` in the current context.
|
9
|
+
|
10
|
+
Examplecode:
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @function my_module
|
14
|
+
* @return [my_module.object]
|
15
|
+
*/
|
16
|
+
function my_module() {
|
17
|
+
|
18
|
+
// some private stuff here
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @property .foo
|
23
|
+
*/
|
24
|
+
my_module.foo = 123;
|
25
|
+
|
26
|
+
|
27
|
+
/**
|
28
|
+
* @property .foo_bar
|
29
|
+
*/
|
30
|
+
my_module.foo_bar = 789;
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
* @object .object
|
35
|
+
*/
|
36
|
+
return {
|
37
|
+
/* @property .object.property_of_the */
|
38
|
+
property_of_the: "returned object"
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
data/LICENSE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Jonathan Brachthäuser (http://b-studios.de)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
jsdoc
|
2
|
+
=====
|
3
|
+
After total dataloss i have to rewrite the Readme's and Test's, so please be patient.
|
4
|
+
jsdoc is currently **not a bit** stable. Stay tuned.
|
5
|
+
|
6
|
+
For some more information about the architecture see:
|
7
|
+
|
8
|
+
- {Parser}
|
9
|
+
- {CodeObject}
|
10
|
+
- {Token}
|
11
|
+
- {Dom}
|
12
|
+
- {Renderer}
|
13
|
+
|
14
|
+
The 'executable' is {JsDoc}
|
15
|
+
|
16
|
+
Required Gems
|
17
|
+
=============
|
18
|
+
- thor
|
19
|
+
- rdiscount
|
data/RENDERING.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Es bietet sich an für manche Objekte eine extra Seite anzulegen und für andere nicht.
|
2
|
+
Stellt sich nur die Frage, wo man diese Grenze zieht.
|
3
|
+
|
4
|
+
Derzeit gibt es:
|
5
|
+
- Objekte ({CodeObject::Object})
|
6
|
+
- Funktionen ({CodeObject::Function})
|
7
|
+
|
8
|
+
Beide können selbst wieder andere Objekte und Funktionen beinhalten.
|
data/bin/docjs
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
#!/usr/bin/ruby1.9
|
2
|
+
# We need pathname to make it work with sym-links
|
3
|
+
require 'pathname'
|
4
|
+
require Pathname.new(__FILE__).realpath + '../../lib/boot'
|
5
|
+
|
6
|
+
# @todo The general flow of information should be documented here
|
7
|
+
#
|
8
|
+
# --String--> [Parser] --Commentstream--> [CodeObjectFactory] --Objectstream--> [Registry]
|
9
|
+
#
|
10
|
+
# Parser
|
11
|
+
# ------
|
12
|
+
# Turns the incoming stream of characters (string) into a stream of
|
13
|
+
# {Parser::Comment comments}. Those comments contain the parsed doclines, which
|
14
|
+
# are simply all lines found in the comment and all tokenlines.
|
15
|
+
|
16
|
+
# configure approot
|
17
|
+
Configs.set :root => Pathname.new(__FILE__).realpath + '../..'
|
18
|
+
|
19
|
+
# Pipeline:
|
20
|
+
# 1. load options from shell and specified YAML-file (if any)
|
21
|
+
# 2. load files
|
22
|
+
# 3. parse files
|
23
|
+
# 4. turn into objects and save to dom
|
24
|
+
# 5. render templates
|
25
|
+
#
|
26
|
+
# @note options declared in a build.yml will override command-line ones
|
27
|
+
# @todo command line option to copy all templates to specified directory like
|
28
|
+
# jsdoc dump_templates ../templates/original
|
29
|
+
class JsDoc < Thor
|
30
|
+
|
31
|
+
include Thor::Actions
|
32
|
+
|
33
|
+
desc "jsdoc CONFIG_FILE", "Starts documentation process"
|
34
|
+
set_options :files =>
|
35
|
+
{ :type => :array, :aliases => '-f', :default => [], :required => true },
|
36
|
+
|
37
|
+
:docs =>
|
38
|
+
{ :type => :array, :aliases => '-d', :default => ['README.md'], :required => true },
|
39
|
+
|
40
|
+
:output =>
|
41
|
+
{ :type => :string, :aliases => '-o', :default => 'out' },
|
42
|
+
|
43
|
+
:templates =>
|
44
|
+
{ :type => :string, :aliases => '-t', :default => Configs.root + 'templates' },
|
45
|
+
|
46
|
+
:appname =>
|
47
|
+
{ :type => :string, :aliases => '-n', :default => "MyAppName" },
|
48
|
+
|
49
|
+
:logfile =>
|
50
|
+
{ :type => :string, :aliases => '-lf', :default => 'jsdoc.log' },
|
51
|
+
|
52
|
+
:loglevel =>
|
53
|
+
{ :type => :string, :aliases => '-ll', :default => 'info' }
|
54
|
+
|
55
|
+
def jsdoc(config_file = nil)
|
56
|
+
# @see Thor#merge_options
|
57
|
+
configs = config_file ? merge_options(options, config_file) : options
|
58
|
+
|
59
|
+
begin
|
60
|
+
setup_application configs
|
61
|
+
|
62
|
+
# load application specific files
|
63
|
+
require Configs.templates + '/application.rb'
|
64
|
+
|
65
|
+
# Config Thor settings
|
66
|
+
JsDoc.source_root(Configs.templates)
|
67
|
+
self.destination_root = Configs.output
|
68
|
+
|
69
|
+
Processor.prepare_documents
|
70
|
+
# let's check our Documents tree
|
71
|
+
Dom.docs.print_tree
|
72
|
+
|
73
|
+
# the configs are now available through our Configs-module
|
74
|
+
Processor.process_and_render
|
75
|
+
|
76
|
+
Logger.info "Copying template resources to output"
|
77
|
+
directory 'resources/img', './img' # copy resources
|
78
|
+
directory 'resources/css', './css'
|
79
|
+
directory 'resources/js', './js'
|
80
|
+
|
81
|
+
rescue Exception => error
|
82
|
+
Logger.error error.message + "\n" + error.backtrace.map{|l| " #{l}" }.join("\n")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
desc "tokens", "Lists all supported tokens"
|
89
|
+
def tokens
|
90
|
+
say "Supported tokens:"
|
91
|
+
say Token::Handler.handlers.map{|k,v| " @#{k}" }.sort.join "\n"
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
desc "tasks", "Lists all registered render-tasks"
|
97
|
+
def tasks
|
98
|
+
say "Registered render-tasks:"
|
99
|
+
|
100
|
+
task_table = Processor.render_tasks.map{|k,v| [":#{k}","# #{v.description}"] }.sort
|
101
|
+
|
102
|
+
print_table task_table, :ident => 2, :colwidth => 20
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
# @todo implement!
|
108
|
+
desc "scaffold OUTPUT_DIR", "You can use scaffolding to get the templates and some basic ruby-files, that you will need to create your own templates"
|
109
|
+
set_options :logfile =>
|
110
|
+
{ :type => :string, :aliases => '-lf', :default => 'jsdoc.log' },
|
111
|
+
|
112
|
+
:loglevel =>
|
113
|
+
{ :type => :string, :aliases => '-ll', :default => 'info' }
|
114
|
+
def scaffold(output_dir)
|
115
|
+
|
116
|
+
setup_application options.merge({
|
117
|
+
:output => output_dir,
|
118
|
+
:templates => output_dir
|
119
|
+
})
|
120
|
+
|
121
|
+
# Setup Thor paths
|
122
|
+
JsDoc.source_root(Configs.root)
|
123
|
+
self.destination_root = Configs.output
|
124
|
+
Configs.set(:scaffolding_path, output_dir)
|
125
|
+
|
126
|
+
|
127
|
+
answers = {}
|
128
|
+
yes_no = "(y|n)"
|
129
|
+
|
130
|
+
Logger.info "We need some information from you, to customize the scaffolding process to your needs."
|
131
|
+
|
132
|
+
answers[:build] = yes? "Do you wan't to generate a build.yml? #{yes_no}"
|
133
|
+
write_build_file if answers[:build]
|
134
|
+
|
135
|
+
Configs.set :answers, answers
|
136
|
+
|
137
|
+
# Work with the answers
|
138
|
+
Logger.info "Copying the template files to #{Configs.templates}"
|
139
|
+
directory 'templates', Configs.templates # copy templates and resources
|
140
|
+
|
141
|
+
Logger.info "Copying the included *.rb files to #{Configs.includes}"
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
protected
|
146
|
+
|
147
|
+
def write_build_file
|
148
|
+
|
149
|
+
build = {
|
150
|
+
'files' => [],
|
151
|
+
'docs' => [],
|
152
|
+
'output' => 'docs',
|
153
|
+
'logfile' => 'logfile.log',
|
154
|
+
'loglevel' => 'info',
|
155
|
+
'templates' => Configs.scaffolding_path
|
156
|
+
}
|
157
|
+
|
158
|
+
say "\nPlease enter the name of your App", :bold
|
159
|
+
build['appname'] = ask ">"
|
160
|
+
|
161
|
+
say "\nPlease enter the javascript-files you want to integrate into your documentation", :bold
|
162
|
+
say "(You will be asked multiple times, unless your answer is empty) You also can specify a file-matching pattern, foo/**/*.js"
|
163
|
+
|
164
|
+
while true do
|
165
|
+
answer = ask ">"
|
166
|
+
break if answer == ""
|
167
|
+
build['files'] << answer
|
168
|
+
end
|
169
|
+
|
170
|
+
say "\nPlease enter the markdown-documentation-files you want to integrate into your documentation", :bold
|
171
|
+
say "(You will be asked multiple times, unless your answer is empty) You also can specify a file-matching pattern, like docs/*.md"
|
172
|
+
|
173
|
+
while true do
|
174
|
+
answer = ask ">"
|
175
|
+
break if answer == ""
|
176
|
+
build['docs'] << answer
|
177
|
+
end
|
178
|
+
|
179
|
+
# answers[:scss_build] = yes? "Do you wan't to integrate SCSS into your build-process? #{yes_no}"
|
180
|
+
|
181
|
+
# maybe ask some more information to generate build.yml
|
182
|
+
create_file Configs.wdir + "/build.yml", build.to_yaml
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
unless ARGV.first and JsDoc.method_defined?(ARGV.first)
|
188
|
+
ARGV.unshift 'jsdoc'
|
189
|
+
end
|
190
|
+
JsDoc.start(ARGV)
|
data/docjs.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.required_rubygems_version = ">= 1.5"
|
3
|
+
s.required_ruby_version = '>= 1.9'
|
4
|
+
|
5
|
+
|
6
|
+
s.name = 'docjs'
|
7
|
+
s.version = '0.1'
|
8
|
+
s.date = '2011-06-07'
|
9
|
+
s.summary = "Javascript Documentation Generator"
|
10
|
+
s.description = "Create beautyful Javascript documentations with this ruby-gem. It's pretty easy to customize and add your own tokens/DSL."
|
11
|
+
s.homepage = "https://github.com/b-studios/docjs"
|
12
|
+
s.authors = ["Jonathan Brachthäuser"]
|
13
|
+
s.email = "jonathan@b-studios.de"
|
14
|
+
s.rubyforge_project = s.name
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n").find_all do |file|
|
17
|
+
file !~ /^yard$/ &&
|
18
|
+
file !~ /^run_tests$/ &&
|
19
|
+
file !~/^build/ &&
|
20
|
+
file !~/gitignore/
|
21
|
+
end
|
22
|
+
|
23
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
24
|
+
|
25
|
+
s.executables = ['docjs']
|
26
|
+
s.default_executable = 'bin/docjs'
|
27
|
+
|
28
|
+
s.add_dependency 'rdiscount'
|
29
|
+
s.add_dependency 'thor'
|
30
|
+
|
31
|
+
s.require_path = 'lib'
|
32
|
+
end
|
data/lib/boot.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'json'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
require_relative 'thor'
|
6
|
+
require_relative 'logger'
|
7
|
+
require_relative 'configs'
|
8
|
+
require_relative 'parser/parser'
|
9
|
+
require_relative 'code_object/function'
|
10
|
+
require_relative 'dom/dom'
|
11
|
+
require_relative 'processor'
|
12
|
+
|
13
|
+
def setup_application(options)
|
14
|
+
|
15
|
+
# initialize Logger
|
16
|
+
Logger.setup :logfile => File.expand_path(options[:logfile], Dir.pwd),
|
17
|
+
:level => (options[:loglevel]).to_sym
|
18
|
+
|
19
|
+
Logger.info "Setting up Application"
|
20
|
+
|
21
|
+
# Process option-values and store them in our Configs-object
|
22
|
+
Configs.set :options => options, # Just store the options for now
|
23
|
+
:wdir => Dir.pwd, # The current working directory
|
24
|
+
:output => File.absolute_path(options[:output]),
|
25
|
+
:templates => File.absolute_path(options[:templates]),
|
26
|
+
:includes => (options[:includes] && File.absolute_path(options[:includes])),
|
27
|
+
:files => (options[:files] && options[:files].map {|path| Dir.glob(path) }.flatten),
|
28
|
+
:docs => (options[:docs] && options[:docs].map {|path| Dir.glob(path) }.flatten)
|
29
|
+
|
30
|
+
Logger.debug "Given options: #{options}"
|
31
|
+
Logger.debug "App Root: #{Configs.root}"
|
32
|
+
Logger.debug "Working Dir: #{Configs.wdir}"
|
33
|
+
Logger.debug "Output Dir: #{Configs.output}"
|
34
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# ../data.img#1787927:1
|
2
|
+
require_relative '../token/container'
|
3
|
+
require_relative '../dom/dom'
|
4
|
+
require_relative '../parser/meta_container'
|
5
|
+
|
6
|
+
#
|
7
|
+
# 
|
8
|
+
#
|
9
|
+
#
|
10
|
+
module CodeObject
|
11
|
+
|
12
|
+
class Base
|
13
|
+
|
14
|
+
include Token::Container
|
15
|
+
include Dom::Node
|
16
|
+
include Parser::MetaContainer
|
17
|
+
|
18
|
+
attr_reader :docs, :name, :path
|
19
|
+
|
20
|
+
# The name instance variable is required by Dom::Node
|
21
|
+
def initialize(path = "NO_PATH_SPECIFIED")
|
22
|
+
path = path.to_s.split(/\s/).first # remove trailing spaces
|
23
|
+
@path, @name = path, extract_name_from(path)
|
24
|
+
super()
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
token_names = @tokens.keys if @tokens
|
29
|
+
"#<#{self.class}:#{self.name} @parent=#{parent.name if parent} @children=#{@children.keys} @tokens=#{token_names}>"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Automatically converts markdown-documentation to html
|
33
|
+
def docs=(docstring)
|
34
|
+
@docs = docstring.strip
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
# This is a Helpermethod, which can be used in subclasses like CodeObject::Function
|
40
|
+
def self.token_reader(name, token = name)
|
41
|
+
define_method name do
|
42
|
+
self.token(token)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|