1/*
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * Program doctext.
19 *
20 * Seriously, this is the documentation for this whole program.
21 */
22
23namespace java thrift.test
24namespace cpp thrift.test
25namespace json thrift.test.doc
26
27// C++ comment
28/* c style comment */
29
30# the new unix comment
31
32/** Some doc text goes here.  Wow I am [nesting these] (no more nesting.) */
33enum Numberz {
34  /** This is how to document a parameter */
35  ONE = 1,
36
37  /** And this is a doc for a parameter that has no specific value assigned */
38  TWO = 2,
39
40  THREE = 3,
41  FIVE = 5,
42  SIX = 6,
43  EIGHT = 8,
44}
45
46/** This is how you would do a typedef doc */
47typedef i64 UserId
48
49/** And this is where you would document a struct */
50struct Xtruct {
51  /** And the members of a struct */
52  1: string string_thing;
53
54  /** doct text goes before a comma */
55  4: byte byte_thing;
56
57  9: i32 i32_thing;
58  11: i64 i64_thing;
59}
60
61/**
62 * You can document constants now too.  Yeehaw!
63 */
64const i32 INT32CONSTANT = 9853;
65const i16 INT16CONSTANT = 1616;
66/** Everyone get in on the docu-action! */
67const map<string, string> MAPCONSTANT = {'hello': 'world', 'goodnight': 'moon'};
68
69struct Xtruct2 {
70  1: byte byte_thing;
71  2: Xtruct struct_thing;
72  3: i32 i32_thing;
73}
74
75/** Struct insanity */
76struct Insanity {
77  /** This is doc for field 1 */
78  1: map<Numberz, UserId> userMap;
79
80  /** And this is doc for field 2 */
81  2: list<Xtruct> xtructs;
82}
83
84exception Xception {
85  1: i32 errorCode;
86  2: string message;
87}
88
89exception Xception2 {
90  1: i32 errorCode;
91  2: Xtruct struct_thing;
92}
93
94/* C1 */
95/** Doc */
96/* C2 */
97/* C3 */
98struct EmptyStruct {}
99
100struct OneField {
101  1: EmptyStruct field;
102}
103
104/** This is where you would document a Service */
105service ThriftTest {
106  /** And this is how you would document functions in a service */
107  void testVoid();
108  string testString(1: string thing);
109  byte testByte(1: byte thing);
110  i32 testI32(1: i32 thing);
111
112  /** Like this one */
113  i64 testI64(1: i64 thing);
114  double testDouble(1: double thing);
115  Xtruct testStruct(1: Xtruct thing);
116  Xtruct2 testNest(1: Xtruct2 thing);
117  map<i32, i32> testMap(1: map<i32, i32> thing);
118  set<i32> testSet(1: set<i32> thing);
119  list<i32> testList(1: list<i32> thing);
120
121  /** This is an example of a function with params documented */
122  Numberz testEnum(
123    /** This param is a thing */
124    1: Numberz thing,
125  );
126
127  UserId testTypedef(1: UserId thing);
128
129  map<i32, map<i32, i32>> testMapMap(1: i32 hello);
130
131  /* So you think you've got this all worked, out eh? */
132  map<UserId, map<Numberz, Insanity>> testInsanity(1: Insanity argument);
133}
134
135/// This style of Doxy-comment doesn't work.
136typedef i32 SorryNoGo
137
138/**
139 * This is a trivial example of a multiline docstring.
140 */
141typedef i32 TrivialMultiLine
142
143/**
144 * This is the cannonical example
145 * of a multiline docstring.
146 */
147typedef i32 StandardMultiLine
148
149/**
150 * The last line is non-blank.
151 * I said non-blank! */
152typedef i32 LastLine
153
154/** Both the first line
155 * are non blank. ;-)
156 * and the last line */
157typedef i32 FirstAndLastLine
158
159/**
160 *    INDENTED TITLE
161 * The text is less indented.
162 */
163typedef i32 IndentedTitle
164
165/**       First line indented.
166 * Unfortunately, this does not get indented.
167 */
168typedef i32 FirstLineIndent
169
170/**
171 * void code_in_comment() {
172 *   printf("hooray code!");
173 * }
174 */
175typedef i32 CodeInComment
176
177/**
178     * Indented Docstring.
179     * This whole docstring is indented.
180     *   This line is indented further.
181     */
182typedef i32 IndentedDocstring
183
184/** Irregular docstring.
185 * We will have to punt
186  * on this thing */
187typedef i32 Irregular1
188
189/**
190 * note the space
191 * before these lines
192* but not this
193 * one
194 */
195typedef i32 Irregular2
196
197/**
198* Flush against
199* the left.
200*/
201typedef i32 Flush
202
203/**
204  No stars in this one.
205  It should still work fine, though.
206    Including indenting.
207    */
208typedef i32 NoStars
209
210/** Trailing whitespace
211Sloppy trailing whitespace
212is truncated.   */
213typedef i32 TrailingWhitespace
214
215/**
216 * This is a big one.
217 *
218 * We'll have some blank lines in it.
219 *
220 * void as_well_as(some code) {
221 *   puts("YEEHAW!");
222 * }
223 */
224typedef i32 BigDog
225
226/**
227*
228*
229*/
230typedef i32 TotallyDegenerate
231/* THE END */
232