docjs 0.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +77 -14
- data/bin/docjs +54 -30
- data/docjs.gemspec +2 -2
- data/lib/boot.rb +2 -2
- data/lib/logger.rb +2 -2
- data/templates/tasks/json_data_task.rb +1 -1
- data/test/code_object/prototype.rb +1 -0
- data/test/rspec_helper.rb +4 -1
- data/test/token/tokens.rb +2 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,19 +1,82 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
After total dataloss i have to rewrite the Readme's and Test's, so
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
Doc.js
|
2
|
+
======
|
3
|
+
Just a note: After total dataloss i have to rewrite the Readme's and Test's, so
|
4
|
+
please be patient.
|
5
|
+
|
6
|
+
|
7
|
+
Supported Ruby-Version
|
8
|
+
======================
|
9
|
+
Currently **only > 1.9** is supported. I am working on 1.8.x, though this is not
|
10
|
+
my target platform.
|
11
|
+
|
12
|
+
|
13
|
+
Installation
|
14
|
+
============
|
15
|
+
gem install docjs
|
16
|
+
|
15
17
|
|
16
18
|
Required Gems
|
17
19
|
=============
|
20
|
+
The following Gems are required to make docjs work and should automatically be
|
21
|
+
installed while installing docjs:
|
22
|
+
|
18
23
|
- thor
|
19
24
|
- rdiscount
|
25
|
+
|
26
|
+
|
27
|
+
Basic Usage
|
28
|
+
===========
|
29
|
+
|
30
|
+
Configuration
|
31
|
+
-------------
|
32
|
+
Before you can use Doc.js you may create your own **Configuration-File**. This
|
33
|
+
can easily be done, using the built-in
|
34
|
+
configuration-generator:
|
35
|
+
|
36
|
+
docjs configure
|
37
|
+
|
38
|
+
You optionally can specify the filename of your configuration file. If no file
|
39
|
+
is specified the configs will be written to `build.yml`.
|
40
|
+
|
41
|
+
docjs configure my_config_file.yml
|
42
|
+
|
43
|
+
The configuration is an interactive one - simply answer the questions you will
|
44
|
+
be asked.
|
45
|
+
|
46
|
+
|
47
|
+
Start documenting your code
|
48
|
+
---------------------------
|
49
|
+
To make jsdoc recognize your documentation you have to use some special tokens.
|
50
|
+
Let's write a documented function `hello_doc`:
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @function hello_doc
|
54
|
+
*
|
55
|
+
* Innovative function to greet a Person.
|
56
|
+
*
|
57
|
+
* @param [String] name the person you want to greet
|
58
|
+
* @return void
|
59
|
+
*/
|
60
|
+
function hello_doc(name) {
|
61
|
+
console.log("Hello " + name + "!");
|
62
|
+
}
|
63
|
+
|
64
|
+
The symbols `@function`, `@param` and `@return` are called **tokens** in Doc.js.
|
65
|
+
There are many more by default. To see which one you can use simply type:
|
66
|
+
|
67
|
+
docjs tokens
|
68
|
+
|
69
|
+
|
70
|
+
Run the documentation and enjoy!
|
71
|
+
--------------------------------
|
72
|
+
Now it's time to kickoff the documentation-process by typing:
|
73
|
+
|
74
|
+
docjs your_config.yml
|
75
|
+
|
76
|
+
You will find the docs in the output-directory you have specified in your
|
77
|
+
config-file.
|
78
|
+
|
79
|
+
|
80
|
+
License
|
81
|
+
=======
|
82
|
+
docjs is released under MIT-License. See LICENSE.md for more information.
|
data/bin/docjs
CHANGED
@@ -26,11 +26,11 @@ Configs.set :root => Pathname.new(__FILE__).realpath + '../..'
|
|
26
26
|
# @note options declared in a build.yml will override command-line ones
|
27
27
|
# @todo command line option to copy all templates to specified directory like
|
28
28
|
# jsdoc dump_templates ../templates/original
|
29
|
-
class
|
29
|
+
class DocJs < Thor
|
30
30
|
|
31
31
|
include Thor::Actions
|
32
32
|
|
33
|
-
desc "
|
33
|
+
desc "CONFIG_FILE", "Starts documentation process"
|
34
34
|
set_options :files =>
|
35
35
|
{ :type => :array, :aliases => '-f', :default => [], :required => true },
|
36
36
|
|
@@ -47,12 +47,12 @@ class JsDoc < Thor
|
|
47
47
|
{ :type => :string, :aliases => '-n', :default => "MyAppName" },
|
48
48
|
|
49
49
|
:logfile =>
|
50
|
-
{ :type => :string, :aliases => '-lf', :default => '
|
50
|
+
{ :type => :string, :aliases => '-lf', :default => 'docjs.log' },
|
51
51
|
|
52
52
|
:loglevel =>
|
53
53
|
{ :type => :string, :aliases => '-ll', :default => 'info' }
|
54
54
|
|
55
|
-
def
|
55
|
+
def docjs(config_file = nil)
|
56
56
|
# @see Thor#merge_options
|
57
57
|
configs = config_file ? merge_options(options, config_file) : options
|
58
58
|
|
@@ -63,7 +63,7 @@ class JsDoc < Thor
|
|
63
63
|
require Configs.templates + '/application.rb'
|
64
64
|
|
65
65
|
# Config Thor settings
|
66
|
-
|
66
|
+
DocJs.source_root(Configs.templates)
|
67
67
|
self.destination_root = Configs.output
|
68
68
|
|
69
69
|
Processor.prepare_documents
|
@@ -119,20 +119,20 @@ class JsDoc < Thor
|
|
119
119
|
})
|
120
120
|
|
121
121
|
# Setup Thor paths
|
122
|
-
|
122
|
+
DocJs.source_root(Configs.root)
|
123
123
|
self.destination_root = Configs.output
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
answers = {}
|
124
|
+
|
128
125
|
yes_no = "(y|n)"
|
129
126
|
|
130
|
-
Logger.info "We need some information from you, to customize the scaffolding process to your needs."
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
127
|
+
Logger.info "We need some information from you, to customize the scaffolding process to your needs."
|
128
|
+
if yes? "Do you wan't to generate a build.yml? #{yes_no}"
|
129
|
+
configure(Configs.wdir + '/build.yml', {
|
130
|
+
'templates' => output_dir,
|
131
|
+
'output' => 'docs',
|
132
|
+
'logfile' => 'logfile.log',
|
133
|
+
'loglevel' => 'info'
|
134
|
+
})
|
135
|
+
end
|
136
136
|
|
137
137
|
# Work with the answers
|
138
138
|
Logger.info "Copying the template files to #{Configs.templates}"
|
@@ -141,20 +141,16 @@ class JsDoc < Thor
|
|
141
141
|
Logger.info "Copying the included *.rb files to #{Configs.includes}"
|
142
142
|
end
|
143
143
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
def write_build_file
|
148
|
-
|
144
|
+
desc "configure [NEW_CONFIGFILE]", "Helps you creating your build.yml to start off with doc.js"
|
145
|
+
def configure(output_file = "build.yml", preconfigured = {})
|
146
|
+
|
149
147
|
build = {
|
150
148
|
'files' => [],
|
151
|
-
'docs' => []
|
152
|
-
'output' => 'docs',
|
153
|
-
'logfile' => 'logfile.log',
|
154
|
-
'loglevel' => 'info',
|
155
|
-
'templates' => Configs.scaffolding_path
|
149
|
+
'docs' => []
|
156
150
|
}
|
157
151
|
|
152
|
+
build.merge! preconfigured
|
153
|
+
|
158
154
|
say "\nPlease enter the name of your App", :bold
|
159
155
|
build['appname'] = ask ">"
|
160
156
|
|
@@ -176,15 +172,43 @@ class JsDoc < Thor
|
|
176
172
|
build['docs'] << answer
|
177
173
|
end
|
178
174
|
|
175
|
+
if not build['templates'] and yes? "Are you using your own templates?"
|
176
|
+
say "\nPlease enter the path to your templates", :bold
|
177
|
+
build['templates'] = ask ">"
|
178
|
+
end
|
179
|
+
|
180
|
+
if not build['loglevel']
|
181
|
+
say "\nPlease specify the loglevel of your output: (error|warn|info|debug)", :bold
|
182
|
+
|
183
|
+
while true do
|
184
|
+
answer = ask ">"
|
185
|
+
if %w(error warn info debug).include? answer
|
186
|
+
build['loglevel'] = answer
|
187
|
+
break
|
188
|
+
end
|
189
|
+
say "\nThe answer you've given is not one of (error|warn|info|debug). Please try again", :bold
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if not build['logfile'] and yes? "Do you wan't to save your logs to a file?"
|
194
|
+
say "\nPlease enter the path to your logfile", :bold
|
195
|
+
build['logfile'] = ask ">"
|
196
|
+
end
|
197
|
+
|
179
198
|
# answers[:scss_build] = yes? "Do you wan't to integrate SCSS into your build-process? #{yes_no}"
|
180
199
|
|
181
200
|
# maybe ask some more information to generate build.yml
|
182
|
-
create_file
|
201
|
+
create_file output_file, build.to_yaml
|
183
202
|
end
|
184
203
|
|
204
|
+
|
185
205
|
end
|
186
206
|
|
187
|
-
|
188
|
-
ARGV.unshift '
|
207
|
+
if ARGV.size == 0
|
208
|
+
ARGV.unshift 'help'
|
209
|
+
|
210
|
+
elsif not (ARGV.size > 0 and DocJs.method_defined?(ARGV.first))
|
211
|
+
ARGV.unshift 'docjs'
|
189
212
|
end
|
190
|
-
|
213
|
+
|
214
|
+
DocJs.start(ARGV)
|
data/docjs.gemspec
CHANGED
@@ -4,11 +4,11 @@ Gem::Specification.new do |s|
|
|
4
4
|
|
5
5
|
|
6
6
|
s.name = 'docjs'
|
7
|
-
s.version = '0.1'
|
7
|
+
s.version = '0.1.2'
|
8
8
|
s.date = '2011-06-07'
|
9
9
|
s.summary = "Javascript Documentation Generator"
|
10
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/
|
11
|
+
s.homepage = "https://github.com/b-studios/doc.js"
|
12
12
|
s.authors = ["Jonathan Brachthäuser"]
|
13
13
|
s.email = "jonathan@b-studios.de"
|
14
14
|
s.rubyforge_project = s.name
|
data/lib/boot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'json'
|
3
2
|
require 'yaml'
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
require_relative 'thor'
|
6
6
|
require_relative 'logger'
|
@@ -10,7 +10,7 @@ require_relative 'code_object/function'
|
|
10
10
|
require_relative 'dom/dom'
|
11
11
|
require_relative 'processor'
|
12
12
|
|
13
|
-
def setup_application(options)
|
13
|
+
def setup_application(options = {})
|
14
14
|
|
15
15
|
# initialize Logger
|
16
16
|
Logger.setup :logfile => File.expand_path(options[:logfile], Dir.pwd),
|
data/lib/logger.rb
CHANGED
@@ -16,7 +16,7 @@ module Logger
|
|
16
16
|
def self.setup(args = {})
|
17
17
|
|
18
18
|
@@shell = Thor::Base.shell.new
|
19
|
-
@@logfile = args[:
|
19
|
+
@@logfile = args[:logfile]
|
20
20
|
@@level = LEVEL[args[:level] || :info]
|
21
21
|
|
22
22
|
# write start sequence
|
@@ -37,7 +37,7 @@ module Logger
|
|
37
37
|
|
38
38
|
msg = msg.join "\n"
|
39
39
|
|
40
|
-
unless @@logfile.nil?
|
40
|
+
unless @@logfile.nil? or @@logfile == ""
|
41
41
|
File.open(@@logfile, "a") do |f|
|
42
42
|
f.write "#{level.prefix} #{msg}\n"
|
43
43
|
end
|
data/test/rspec_helper.rb
CHANGED
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:
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Jonathan Brachth\xC3\xA4user"
|
@@ -153,7 +153,7 @@ files:
|
|
153
153
|
- test/token/handler.rb
|
154
154
|
- test/token/tokens.rb
|
155
155
|
has_rdoc: true
|
156
|
-
homepage: https://github.com/b-studios/
|
156
|
+
homepage: https://github.com/b-studios/doc.js
|
157
157
|
licenses: []
|
158
158
|
|
159
159
|
post_install_message:
|