Skip to content

Commit c92bf23

Browse files
ryanwjacksonpeterfication
authored andcommitted
Additional file patterns docs (ctran#637)
Add better documentation for new option for additional file patterns. Implemented in ctran#633 and ctran#636.
1 parent a098c5e commit c92bf23

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

README.rdoc

+25-5
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ you can do so with a simple environment variable, instead of editing the
163163
== Options
164164

165165
Usage: annotate [options] [model_file]*
166-
--additional_file_patterns Additional file paths or globs to annotate
166+
--additional_file_patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
167167
-d, --delete Remove annotations from all model files or the routes.rb file
168168
-p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
169169
--position
@@ -206,15 +206,35 @@ you can do so with a simple environment variable, instead of editing the
206206
--frozen Do not allow to change annotations. Exits non-zero if there are going to be changes to files.
207207
--timestamp Include timestamp in (routes) annotation
208208
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
209-
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`
210-
--ignore-routes REGEX don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`
209+
-I, --ignore-columns REGEX don't annotate columns that match a given REGEX (e.g. `annotate -I '^(id|updated_at|created_at)'`)
210+
--ignore-routes REGEX don't annotate routes that match a given REGEX (e.g. `annotate -I '(mobile|resque|pghero)'`)_
211211
--hide-limit-column-types VALUES
212-
don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)
212+
don't show limit for given column types, separated by commas (e.g. `integer,boolean,text`)
213213
--hide-default-column-types VALUES
214-
don't show default for given column types, separated by commas (i.e., `json,jsonb,hstore`)
214+
don't show default for given column types, separated by commas (e.g. `json,jsonb,hstore`)
215215
--ignore-unknown-models don't display warnings for bad model files
216216
--with-comment include database comments in model annotations
217217

218+
=== Option: +additional_file_patterns+
219+
220+
CLI: +--additional_file_patterns+<br>
221+
Ruby: +:additional_file_patterns+
222+
223+
Provide additional paths for the gem to annotate. These paths can include globs.
224+
It is recommended to use absolute paths. Here are some examples:
225+
226+
227+
- <code>/app/lib/decorates/%MODEL_NAME%/&ast;.rb</code>
228+
- <code>/app/lib/forms/%PLURALIZED_MODEL_NAME%/&ast;&ast;/&ast;.rb</code>
229+
- <code>/app/lib/forms/%TABLE_NAME%/&ast;.rb</code>
230+
231+
The appropriate model will be inferred using the <code>%*%</code> syntax, annotating any matching files.
232+
It works with existing filename resolutions (options for which can be found in the +resolve_filename+ method of
233+
+annotate_models.rb+).
234+
235+
When using in a Rails config, you can use the following:
236+
237+
<code>File.join(Rails.application.root, 'app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb')</code>
218238

219239
== Sorting
220240

lib/annotate/parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def add_options_to_parser(option_parser) # rubocop:disable Metrics/MethodLength
4949

5050
option_parser.banner = 'Usage: annotate [options] [model_file]*'
5151

52-
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate") do |additional_file_patterns|
52+
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)") do |additional_file_patterns|
5353
ENV['additional_file_patterns'] = additional_file_patterns
5454
end
5555

0 commit comments

Comments
 (0)