kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/indexer/testdata/basic/comments.go (about)

     1  // Package comment contains comments.
     2  package comment
     3  
     4  //- Pkg.node/kind package
     5  //- Pkg.doc/uri "http://godoc.org/kythe/go/indexer/comment_test"
     6  //- PkgDoc.node/kind doc
     7  //- PkgDoc documents Pkg
     8  //- PkgDoc.text "Package comment contains comments."
     9  
    10  //- @+3"foo" defines/binding Foo
    11  
    12  /* foo comment */
    13  var foo int
    14  
    15  //- Foo.node/kind variable
    16  //- FooDoc.node/kind doc
    17  //- FooDoc.text "foo comment"
    18  //- FooDoc documents Foo
    19  
    20  // General constants.
    21  const (
    22  	//- @+2"bar" defines/binding Bar
    23  
    24  	bar = 5
    25  
    26  	//- @+3"baz" defines/binding Baz
    27  
    28  	// baz comment
    29  	baz = "quux" // doc comments are preferred
    30  
    31  	//- @+2"ほげ" defines/binding JFoo
    32  
    33  	ほげ = 42 // the japanese equivalent of foo
    34  )
    35  
    36  // Names without their own comments inherit the block comment, if present.
    37  // This may result in duplicating the comment text to different nodes.
    38  //
    39  //- Bar.node/kind constant
    40  //- BarComment.node/kind doc
    41  //- BarComment.text "General constants."
    42  //- BarComment documents Bar
    43  
    44  // Names with their own comments prefer them.
    45  //- Baz.node/kind constant
    46  //- BazComment.node/kind doc
    47  //- BazComment.text "baz comment"
    48  //- BazComment documents Baz
    49  
    50  // Line comments are used when there is no above-line "doc" comment.
    51  //- !{ _BazLineComment.text "doc comments are preferred" }
    52  //- LineComment documents JFoo
    53  //- LineComment.node/kind doc
    54  //- LineComment.text "the japanese equivalent of foo"
    55  
    56  //- @+3"alpha" defines/binding Alpha
    57  
    58  // alpha is a function.
    59  func alpha() {}
    60  
    61  //- ImportantComment documents Param
    62  //- ImportantComment.text "load-bearing comment"
    63  //- EhComment documents Eh
    64  //- EhComment.text "idk"
    65  
    66  //- @+5"importantParam" defines/binding Param
    67  //- @+6"ehParam" defines/binding Eh
    68  
    69  func beta(
    70  	// load-bearing comment
    71  	importantParam string,
    72  
    73  	ehParam string, // idk
    74  ) {
    75  }
    76  
    77  //- Alpha.node/kind function
    78  //- AlphaDoc.node/kind doc
    79  //- AlphaDoc.text "alpha is a function."
    80  //- AlphaDoc documents Alpha
    81  
    82  //- @+3"widget" defines/binding Widget
    83  
    84  // widget comment
    85  type widget struct {
    86  	//- Lawyer.node/kind variable
    87  	//- LawyerDoc documents Lawyer
    88  	//- LawyerDoc.text "Lawyer takes the bar."
    89  	//-
    90  	//- @+3"Lawyer" defines/binding Lawyer
    91  
    92  	// Lawyer takes the bar.
    93  	Lawyer bool
    94  
    95  	//- ErrField.node/kind variable
    96  	//- ErrDoc documents ErrField
    97  	//- ErrDoc.text "What went wrong."
    98  	//-
    99  	//- @+3"error" defines/binding ErrField
   100  
   101  	// What went wrong.
   102  	error
   103  
   104  	//- LineDoc documents ByLineField
   105  	//- LineDoc.text "this is a line comment"
   106  	//- @+2ByLine defines/binding ByLineField
   107  
   108  	ByLine int // this is a line comment
   109  }
   110  
   111  //- Widget.node/kind record
   112  //- WidgetComment.node/kind doc
   113  //- WidgetComment.text "widget comment"
   114  //- WidgetComment documents Widget
   115  
   116  //- @+3I defines/binding I
   117  
   118  // interface comment
   119  type I interface {
   120  	//- I.node/kind interface
   121  	//- IDoc.node/kind doc
   122  	//- IDoc.text "interface comment"
   123  	//- IDoc documents I
   124  
   125  	//- @+3M defines/binding M
   126  
   127  	// A method comment
   128  	M() bool
   129  
   130  	//- M.node/kind function
   131  	//- MDoc.node/kind doc
   132  	//- MDoc.text "A method comment"
   133  	//- MDoc documents M
   134  }