hobo 0.7.4 → 0.7.5

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.
Files changed (45) hide show
  1. data/bin/hobo +0 -6
  2. data/hobo_files/plugin/CHANGES.txt +103 -0
  3. data/hobo_files/plugin/Rakefile +2 -0
  4. data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +1 -0
  5. data/hobo_files/plugin/generators/hobo_rapid/templates/IE7.js +2 -0
  6. data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +28 -12
  7. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/{application.css → clean.css} +10 -9
  8. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +1 -1
  9. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/views/{application.dryml → clean.dryml} +0 -0
  10. data/hobo_files/plugin/init.rb +7 -3
  11. data/hobo_files/plugin/lib/hobo.rb +3 -1
  12. data/hobo_files/plugin/lib/hobo/bundle.rb +24 -14
  13. data/hobo_files/plugin/lib/hobo/dryml.rb +5 -1
  14. data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +1 -1
  15. data/hobo_files/plugin/lib/hobo/dryml/parser/base_parser.rb +11 -10
  16. data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +37 -10
  17. data/hobo_files/plugin/lib/hobo/dryml/template.rb +5 -22
  18. data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +1 -1
  19. data/hobo_files/plugin/lib/hobo/dryml/template_handler.rb +10 -2
  20. data/hobo_files/plugin/lib/hobo/hobo_helper.rb +7 -0
  21. data/hobo_files/plugin/lib/hobo/model.rb +18 -13
  22. data/hobo_files/plugin/lib/hobo/model_controller.rb +45 -54
  23. data/hobo_files/plugin/lib/hobo/model_router.rb +8 -1
  24. data/hobo_files/plugin/lib/hobo/scopes.rb +3 -4
  25. data/hobo_files/plugin/lib/hobo/scopes/automatic_scopes.rb +3 -0
  26. data/hobo_files/plugin/taglib-docs/core.markdown +165 -0
  27. data/hobo_files/plugin/taglib-docs/rapid.markdown +677 -0
  28. data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +240 -0
  29. data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +418 -0
  30. data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +562 -0
  31. data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +187 -0
  32. data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +214 -0
  33. data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +530 -0
  34. data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +65 -0
  35. data/hobo_files/plugin/taglib-docs/rapid_support.markdown +50 -0
  36. data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +129 -0
  37. data/hobo_files/plugin/taglibs/rapid.dryml +2 -2
  38. data/hobo_files/plugin/taglibs/rapid_forms.dryml +7 -22
  39. data/hobo_files/plugin/taglibs/rapid_generics.dryml +14 -12
  40. data/hobo_files/plugin/taglibs/rapid_navigation.dryml +5 -4
  41. data/hobo_files/plugin/taglibs/rapid_pages.dryml +5 -1
  42. data/hobo_files/plugin/tasks/fix_dryml.rake +1 -1
  43. data/hobo_files/plugin/tasks/generate_tag_reference.rb +162 -0
  44. data/hobo_files/plugin/tasks/hobo_tasks.rake +17 -0
  45. 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">&nbsp;</a>
