diff --git a/docs-2.0/3.ngql-guide/1.nGQL-overview/comments.md b/docs-2.0/3.ngql-guide/1.nGQL-overview/comments.md new file mode 100644 index 00000000000..5194cd6eb71 --- /dev/null +++ b/docs-2.0/3.ngql-guide/1.nGQL-overview/comments.md @@ -0,0 +1,46 @@ +# Comments + +This topic will describe the comments in nGQL. + +## Legacy version compatibility + +* In Nebula Graph 1.0, there are four comment styles: `#`, `--`, `//`, `/* */`. +* In Nebula Graph 2.0, `--` represents [an edge pattern](../../3.ngql-guide/1.nGQL-overview/3.graph-patterns.md) and cannot be used as comments. + +## Examples + +```ngql +nebula> # Do nothing in this line +nebula> RETURN 1+1; # This comment continues to the end of this line. +nebula> RETURN 1+1; // This comment continues to the end of this line. +nebula> RETURN 1 /* This is an in-line comment. */ + 1 == 2; +nebula> RETURN 11 + \ +/* Multi-line comment. \ +Use a backslash as a line break. \ +*/ 12; +``` + +In nGQL statement, the backslash `\` in a line indicates a line break. + +## OpenCypher compatibility + +* In nGQL, you must add a `\` at the end of every line, even in multi-line comments `/* */`. +* In openCypher, there is no need to use a `\` as a line break. + +```openCypher +/* openCypher style: +The following comment +spans more than +one line */ +MATCH (n:label) +RETURN n; +``` + +```ngql +/* nGQL style: \ +The following comment \ +spans more than \ +one line */ \ +MATCH (n:tag) \ +RETURN n; +``` diff --git a/mkdocs.yml b/mkdocs.yml index 46136e96d71..74431c3c66f 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -67,6 +67,7 @@ nav: - nGQL overview: - Overview: 3.ngql-guide/1.nGQL-overview/1.overview.md - Graph patterns: 3.ngql-guide/1.nGQL-overview/3.graph-patterns.md + - Comments: 3.ngql-guide/1.nGQL-overview/comments.md - Data types: - Numeric: 3.ngql-guide/3.data-types/1.numeric.md - Boolean: 3.ngql-guide/3.data-types/2.boolean.md