annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Top does not do what I think it should? And annotator fails to indent.

Open kwerle opened this issue 9 months ago • 2 comments

I have a class that was written:

# Schema information from previous annotator
module SomeModule
  # Some doc about MyModel
  class MyModel < ...

I changed all of annotaterb's position options to 'top' - which I supposed is top of file? It inserted docs like this (see also #201):

module SomeModule
  # Some doc about MyModel
# Schema information from annotaterb
  class MyModel < ...

I expected the schema information to go to the top of the file. I expect standard indentation. And/or indentation that matches the class declaration.

kwerle avatar Mar 24 '25 20:03 kwerle

Are you still facing this issue? There's a significant change between the old gem and this one, namely that the old one used a regex pattern in an attempt to match the annotation pattern.

That was hard to iterate on, so a file parser was used instead. If you have this problem still, let me know if you are able to debug the parser and see how it's conflicting with your setup.

drwl avatar Jul 15 '25 03:07 drwl

@drwl It is much improved! Models that already have schema information and comments seem to be updated correctly. However - if I have a new model file like

# These are some commends
class MyModel
...
end

When I annotate it I end up with

# These are some commends
# == Schema Information
...
#
class MyModel
...
end

And what I expect is:

# == Schema Information
...
#

# These are some commends
class MyModel
...
end

It is trivial to reproduce this issue in all model files by doing annotaterb models -d && annotaterb models

==================

I'll add an additional note in here because I don't think it's an issue worth addressing but it is interesting. Ignore this bug pollution!

A handful of my models got duplicate index information in them when I migrated from the old annotate to annotaterb for some reason. Literally 1% - 3/300ish. No idea why. When I deleted the index information and re-annotated it behaved correctly.

Here is an example:

# Indexes
#
#  index_runs_on_data_set_id_and_group_id  (data_set_id)
#  index_runs_on_group_id                  (data_set_id)
#  index_runs_on_project_id                (project_id)
#  index_runs_on_protocol_id               (protocol_id)
#  index_runs_on_user_id                   (user_id)
#
#  index_runs_on_data_set_id_and_group_id  (data_set_id)
#  index_runs_on_group_id                  (data_set_id)
#  index_runs_on_project_id                (project_id)
#  index_runs_on_protocol_id               (protocol_id)
#  index_runs_on_user_id                   (user_id)

kwerle avatar Jul 17 '25 20:07 kwerle