Skip to content

Commit

Permalink
Clarify docs about magic comments placement
Browse files Browse the repository at this point in the history
Magic comments like `frozen_string_literal` may appear everywhere
within the first comment section while `encoding` have to be the first
line, or second line after shebang.
  • Loading branch information
splattael authored and hsbt committed Oct 30, 2021
1 parent f634d1e commit 09bdb43
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/syntax/comments.rdoc
Expand Up @@ -41,8 +41,7 @@ syntax error:
While comments are typically ignored by Ruby, special "magic comments" contain
directives that affect how the code is interpreted.

Top-level magic comments must start on the first line, or on the second line if
the first line looks like <tt>#! shebang line</tt>.
Top-level magic comments must appear in the first comment section of a file.

NOTE: Magic comments affect only the file in which they appear;
other files are unaffected.
Expand Down Expand Up @@ -74,7 +73,8 @@ regexp literals and <code>__ENCODING__</code>:

Default encoding is UTF-8.

It must appear in the first comment section of a file.
Top-level magic comments must start on the first line, or on the second line if
the first line looks like <tt>#! shebang line</tt>.

The word "coding" may be used instead of "encoding".

Expand Down

0 comments on commit 09bdb43

Please sign in to comment.