10
+ ## &lt;table-plus&gt;
11
+
12
+
13
+
14
+ ### Attributes (merged with [&lt;div&gt;](#div))
15
+
16
+ * sort-field
17
+ * sort-direction
18
+ * sort-columns
19
+
20
+
21
+ ### Parameters (merged with [&lt;table&gt;](#table))
22
+
23
+ <ul><li>&lt;header:&gt; (&lt;div&gt;)
24
+ <ul><li>&lt;search-form:&gt; (&lt;form&gt;)
25
+ <ul><li>&lt;search-submit:&gt; (&lt;submit&gt;)
26
+ </li>
27
+ </ul></li>
28
+ </ul></li>
29
+ <li>(dynamic parameter) (&lt;th&gt;)
30
+ <ul><li>(dynamic parameter) (&lt;a&gt;)
31
+ </li>
32
+ <li>&lt;up-arrow:&gt; (&lt;do&gt;)
33
+ </li>
34
+ <li>&lt;down-arrow:&gt; (&lt;do&gt;)
35
+ </li>
36
+ </ul></li>
37
+ <li>&lt;empty-message:&gt; (&lt;do&gt;)
38
+ </li>
39
+ <li>&lt;page-nav:&gt;
40
+ </li>
41
+ </ul>
42
+
43
+
44
+ ---
45
+
46
+ <a name="change-password-form">&nbsp;</a>
47
+ ## &lt;change-password-form&gt;
48
+
49
+
50
+
51
+ ### Attributes
52
+
53
+ None
54
+
55
+ ### Parameters
56
+
57
+ <ul><li>&lt;form:&gt;
58
+ <ul><li>&lt;field-list:&gt;
59
+ </li>
60
+ <li>&lt;actions:&gt; (&lt;div&gt;)
61
+ <ul><li>&lt;submit:&gt;
62
+ </li>
63
+ </ul></li>
64
+ </ul></li>
65
+ </ul>
@@ -0,0 +1,50 @@
1
+ # Rapid Support
2
+
3
+ * [&lt;with-fields&gt;](#with-fields)
4
+ * [&lt;with-field-names&gt;](#with-field-names)
5
+
6
+
7
+ ---
8
+
9
+ <a name="with-fields">&nbsp;</a>
10
+ ## &lt;with-fields&gt;
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>&lt;default:&gt; (&lt;do&gt;)
27
+ </li>
28
+ <li>&lt;default:&gt; (&lt;do&gt;)
29
+ </li>
30
+ </ul>
31
+
32
+
33
+ ---
34
+
35
+ <a name="with-field-names">&nbsp;</a>
36
+ ## &lt;with-field-names&gt;
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
+ * [&lt;signup-page&gt;](#signup-page)
4
+ * [&lt;login-page&gt;](#login-page)
5
+ * [&lt;account-disabled-page&gt;](#account-disabled-page)
6
+ * [&lt;account-page&gt;](#account-page)
7
+
8
+
9
+ ---
10
+
11
+ <a name="signup-page">&nbsp;</a>
12
+ ## &lt;signup-page&gt;
13
+
14
+
15
+
16
+ ### Attributes (merged with [&lt;page&gt;](#page))
17
+
18
+ None
19
+
20
+ ### Parameters (merged with [&lt;page&gt;](#page))
21
+
22
+ <ul><li>&lt;body:&gt;
23
+ </li>
24
+ <li>&lt;content-header:&gt;
25
+ <ul><li>&lt;heading:&gt;
26
+ </li>
27
+ </ul></li>
28
+ <li>&lt;content-body:&gt;
29
+ <ul><li>&lt;form:&gt;
30
+ <ul><li>&lt;field-list:&gt;
31
+ </li>
32
+ <li>&lt;actions:&gt; (&lt;div&gt;)
33
+ </li>
34
+ </ul></li>
35
+ </ul></li>
36
+ </ul>
37
+
38
+
39
+ ---
40
+
41
+ <a name="login-page">&nbsp;</a>
42
+ ## &lt;login-page&gt;
43
+
44
+
45
+
46
+ ### Attributes (merged with [&lt;page&gt;](#page))
47
+
48
+ * remember-me
49
+
50
+
51
+ ### Parameters (merged with [&lt;page&gt;](#page))
52
+
53
+ <ul><li>&lt;body:&gt;
54
+ </li>
55
+ <li>&lt;content-header:&gt;
56
+ <ul><li>&lt;heading:&gt;
57
+ </li>
58
+ </ul></li>
59
+ <li>&lt;content-body:&gt;
60
+ <ul><li>&lt;form:&gt;
61
+ <ul><li>&lt;labelled-item-list:&gt;
62
+ <ul><li>&lt;login-label:&gt; (&lt;item-label&gt;)
63
+ </li>
64
+ <li>&lt;login-input:&gt; (&lt;input&gt;)
65
+ </li>
66
+ <li>&lt;password-label:&gt; (&lt;item-label&gt;)
67
+ </li>
68
+ <li>&lt;password-input:&gt; (&lt;input&gt;)
69
+ </li>
70
+ <li>&lt;remember-me-label:&gt; (&lt;item-label&gt;)
71
+ </li>
72
+ <li>&lt;remember-me-input:&gt; (&lt;input&gt;)
73
+ </li>
74
+ </ul></li>
75
+ <li>&lt;actions:&gt; (&lt;div&gt;)
76
+ <ul><li>&lt;submit:&gt;
77
+ </li>
78
+ </ul></li>
79
+ </ul></li>
80
+ </ul></li>
81
+ </ul>
82
+
83
+
84
+ ---
85
+
86
+ <a name="account-disabled-page">&nbsp;</a>
87
+ ## &lt;account-disabled-page&gt;
88
+
89
+
90
+
91
+ ### Attributes (merged with [&lt;page&gt;](#page))
92
+
93
+ None
94
+
95
+ ### Parameters (merged with [&lt;page&gt;](#page))
96
+
97
+ <ul><li>&lt;body:&gt;
98
+ </li>
99
+ <li>&lt;content-header:&gt;
100
+ <ul><li>&lt;heading:&gt;
101
+ </li>
102
+ </ul></li>
103
+ <li>&lt;content-body:&gt;
104
+ </li>
105
+ </ul>
106
+
107
+
108
+ ---
109
+
110
+ <a name="account-page">&nbsp;</a>
111
+ ## &lt;account-page&gt;
112
+
113
+
114
+
115
+ ### Attributes (merged with [&lt;page&gt;](#page))
116
+
117
+ None
118
+
119
+ ### Parameters (merged with [&lt;page&gt;](#page))
120
+
121
+ <ul><li>&lt;body:&gt;
122
+ </li>
123
+ <li>&lt;content-header:&gt;
124
+ </li>
125
+ <li>&lt;content-body:&gt;
126
+ <ul><li>&lt;error-messages:&gt;
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 ||= 'application' -%>
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="belongs-to-autocompleting-input">
302
- <% refl = this_type
303
- completer_model ||= refl.klass
304
- completer_attr ||= refl.klass.id_name_column
305
- id ||= dom_id + "_completer"
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 = request.request_uri if stay_here %>
359
+ <% uri = "stay-here" if stay_here %>
375
360
  <% uri = session[:previous_uri] if go_back %>
376
361
  <input type="hidden" value="&params[: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 field="&this.class.creator_attribute" class="creator" if="&this.class.creator_attribute" param="by"/>
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
- <set collection-name="&(this.try.origin_attribute || this.member_class.name.pluralize).to_s"/>
104
- <div class="collection-preview" merge-attrs>
105
- <h2>
106
- <do param="heading"><collection-name.titleize/></do>
107
- <span param="show-all-link" if="&this.any? && linkable?">(<a>show all</a>)</span>
108
- </h2>
109
- <collection merge-params>
110
- <card: class="small"/>
111
- </collection>
112
- </div>
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="&current">
@@ -29,7 +30,7 @@
29
30
  <def tag="account-nav">
30
31
  <ul with="&current_user" class="account-nav" param>
31
32
  <if test="&logged_in?">
32
- <li class='nav-item' param="logged-in-as"><a to="&current_user">Logged in as <view:login/></a></li>
33
+ <li class='nav-item' param="logged-in-as"><a to="&current_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
- <!-- write your own navigation using the <navigation> tag -->
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" if param>There <count prefix="are"/></p>
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 = REXML::Document.new(Hobo::Dryml::RexSource.new(@src), :dryml_mode => true)
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 = "&lt;#{name}#{for_decl}&gt;"
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}">&nbsp;</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
+ "&lt;#{elem.name}:&gt;"
107
+ elsif p_attr =~ /#\{/
108
+ "(dynamic parameter) (&lt;#{elem.name}&gt;)"
109
+ else
110
+ "&lt;#{p_attr}:&gt; (&lt;#{elem.name}&gt;)"
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
+