hobo 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/hobo +0 -6
- data/hobo_files/plugin/CHANGES.txt +103 -0
- data/hobo_files/plugin/Rakefile +2 -0
- data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +1 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/IE7.js +2 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +28 -12
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/{application.css → clean.css} +10 -9
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +1 -1
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/views/{application.dryml → clean.dryml} +0 -0
- data/hobo_files/plugin/init.rb +7 -3
- data/hobo_files/plugin/lib/hobo.rb +3 -1
- data/hobo_files/plugin/lib/hobo/bundle.rb +24 -14
- data/hobo_files/plugin/lib/hobo/dryml.rb +5 -1
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +1 -1
- data/hobo_files/plugin/lib/hobo/dryml/parser/base_parser.rb +11 -10
- data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +37 -10
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +5 -22
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +1 -1
- data/hobo_files/plugin/lib/hobo/dryml/template_handler.rb +10 -2
- data/hobo_files/plugin/lib/hobo/hobo_helper.rb +7 -0
- data/hobo_files/plugin/lib/hobo/model.rb +18 -13
- data/hobo_files/plugin/lib/hobo/model_controller.rb +45 -54
- data/hobo_files/plugin/lib/hobo/model_router.rb +8 -1
- data/hobo_files/plugin/lib/hobo/scopes.rb +3 -4
- data/hobo_files/plugin/lib/hobo/scopes/automatic_scopes.rb +3 -0
- data/hobo_files/plugin/taglib-docs/core.markdown +165 -0
- data/hobo_files/plugin/taglib-docs/rapid.markdown +677 -0
- data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +240 -0
- data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +418 -0
- data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +562 -0
- data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +187 -0
- data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +214 -0
- data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +530 -0
- data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +65 -0
- data/hobo_files/plugin/taglib-docs/rapid_support.markdown +50 -0
- data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +129 -0
- data/hobo_files/plugin/taglibs/rapid.dryml +2 -2
- data/hobo_files/plugin/taglibs/rapid_forms.dryml +7 -22
- data/hobo_files/plugin/taglibs/rapid_generics.dryml +14 -12
- data/hobo_files/plugin/taglibs/rapid_navigation.dryml +5 -4
- data/hobo_files/plugin/taglibs/rapid_pages.dryml +5 -1
- data/hobo_files/plugin/tasks/fix_dryml.rake +1 -1
- data/hobo_files/plugin/tasks/generate_tag_reference.rb +162 -0
- data/hobo_files/plugin/tasks/hobo_tasks.rake +17 -0
- metadata +46 -5
@@ -0,0 +1,65 @@
|
|
1
|
+
# Rapid Plus
|
2
|
+
|
3
|
+
* [<table-plus>](#table-plus)
|
4
|
+
* [<change-password-form>](#change-password-form)
|
5
|
+
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
<a name="table-plus"> </a>
|
10
|
+
## <table-plus>
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
### Attributes (merged with [<div>](#div))
|
15
|
+
|
16
|
+
* sort-field
|
17
|
+
* sort-direction
|
18
|
+
* sort-columns
|
19
|
+
|
20
|
+
|
21
|
+
### Parameters (merged with [<table>](#table))
|
22
|
+
|
23
|
+
<ul><li><header:> (<div>)
|
24
|
+
<ul><li><search-form:> (<form>)
|
25
|
+
<ul><li><search-submit:> (<submit>)
|
26
|
+
</li>
|
27
|
+
</ul></li>
|
28
|
+
</ul></li>
|
29
|
+
<li>(dynamic parameter) (<th>)
|
30
|
+
<ul><li>(dynamic parameter) (<a>)
|
31
|
+
</li>
|
32
|
+
<li><up-arrow:> (<do>)
|
33
|
+
</li>
|
34
|
+
<li><down-arrow:> (<do>)
|
35
|
+
</li>
|
36
|
+
</ul></li>
|
37
|
+
<li><empty-message:> (<do>)
|
38
|
+
</li>
|
39
|
+
<li><page-nav:>
|
40
|
+
</li>
|
41
|
+
</ul>
|
42
|
+
|
43
|
+
|
44
|
+
---
|
45
|
+
|
46
|
+
<a name="change-password-form"> </a>
|
47
|
+
## <change-password-form>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
### Attributes
|
52
|
+
|
53
|
+
None
|
54
|
+
|
55
|
+
### Parameters
|
56
|
+
|
57
|
+
<ul><li><form:>
|
58
|
+
<ul><li><field-list:>
|
59
|
+
</li>
|
60
|
+
<li><actions:> (<div>)
|
61
|
+
<ul><li><submit:>
|
62
|
+
</li>
|
63
|
+
</ul></li>
|
64
|
+
</ul></li>
|
65
|
+
</ul>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Rapid Support
|
2
|
+
|
3
|
+
* [<with-fields>](#with-fields)
|
4
|
+
* [<with-field-names>](#with-field-names)
|
5
|
+
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
<a name="with-fields"> </a>
|
10
|
+
## <with-fields>
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
### Attributes
|
15
|
+
|
16
|
+
* fields
|
17
|
+
* associations
|
18
|
+
* skip
|
19
|
+
* skip-associations
|
20
|
+
* include-timestamps
|
21
|
+
* force-all
|
22
|
+
|
23
|
+
|
24
|
+
### Parameters
|
25
|
+
|
26
|
+
<ul><li><default:> (<do>)
|
27
|
+
</li>
|
28
|
+
<li><default:> (<do>)
|
29
|
+
</li>
|
30
|
+
</ul>
|
31
|
+
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
<a name="with-field-names"> </a>
|
36
|
+
## <with-field-names>
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
### Attributes
|
41
|
+
|
42
|
+
* fields
|
43
|
+
* skip
|
44
|
+
* skip-associations
|
45
|
+
* include-timestamps
|
46
|
+
|
47
|
+
|
48
|
+
### Parameters
|
49
|
+
|
50
|
+
None
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Rapid User Pages
|
2
|
+
|
3
|
+
* [<signup-page>](#signup-page)
|
4
|
+
* [<login-page>](#login-page)
|
5
|
+
* [<account-disabled-page>](#account-disabled-page)
|
6
|
+
* [<account-page>](#account-page)
|
7
|
+
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
<a name="signup-page"> </a>
|
12
|
+
## <signup-page>
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
### Attributes (merged with [<page>](#page))
|
17
|
+
|
18
|
+
None
|
19
|
+
|
20
|
+
### Parameters (merged with [<page>](#page))
|
21
|
+
|
22
|
+
<ul><li><body:>
|
23
|
+
</li>
|
24
|
+
<li><content-header:>
|
25
|
+
<ul><li><heading:>
|
26
|
+
</li>
|
27
|
+
</ul></li>
|
28
|
+
<li><content-body:>
|
29
|
+
<ul><li><form:>
|
30
|
+
<ul><li><field-list:>
|
31
|
+
</li>
|
32
|
+
<li><actions:> (<div>)
|
33
|
+
</li>
|
34
|
+
</ul></li>
|
35
|
+
</ul></li>
|
36
|
+
</ul>
|
37
|
+
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
<a name="login-page"> </a>
|
42
|
+
## <login-page>
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
### Attributes (merged with [<page>](#page))
|
47
|
+
|
48
|
+
* remember-me
|
49
|
+
|
50
|
+
|
51
|
+
### Parameters (merged with [<page>](#page))
|
52
|
+
|
53
|
+
<ul><li><body:>
|
54
|
+
</li>
|
55
|
+
<li><content-header:>
|
56
|
+
<ul><li><heading:>
|
57
|
+
</li>
|
58
|
+
</ul></li>
|
59
|
+
<li><content-body:>
|
60
|
+
<ul><li><form:>
|
61
|
+
<ul><li><labelled-item-list:>
|
62
|
+
<ul><li><login-label:> (<item-label>)
|
63
|
+
</li>
|
64
|
+
<li><login-input:> (<input>)
|
65
|
+
</li>
|
66
|
+
<li><password-label:> (<item-label>)
|
67
|
+
</li>
|
68
|
+
<li><password-input:> (<input>)
|
69
|
+
</li>
|
70
|
+
<li><remember-me-label:> (<item-label>)
|
71
|
+
</li>
|
72
|
+
<li><remember-me-input:> (<input>)
|
73
|
+
</li>
|
74
|
+
</ul></li>
|
75
|
+
<li><actions:> (<div>)
|
76
|
+
<ul><li><submit:>
|
77
|
+
</li>
|
78
|
+
</ul></li>
|
79
|
+
</ul></li>
|
80
|
+
</ul></li>
|
81
|
+
</ul>
|
82
|
+
|
83
|
+
|
84
|
+
---
|
85
|
+
|
86
|
+
<a name="account-disabled-page"> </a>
|
87
|
+
## <account-disabled-page>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
### Attributes (merged with [<page>](#page))
|
92
|
+
|
93
|
+
None
|
94
|
+
|
95
|
+
### Parameters (merged with [<page>](#page))
|
96
|
+
|
97
|
+
<ul><li><body:>
|
98
|
+
</li>
|
99
|
+
<li><content-header:>
|
100
|
+
<ul><li><heading:>
|
101
|
+
</li>
|
102
|
+
</ul></li>
|
103
|
+
<li><content-body:>
|
104
|
+
</li>
|
105
|
+
</ul>
|
106
|
+
|
107
|
+
|
108
|
+
---
|
109
|
+
|
110
|
+
<a name="account-page"> </a>
|
111
|
+
## <account-page>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
### Attributes (merged with [<page>](#page))
|
116
|
+
|
117
|
+
None
|
118
|
+
|
119
|
+
### Parameters (merged with [<page>](#page))
|
120
|
+
|
121
|
+
<ul><li><body:>
|
122
|
+
</li>
|
123
|
+
<li><content-header:>
|
124
|
+
</li>
|
125
|
+
<li><content-body:>
|
126
|
+
<ul><li><error-messages:>
|
127
|
+
</li>
|
128
|
+
</ul></li>
|
129
|
+
</ul>
|
@@ -296,7 +296,7 @@
|
|
296
296
|
|
297
297
|
<def tag="view" for="Numeric" attrs="format"><%= format ? format % this : this.to_s %></def>
|
298
298
|
|
299
|
-
<def tag="view" for="string"><%= h(this).gsub("\n", "<br/>") %></def>
|
299
|
+
<def tag="view" for="string"><%= this.try.to_html || h(this).gsub("\n", "<br/>") %></def>
|
300
300
|
|
301
301
|
<def tag="view" for="boolean"><%= this ? 'Yes' : 'No' %></def>
|
302
302
|
|
@@ -335,7 +335,7 @@
|
|
335
335
|
|
336
336
|
|
337
337
|
<def tag="theme-stylesheet" attrs="name">
|
338
|
-
<% name ||=
|
338
|
+
<% name ||= Hobo.current_theme -%>
|
339
339
|
<link href="#{base_url}/hobothemes/#{Hobo.current_theme}/stylesheets/#{name}.css"
|
340
340
|
media="screen" rel="Stylesheet" type="text/css" />
|
341
341
|
</def>
|
@@ -145,14 +145,6 @@
|
|
145
145
|
<%= text_area_tag(name, this, add_classes(attributes, :tiny_mce)) %>
|
146
146
|
</def>
|
147
147
|
|
148
|
-
<def tag="input" for="markdown" attrs="name">
|
149
|
-
<%= text_area_tag(name, this, attributes) %>
|
150
|
-
</def>
|
151
|
-
|
152
|
-
<def tag="input" for="textile" attrs="name">
|
153
|
-
<%= text_area_tag(name, this, attributes) %>
|
154
|
-
</def>
|
155
|
-
|
156
148
|
<def tag="input" for="date" attrs="order">
|
157
149
|
<% order = order.nil? ? [:year, :month, :day] : comma_split(order).*.to_sym -%>
|
158
150
|
<%= select_date(this || Time.now, attributes.merge(:prefix => param_name_for_this, :order => order)) %>
|
@@ -193,7 +185,7 @@
|
|
193
185
|
<def tag="remote-method-button" attrs="method, update, label"><%=
|
194
186
|
ajax_attributes, html_attributes = attributes.partition_hash(Hobo::RapidHelper::AJAX_ATTRS)
|
195
187
|
|
196
|
-
url = object_url(this, method)
|
188
|
+
url = object_url(this, method, :method => :post)
|
197
189
|
add_classes!(html_attributes, "button remote-method-button #{method}-button")
|
198
190
|
if update || result_update || !ajax_attrs.empty?
|
199
191
|
label ||= method.titleize
|
@@ -298,18 +290,11 @@
|
|
298
290
|
</def>
|
299
291
|
|
300
292
|
|
301
|
-
<def tag="
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
where_attributes = attributes.select_hash {|k,v| k.to_s.starts_with? "where_"}
|
307
|
-
url = object_url(completer_model, :completions, { :for => completer_attr }.update(where_attributes))
|
308
|
-
%>
|
309
|
-
|
310
|
-
<input type="text" id="#{id}" class="autocomplete-bhv" autocomplete-url="#{url}"
|
311
|
-
name="#{param_name_for_this}" merge-attrs/>
|
312
|
-
<div id="#{id}-completions" class="completions-popup" style="display:none"></div>
|
293
|
+
<def tag="name-one" attrs="complete-target, completer">
|
294
|
+
<input type="text" name="#{param_name_for_this}"
|
295
|
+
class="autocompleter #{type_and_field} complete-on:#{dom_id complete_target}:#{completer}"
|
296
|
+
merge-attrs/>
|
297
|
+
<div class="completions-popup" style="display:none"></div>
|
313
298
|
</def>
|
314
299
|
|
315
300
|
|
@@ -371,7 +356,7 @@
|
|
371
356
|
|
372
357
|
|
373
358
|
<def tag="after-submit" attrs="uri, stay-here, go-back">
|
374
|
-
<% uri =
|
359
|
+
<% uri = "stay-here" if stay_here %>
|
375
360
|
<% uri = session[:previous_uri] if go_back %>
|
376
361
|
<input type="hidden" value="¶ms[:after_submit] || uri" name="after_submit" if="&uri"/>
|
377
362
|
</def>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<def tag="creation-details">
|
2
2
|
<div class="creation-details">
|
3
|
-
<view
|
3
|
+
<if:get_creator><view class="creator" param="by"/></if:>
|
4
4
|
<view:created_at class="created-at" if="&this.respond_to?(:created_at)" param="at"/>
|
5
5
|
</div>
|
6
6
|
</def>
|
@@ -97,19 +97,21 @@
|
|
97
97
|
</def>
|
98
98
|
|
99
99
|
|
100
|
-
<def tag="collection-preview" attrs="limit">
|
100
|
+
<def tag="collection-preview" attrs="limit, if-any">
|
101
101
|
<% limit ||= 6 %>
|
102
102
|
<do with="&this.is_a?(Class) ? this.limit(limit).all : this.limit(limit)">
|
103
|
-
<
|
104
|
-
|
105
|
-
<
|
106
|
-
<
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<
|
111
|
-
|
112
|
-
|
103
|
+
<unless test="&if_any && this.empty?">
|
104
|
+
<set collection-name="&(this.try.origin_attribute || this.member_class.name.pluralize).to_s"/>
|
105
|
+
<div class="collection-preview" merge-attrs>
|
106
|
+
<h2>
|
107
|
+
<do param="heading"><collection-name.titleize/></do>
|
108
|
+
<span param="show-all-link" if="&linkable? && this.count > limit">(<a>show all</a>)</span>
|
109
|
+
</h2>
|
110
|
+
<collection merge-params>
|
111
|
+
<card: class="small"/>
|
112
|
+
</collection>
|
113
|
+
</div>
|
114
|
+
</unless>
|
113
115
|
</do>
|
114
116
|
</def>
|
115
117
|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
-->
|
4
4
|
|
5
5
|
<!--- General Navigation -->
|
6
|
-
|
6
|
+
|
7
|
+
<!-- General purpose navigation bar. Renders a `<ul class="navigation">` -->
|
7
8
|
<def tag="navigation" attrs="current">
|
8
9
|
<ul class="navigation" merge-attrs>
|
9
10
|
<set-scoped current-navigation="¤t">
|
@@ -29,7 +30,7 @@
|
|
29
30
|
<def tag="account-nav">
|
30
31
|
<ul with="¤t_user" class="account-nav" param>
|
31
32
|
<if test="&logged_in?">
|
32
|
-
<li class='nav-item' param="logged-in-as"><a to="¤t_user">Logged in as <
|
33
|
+
<li class='nav-item' param="logged-in-as"><a to="¤t_user">Logged in as <name/></a></li>
|
33
34
|
<li class='nav-item' param="account"><a action="account">Account</a></li>
|
34
35
|
<li class='nav-item' param="log-out"><a href="&logout_url">Log out</a></li>
|
35
36
|
</if>
|
@@ -86,8 +87,8 @@
|
|
86
87
|
</def>
|
87
88
|
|
88
89
|
|
89
|
-
<!-- magic nav, just to get you started
|
90
|
-
|
90
|
+
<!-- magic nav, just to get you started. Don't try to customise this
|
91
|
+
but rather write your own navigation using the `<navigation>` tag -->
|
91
92
|
<def tag="magic-nav">
|
92
93
|
<navigation merge-attrs>
|
93
94
|
<nav-item href="#{base_url}/">Home</nav-item>
|
@@ -12,6 +12,7 @@
|
|
12
12
|
|
13
13
|
<do param="scripts">
|
14
14
|
<javascript param name="prototype, effects, dragdrop, controls, lowpro, hobo-rapid, application"/>
|
15
|
+
<do param="fix-ie6"><%= "<!--[if lt IE 7]>" %><javascript name="IE7"/><%= "<![endif]-->" %></do>
|
15
16
|
<hobo-rapid-javascripts param/>
|
16
17
|
</do>
|
17
18
|
</head>
|
@@ -70,7 +71,10 @@
|
|
70
71
|
<body: class="index-page #{type_id model}" param/>
|
71
72
|
<content-header: param>
|
72
73
|
<heading param><type-name with="&model" plural/></heading>
|
73
|
-
<p class="note"
|
74
|
+
<p class="note" param="count">
|
75
|
+
<if>There <count prefix="are"/></if>
|
76
|
+
<else>There aren't any <type-name lowercase plural/> yet.</else>
|
77
|
+
</p>
|
74
78
|
</content-header:>
|
75
79
|
|
76
80
|
<content-body: param>
|
@@ -100,7 +100,7 @@ def fix_file(filename)
|
|
100
100
|
# happy
|
101
101
|
@src = "<root>" + src + "</root>"
|
102
102
|
begin
|
103
|
-
doc =
|
103
|
+
doc = Hobo::Dryml::Parser::Document.new(Hobo::Dryml::Parser::Source.new(@src))
|
104
104
|
rescue REXML::ParseException => e
|
105
105
|
raise Exception, "File: #{@template_path}\n#{e}"
|
106
106
|
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'hobosupport'
|
3
|
+
Dependencies.load_paths << File.dirname(__FILE__) + "/../lib"
|
4
|
+
|
5
|
+
require 'rexml/xpath'
|
6
|
+
XPath = REXML::XPath
|
7
|
+
|
8
|
+
require 'maruku'
|
9
|
+
|
10
|
+
|
11
|
+
def tag_title(tag, link=false)
|
12
|
+
if tag.is_a? String
|
13
|
+
name = tag
|
14
|
+
anchor = tag
|
15
|
+
else
|
16
|
+
for_attr = tag.attributes['for'] and for_decl = %( for=`"#{for_attr}"`)
|
17
|
+
name = tag.attributes['tag']
|
18
|
+
anchor = tag_anchor(tag)
|
19
|
+
end
|
20
|
+
|
21
|
+
title = "<#{name}#{for_decl}>"
|
22
|
+
|
23
|
+
if link
|
24
|
+
"[#{title}](##{anchor})"
|
25
|
+
else
|
26
|
+
title
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def link_to_tag(tag)
|
32
|
+
tag_title(tag, true)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def tag_anchor(element)
|
37
|
+
for_attr = element.attributes['for']
|
38
|
+
name = element.attributes['tag']
|
39
|
+
|
40
|
+
if for_attr
|
41
|
+
"#{name}--for-#{for_attr}"
|
42
|
+
else
|
43
|
+
name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def comment_for_tag(element)
|
49
|
+
space = element.previous_sibling and
|
50
|
+
space.to_s.blank? && space.to_s.count("\n") == 1 and
|
51
|
+
comment = space.previous_sibling
|
52
|
+
|
53
|
+
comment.to_s.strip if comment.is_a?(REXML::Comment)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def doc_for_tag(tagdef)
|
58
|
+
comment = comment_for_tag(tagdef)
|
59
|
+
|
60
|
+
params_merged_with = XPath.first(tagdef, ".//*[@merge|@merge-params]")._?.name
|
61
|
+
params_merged_with &&= "(merged with #{link_to_tag params_merged_with})"
|
62
|
+
|
63
|
+
attrs_merged_with = XPath.first(tagdef, ".//*[@merge|@merge-attrs]")._?.name
|
64
|
+
attrs_merged_with &&= "(merged with #{link_to_tag attrs_merged_with})"
|
65
|
+
|
66
|
+
attrs = tagdef.attributes['attrs'] || []
|
67
|
+
attrs = attrs.split(/,\s*/).where_not.blank?.map { |a| " * #{a}\n" }.join
|
68
|
+
|
69
|
+
parameters = params_to_list(get_parameters(tagdef))
|
70
|
+
<<-END
|
71
|
+
---
|
72
|
+
|
73
|
+
<a name="#{tag_anchor tagdef}"> </a>
|
74
|
+
## #{tag_title tagdef}
|
75
|
+
|
76
|
+
#{comment}
|
77
|
+
|
78
|
+
### Attributes #{attrs_merged_with}
|
79
|
+
|
80
|
+
#{attrs.blank? ? 'None' : attrs}
|
81
|
+
|
82
|
+
### Parameters #{params_merged_with}
|
83
|
+
|
84
|
+
#{parameters.blank? ? 'None' : parameters}
|
85
|
+
END
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def get_parameters(elem)
|
90
|
+
result = []
|
91
|
+
elem.elements.each do |e|
|
92
|
+
if e.attributes['param']
|
93
|
+
result << [e, get_parameters(e)]
|
94
|
+
else
|
95
|
+
result.concat(get_parameters(e))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
result
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
def params_to_list(params, indent=" ")
|
103
|
+
items = params.map do |elem, sub_params|
|
104
|
+
p_attr = elem.attributes['param']
|
105
|
+
entry = if p_attr == "&true"
|
106
|
+
"<#{elem.name}:>"
|
107
|
+
elsif p_attr =~ /#\{/
|
108
|
+
"(dynamic parameter) (<#{elem.name}>)"
|
109
|
+
else
|
110
|
+
"<#{p_attr}:> (<#{elem.name}>)"
|
111
|
+
end
|
112
|
+
sub_list = params_to_list(sub_params, indent + ' ') unless sub_params.empty?
|
113
|
+
"<li>#{entry}\n#{sub_list}</li>\n"
|
114
|
+
end.join
|
115
|
+
|
116
|
+
items.any? ? "<ul>#{items}</ul>" : ""
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
def contents(root)
|
121
|
+
tags = XPath.match(root, '/*/def')
|
122
|
+
tags.map { |tag| " * #{link_to_tag tag}\n" }.join
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def doc_for_taglib(title, root)
|
127
|
+
tags = XPath.match(root, '/*/def').map { |e| doc_for_tag(e) }.join("\n\n")
|
128
|
+
|
129
|
+
"# #{title}\n\n" + contents(root) + "\n\n" + tags
|
130
|
+
end
|
131
|
+
|
132
|
+
namespace :hobo do
|
133
|
+
|
134
|
+
desc "Generate markdown formatted reference docs automatically from DRYML taglibs"
|
135
|
+
task :generate_tag_reference do
|
136
|
+
|
137
|
+
src = ENV['src']
|
138
|
+
|
139
|
+
output_dir = ENV['output'] || "taglib-docs"
|
140
|
+
raise RuntimeError, "#{output_dir} is not a directory" if File.exists?(output_dir) && !File.directory?(output_dir)
|
141
|
+
|
142
|
+
FileUtils.mkdir output_dir unless File.exists? output_dir
|
143
|
+
|
144
|
+
dryml_files = File.directory?(src) ? Dir["#{src}/*"] : [src]
|
145
|
+
|
146
|
+
dryml_files.each do |f|
|
147
|
+
basename = File.basename(f).sub(/\.dryml$/, '')
|
148
|
+
title = basename.titleize
|
149
|
+
|
150
|
+
doc = Hobo::Dryml::Parser::Document.new(File.read(f), f)
|
151
|
+
|
152
|
+
markdown = doc_for_taglib(title, doc)
|
153
|
+
#html = Maruku.new(markdown).to_html
|
154
|
+
|
155
|
+
output_file = "#{output_dir}/#{basename}.markdown"
|
156
|
+
puts output_file
|
157
|
+
File.open(output_file, 'w') { |f| f.write(markdown) }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|