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
@@ -0,0 +1,26 @@
|
|
1
|
+
module Tasks
|
2
|
+
|
3
|
+
class ApiIndexTask < RenderTask
|
4
|
+
|
5
|
+
describe 'renders the api_index.html file containing all documented elements as alphabetic listing'
|
6
|
+
layout 'application'
|
7
|
+
|
8
|
+
start_method :render_api_index
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def render_api_index
|
13
|
+
|
14
|
+
in_context Dom.root do
|
15
|
+
@elements = []
|
16
|
+
Dom.root.each_child do |child|
|
17
|
+
@elements << child unless child.is_a? Dom::NoDoc
|
18
|
+
end
|
19
|
+
|
20
|
+
render 'api_index', :to_file => 'api_index.html'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Processor.register_render_task :api_index, Tasks::ApiIndexTask
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Tasks
|
2
|
+
|
3
|
+
class DocsTask < RenderTask
|
4
|
+
|
5
|
+
describe 'renders all specified Markdown files to static documentation'
|
6
|
+
layout 'application'
|
7
|
+
|
8
|
+
start_method :render_docs
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def render_docs
|
13
|
+
Dom.docs.each_child do |doc|
|
14
|
+
next if doc.is_a? Dom::NoDoc
|
15
|
+
|
16
|
+
render_document doc
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_document(document)
|
21
|
+
|
22
|
+
Logger.info "Rendering Document '#{document.name}'"
|
23
|
+
|
24
|
+
in_context document do
|
25
|
+
@document = document
|
26
|
+
render 'doc_page', :to_file => path_to(document, :format => :html)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Processor.register_render_task :docs, Tasks::DocsTask
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Tasks
|
2
|
+
|
3
|
+
class JsonDataTask < RenderTask
|
4
|
+
|
5
|
+
describe 'renders all documented objects to a json file. Objects and Functions are handled seperatly'
|
6
|
+
layout nil
|
7
|
+
|
8
|
+
start_method :render_json
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def render_json
|
13
|
+
|
14
|
+
in_context Dom.root do
|
15
|
+
|
16
|
+
functions = []
|
17
|
+
objects = []
|
18
|
+
|
19
|
+
Dom.root.each_child do |child|
|
20
|
+
|
21
|
+
code_object = {
|
22
|
+
:namespace => child.namespace,
|
23
|
+
:fullname => child.qualified_name,
|
24
|
+
:path => path_to(child , :format => :html)
|
25
|
+
}
|
26
|
+
|
27
|
+
# it's a root level element
|
28
|
+
if child.namespace.nil? or child.namespace == ""
|
29
|
+
code_object[:name] = child.name
|
30
|
+
else
|
31
|
+
code_object[:name] = '.'+child.name
|
32
|
+
end
|
33
|
+
|
34
|
+
if child.is_a? CodeObject::Function
|
35
|
+
functions << code_object.merge({
|
36
|
+
:constructor => child.constructor?
|
37
|
+
})
|
38
|
+
elsif child.is_a? CodeObject::Base
|
39
|
+
objects << code_object
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
@varname = 'apisearch'
|
44
|
+
@data = {
|
45
|
+
:functions => functions.sort {|a,b| a[:name] <=> b[:name] },
|
46
|
+
:objects => objects.sort {|a,b| a[:name] <=> b[:name] }
|
47
|
+
}
|
48
|
+
|
49
|
+
render 'layout/json', :to_file => 'js/apisearch-data.js'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Processor.register_render_task :json_data, Tasks::JsonDataTask
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Tasks
|
2
|
+
|
3
|
+
class TypedTask < RenderTask
|
4
|
+
|
5
|
+
|
6
|
+
# @todo those methods and therefore all class-variables @@configs are shared with all inheriting
|
7
|
+
# classes. i.e. The last change will be applied to all
|
8
|
+
describe 'renders documented objects type-dependant (Functions and Objects)'
|
9
|
+
layout 'application'
|
10
|
+
|
11
|
+
start_method :render_objects
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def render_objects
|
16
|
+
Dom.root.each_child do |node|
|
17
|
+
next if node.is_a? Dom::NoDoc
|
18
|
+
|
19
|
+
if node.is_a? CodeObject::Function
|
20
|
+
render_function node
|
21
|
+
else
|
22
|
+
render_object node
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @todo switch on registered Types to enable dynamic view-changing
|
28
|
+
def render_object(code_object)
|
29
|
+
|
30
|
+
Logger.info "Rendering CodeObject '#{code_object.name}'"
|
31
|
+
|
32
|
+
in_context code_object do
|
33
|
+
@object = code_object
|
34
|
+
@methods = @object.children.values.select {|c| c.is_a? CodeObject::Function }
|
35
|
+
@children = @object.children.values - @methods
|
36
|
+
# Render has to be documented very well, because it will be used in RenderTasks
|
37
|
+
render 'object/index', :to_file => path_to(code_object, :format => :html)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def render_function(code_object)
|
42
|
+
Logger.info "Rendering Function '#{code_object.name}'"
|
43
|
+
|
44
|
+
in_context code_object do
|
45
|
+
@function = code_object
|
46
|
+
@prototype = code_object.prototype
|
47
|
+
@methods = @function.children.values.select {|c| c.is_a? CodeObject::Function }
|
48
|
+
render 'function/index', :to_file => path_to(code_object, :format => :html)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Processor.register_render_task :typed, Tasks::TypedTask
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Token::Handler
|
2
|
+
|
3
|
+
register :author, :area => :sidebar
|
4
|
+
register :public, :area => :sidebar
|
5
|
+
register :private, :area => :sidebar
|
6
|
+
register :version, :area => :sidebar
|
7
|
+
|
8
|
+
register :see, :area => :footer
|
9
|
+
|
10
|
+
register :deprecated, :area => :notification
|
11
|
+
register :todo, :area => :notification
|
12
|
+
register :note, :area => :notification
|
13
|
+
register :warn, :area => :notification
|
14
|
+
|
15
|
+
register :example, :template => 'examples', :handler => :named_multiline
|
16
|
+
|
17
|
+
register :overload, :area => :none do |token, content|
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CodeObject
|
2
|
+
|
3
|
+
class Prototype < CodeObject::Object
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
super(*args)
|
7
|
+
@path += '.prototype'
|
8
|
+
end
|
9
|
+
|
10
|
+
# get the constructor, for which this prototype is used
|
11
|
+
def constructor
|
12
|
+
self.parent
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
CodeObject::Type.register :prototype, CodeObject::Prototype
|
20
|
+
Token::Handler.register :prototype, :handler => :noop, :area => :none
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<article class="api-index">
|
2
|
+
<header>
|
3
|
+
<h1>Alphabetic API-Overview</h1>
|
4
|
+
</header>
|
5
|
+
|
6
|
+
<section class="api-list">
|
7
|
+
<% @elements.sort {|a,b| a.name.downcase <=> b.name.downcase }
|
8
|
+
.group_by {|n| n.name.upcase.chr }
|
9
|
+
.each do |letter, elements| %>
|
10
|
+
<%= tag :h2, letter %>
|
11
|
+
<ul>
|
12
|
+
<% elements.each do |element| %>
|
13
|
+
<li><%= link_to element, element.name %>
|
14
|
+
<% if element.namespace != "" %>
|
15
|
+
<span class="namespace">(<%= element.namespace %>)</span>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
<% end %>
|
20
|
+
</section>
|
21
|
+
</article>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<section class="section method" id="method-<%= detail.name %>">
|
2
|
+
<h2 class="signature"><%= signature detail %></h2>
|
3
|
+
<%= to_html detail.docs %>
|
4
|
+
<%= render_tokens :of => detail, :in => :body %>
|
5
|
+
|
6
|
+
<h3 class="source">Source</h3>
|
7
|
+
<%= code detail.source %>
|
8
|
+
</section>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<article class="function">
|
2
|
+
|
3
|
+
<header>
|
4
|
+
<nav class="sidebar">
|
5
|
+
<p><%= @function.filepath %>:<%= @function.line_start %></p>
|
6
|
+
|
7
|
+
<div class="hierarchy">
|
8
|
+
<h3>Hierarchy</h3>
|
9
|
+
<%= hierarchy @function %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<% unless @prototype.nil? %>
|
13
|
+
<div>
|
14
|
+
<h3>Prototype</h3>
|
15
|
+
<%= link_to @prototype %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% unless @methods.empty? %>
|
20
|
+
<div class="method-list">
|
21
|
+
<h3>Methods</h3>
|
22
|
+
<ul>
|
23
|
+
<% @methods.each do |child| %>
|
24
|
+
<li><%= link_to child %></li>
|
25
|
+
<% end %>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<%= render_tokens :of => @function, :in => :sidebar %>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
<h1><%= @function.qualified_name %></h1>
|
34
|
+
<section class="notification">
|
35
|
+
<%= render_tokens :of => @function, :in => :notification %>
|
36
|
+
</section>
|
37
|
+
</header>
|
38
|
+
|
39
|
+
<div class="body">
|
40
|
+
|
41
|
+
<%= to_html @function.docs %>
|
42
|
+
|
43
|
+
<!--span class="flag">constructor</span-->
|
44
|
+
|
45
|
+
<h2 class="signature"><%= signature @function %></h2>
|
46
|
+
<%= render_tokens :of => @function, :in => :body %>
|
47
|
+
|
48
|
+
<h3 class="source">Source</h3>
|
49
|
+
<%= code @function.source %>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</article>
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Documentation</title>
|
6
|
+
<!--[if lt IE 9]>
|
7
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
8
|
+
<![endif]-->
|
9
|
+
<link href='http://fonts.googleapis.com/css?family=Terminal+Dosis+Light' rel='stylesheet' type='text/css'>
|
10
|
+
<%= style "application" %>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<header id="header" class="s">
|
14
|
+
<div class="wrapper">
|
15
|
+
<nav>
|
16
|
+
<h1><%= Configs.options[:appname] %></h1>
|
17
|
+
|
18
|
+
<ul id="page-menu">
|
19
|
+
<li><%= link_to 'doc:README', 'Documentation' %>
|
20
|
+
<li><%= relative_link 'api_index.html', 'Api-Docs' %>
|
21
|
+
</ul>
|
22
|
+
|
23
|
+
<form>
|
24
|
+
<input type="search" id="search" placeholder="search API-docs" autocomplete="off" autofocus/>
|
25
|
+
</form>
|
26
|
+
</nav>
|
27
|
+
|
28
|
+
<section class="browsers col50">
|
29
|
+
<section class="docs">
|
30
|
+
<h1>Documents</h1>
|
31
|
+
<ul>
|
32
|
+
<% Dom.docs.each_child do |doc| %>
|
33
|
+
<li><%= link_to doc %></li>
|
34
|
+
<% end %>
|
35
|
+
</ul>
|
36
|
+
</section>
|
37
|
+
<section class="api-browser">
|
38
|
+
<h1>API-Browser</h1>
|
39
|
+
<%= api_browser(Dom.root) %>
|
40
|
+
</section>
|
41
|
+
</section>
|
42
|
+
|
43
|
+
<section class="search-results col50">
|
44
|
+
<section class="functions">
|
45
|
+
<h1 class="icon function">Functions</h1>
|
46
|
+
</section>
|
47
|
+
<section class="objects">
|
48
|
+
<h1 class="icon object">Objects</h1>
|
49
|
+
</section>
|
50
|
+
</section>
|
51
|
+
|
52
|
+
<a href="#" class="collapse">Collapse</a>
|
53
|
+
<a href="#" class="expand" style="display: none;">Expand</a>
|
54
|
+
</div>
|
55
|
+
</header>
|
56
|
+
<div role="main" id="main">
|
57
|
+
<%= yield %>
|
58
|
+
</div>
|
59
|
+
<footer id="footer">
|
60
|
+
<div class="wrapper">
|
61
|
+
Documentation created automagically with <a href="http://www.github.com/b-studios/jsdoc">JSDoc for Ruby</a>.
|
62
|
+
</div>
|
63
|
+
</footer>
|
64
|
+
<%= script "jcore" %>
|
65
|
+
<script>
|
66
|
+
var JSDOC = JSDOC || {};
|
67
|
+
JSDOC.root = "<%= to_relative(Configs.output) + '/' %>";
|
68
|
+
window.jQuery || document.write("<script src='"+JSDOC.root+"js/jquery.js'>\x3C/script>")
|
69
|
+
</script>
|
70
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script>
|
71
|
+
<%= script "jquery.treeview", "jquery.cookie", "jquery.tooltip", "application", "apisearch-data" %>
|
72
|
+
<body>
|
73
|
+
</html>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<article>
|
2
|
+
|
3
|
+
<header>
|
4
|
+
<nav class="sidebar">
|
5
|
+
<p><%= @object.filepath %>:<%= @object.line_start %></p>
|
6
|
+
|
7
|
+
<div class="hierarchy">
|
8
|
+
<h3>Hierarchy</h3>
|
9
|
+
<%= hierarchy @object %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<% unless @methods.empty? %>
|
13
|
+
<div class="method-list">
|
14
|
+
<h3>Methods</h3>
|
15
|
+
<ul>
|
16
|
+
<% @methods.each do |child| %>
|
17
|
+
<li><%= link_to child %></li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<%= render_tokens :of => @object, :in => :sidebar %>
|
24
|
+
</nav>
|
25
|
+
|
26
|
+
<h1><%= @object.qualified_name %></h1>
|
27
|
+
<section class="notification">
|
28
|
+
<%= render_tokens :of => @object, :in => :notification %>
|
29
|
+
</section>
|
30
|
+
</header>
|
31
|
+
|
32
|
+
<div class="body">
|
33
|
+
|
34
|
+
<%= to_html @object.docs %>
|
35
|
+
|
36
|
+
<!-- SUMMARY -->
|
37
|
+
<% unless @methods.nil? or @methods.size == 0 %>
|
38
|
+
<section>
|
39
|
+
<h3 class="icon function">Methods</h3>
|
40
|
+
<ul class="summary collapsed">
|
41
|
+
<% @methods.each do |child| %>
|
42
|
+
<li><%= link_to child %></li>
|
43
|
+
<% end %>
|
44
|
+
</ul>
|
45
|
+
</section>
|
46
|
+
<% end %>
|
47
|
+
|
48
|
+
<% unless @children.nil? or @children.size == 0 %>
|
49
|
+
<section>
|
50
|
+
<h3 class="icon object">Children</h3>
|
51
|
+
<ul class="summary collapsed">
|
52
|
+
<% @children.each do |child| %>
|
53
|
+
<li><%= link_to child, ".#{child.name}" %></li>
|
54
|
+
<% end %>
|
55
|
+
</ul>
|
56
|
+
</section>
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<%= render_tokens :of => @object, :in => :body %>
|
60
|
+
|
61
|
+
</div>
|
62
|
+
|
63
|
+
</article>
|