Comments
========

LilyPond comments begin with the ``%`` sign.
Abjad models LilyPond comments as marks.

Adding comments
---------------

You can add comments before, after or to the right of any note, rest or chord:

<abjad>
note = Note(13, (1, 4))
show(note)
iotools.write_expr_to_ly(note, 'first-ex', 'oedo') <hide
</abjad>

<abjad>
marktools.Comment('This is a comment before the note.', 'before')(note)
marktools.Comment('This is a comment to the right of the note.', 'right')(note)
</abjad>

<abjad>
f(note)
</abjad>

You can add comments before, after, in the opening or in the closing of any container:

<abjad>
staff = Staff("c'8 d'8 e'8 f'8")
show(staff)
iotools.write_expr_to_ly(staff, 'staff-ex', 'oedo') <hide
</abjad>

<abjad>
marktools.Comment('Here is a comment before the staff.', 'before')(staff)
marktools.Comment('Here is a comment in the staff opening.', 'opening')(staff)
marktools.Comment('Here is another comment in the staff opening.', 'opening')(staff)
marktools.Comment('Comment in the staff closing.', 'closing')(staff)
marktools.Comment('Comment after the staff.', 'after')(staff)
</abjad>

<abjad>
f(staff)
</abjad>

Getting comments
----------------

Use mark tools to get comments:

<abjad>
marktools.get_comments_attached_to_component(note)
print repr(marktools.get_comments_attached_to_component(note)) <hide
</abjad>

Detaching comments
------------------

Detach comments by hand:

<abjad>
comment_1, comment_2 = marktools.get_comments_attached_to_component(note)
</abjad>

<abjad>
comment_1.detach_mark( )
print repr(comment_1.detach_mark( )) <hide
comment_2.detach_mark( )
print repr(comment_2.detach_mark( )) <hide
</abjad>

<abjad>
f(note)
</abjad>

<abjad>
marktools.get_comments_attached_to_component(note)
print repr(marktools.get_comments_attached_to_component(note)) <hide
</abjad>

Or use mark tools to detach comments automatically:

<abjad>
marktools.detach_comments_attached_to_component(staff)
</abjad>

<abjad>
f(staff)
</abjad>

<abjad>
marktools.get_comments_attached_to_component(staff)
print repr(marktools.get_comments_attached_to_component(staff)) <hide
</abjad>
