Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document drracket:comment-delimiters #635

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drracket/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

(define pkg-authors '(robby))

(define version "1.14")
(define version "1.15")

(define license
'(Apache-2.0 OR MIT))
69 changes: 69 additions & 0 deletions drracket/scribblings/tools/lang-tools.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,75 @@ The default value is @racket[(list #\" #\|)].
@history[#:added "1.10"]
}

@section{Comments}

@language-info-def[drracket:comment-delimiters]{

When a language's @racket[_get-info] procedure responds to
@racket['drracket:comment-delimiters], it is expected to return a
value with this contract:

@racketblock[(listof
(or/c (list/c 'line string? string?)
(list/c 'region string? string? string? string?)))]

The value is a list of comment styles. Each comment style is
expressed as one of:

@itemlist[

@item{@racket[(list 'line start padding)], where @racket[_start]
plus @racket[_padding] starts a comment that is teriminated by the end
of a line.

Lisp example: @racket['(line ";;" " ")].

C++ example: @racket['(line "//" " ")].}

@item{@racket[(list 'region start continue end padding)], where:

@itemlist[

@item{@racket[_start] then @racket[_padding] opens a comment}

@item{@racket[_continue] then @racket[padding] is added to the
beginning of each line except the first one when a comment spans
multiple lines}

@item{@racket[_padding] then @racket[_end] closes a comment}]

Racket example: @racket['(region "#|" "|#" " " " ")].

C++ example: @racket['(region "/*" " *" "*/" " ")].}

]

When not specified by a lang, the default value is suitable for
Racket s-expression langs:

@racketblock['((line ";;" " ")
(region "#|" "|#" " " " "))]

An intended use for these values is by (un)comment commands, which
vary among tools. Some tools (un)comment entire lines, whereas others
may handle portions of a line. Generally this is orthogonal to using a
lang's line vs. region style: A tool can wrap entire lines using
region comments. A tool can insert line breaks to make it possible to
use line comments on a portion of a line. The point of
@racket['drracket:comment-delimiters] is to enable a lang to tell a
tool about its comment delimiters --- not to say exactly how
the (un)comment commands could or should work, exactly.

When the list has multiple styles: Some tools may present the styles
for the user to pick one. Other tools may default to using the first
style in the list (allowing the user to configure another preference
by other means). Therefore when a language supports multiple comment
styles, it should @emph{list the most popular or preferred style
first}.

@history[#:added "1.15"]
}

@section{Keystrokes}

@language-info-def[drracket:keystrokes]{
Expand Down