delphi - Is there a way to escape a closing bracket for comments? -
i'm adding comments delphi code documentation. 1 of things i'm trying document json structure, i'm trying put sample json data commented in code. however, json uses squiggly brackets { }
, coincidentally used comments in delphi.
because of this, can't figure out way add these comments. documentation comment blocks use { }
, example:
{ unit , that. use tsomecomponent bla bla }
when try document json data, closing bracket }
ends comment - if line prefixed single-line comment //
, doesn't work:
{ how json structure looks: // { // "some_string": "value", // "some_object": { // "something": 123 // }, //<-- compiler detects comma // "something_else": "some other string" // } }
as there's closing bracket }
, commented line becomes uncommented, if it's prefixed 2 slashes. delphi picks comma after bracket. in end, cannot figure out way in can document json samples inside code.
i tried using (* *)
around json block still no luck.
is there way around or stuck it?
i discovered solution while typing question, i'm answering q/a style...
when comment block first starts in code in question above, starts opening bracket {
. so, compiler desperately looking find closing bracket, if closing bracket in commented line of code. but, if every line in comment block begins 2 slashes //
instead of opening bracket {
, compiler not looking closing bracket }
. so, instead of code in question above, how should written:
// how json structure looks: // // { // "some_string": "value", // "some_object": { // "something": 123 // }, // "something_else": "some other string" // }
so long don't start comment block opening bracket, compiler won't try end comment block when finds closing bracket.
also, using (* *)
should work fine, long don't use after you've used {
. enclose entire block (*
, *)
, compiler ignore {
or }
inside, so:
(* how json structure looks: { "some_string": "value", "some_object": { "something": 123 }, "something_else": "some other string" } *)
essentially, moment begin 1 comment, whether //
, {
, or (*
, ignore further opening of other type of comment - looking end of own comment type. //
end of line, {
}
, , (*
*)
.
Comments
Post a Comment