Best annotation position is different for models and fixtures... #6

Closed
adamsalter opened this Issue Sep 25, 2009 · 6 comments

Comments

Projects
None yet
5 participants

The 'best' IMHO position for annotations in models is after all code, since you regularly have to edit it and only refer to annotations irregularly. But for fixtures it's is before all the yaml data, since you can have huge yaml files and scrolling to the bottom is annoying/hard, and use usually only refer to fixtures once or twice in their lifetime (certainly less than models).

Could this be changed to the default behaviour? (I know it makes the current 'before|after' syntax a little hard since it is a mix of both...

Thanks in advance,

Owner

ctran commented Sep 25, 2009

I'll see what I can do.

Great!
Thanks for the quick reply ;)

jlw commented Nov 12, 2009

I've used Dave Thomas' annotate models plugin since at least mid-07 and just found your fork (I have other devs who never bother to run annotations, so the after migrate hook is my reason for changing). IMHO, having the default change for everyone to after the model class based on 1 person's preference is bad form.

  1. Please change annotate_one_file to:

new_content = options[:position] == 'after' ? (old_content + "\n" + info_block) : (info_block + old_content)

  1. Or at the very least fix the bug in the annotate_models rake task - :before should be 'before' (:before != 'before').
Contributor

kuroda commented May 14, 2010

+1 for jlw

Please fix the subtle bug that he mentioned.

Line 5 and 6 must be end with 'before' instead of :before.

Because of this bug, the annotation is inserted after the code without -p option.

Contributor

davidxia commented Jan 27, 2012

IMHO, annotations at the beginning of the model file seems to be more widely practiced. I agree with @jlw. Can we make 'before' the default option? I've made both of @jlw suggestions above into a pull request here #69

This issue is related to #34. @robertwahler converts options[:position] to a symbol in annotate_models.rb so that's another way.

Owner

ctran commented Feb 26, 2014

It's is now possible to have your own config. Please check the documentation.

ctran closed this Feb 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment