Skip to content

Commit b0b1083

Browse files
Add a doc field on Function and update content advice (#446)
Add a doc field on function and update content advice
1 parent d564205 commit b0b1083

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

proto/cel/expr/checked.proto

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ message Decl {
236236
Constant value = 2;
237237

238238
// Documentation string for the identifier.
239+
//
240+
// Provide a brief description of what the variable represents and whether
241+
// there are any constraints on the formatting or supported value range.
242+
//
243+
// Examples:
244+
//
245+
// 'request.auth.principal' - string which uniquely identifies an
246+
// authenticated principal. For JSON Web Tokens (JWTs), the principal
247+
// is the combination of the issuer ('iss') and subject ('sub') token
248+
// fields concatenated by a forward slash: iss + `/` + sub.
249+
//
250+
// 'min_cpus' - integer value indicates the minimum number of CPUs
251+
// required for a compute cluster. The 'min_cpus' value must be
252+
// greater than zero and less than 'max_cpus' or 64 whichever is less.
239253
string doc = 3;
240254
}
241255

@@ -293,11 +307,45 @@ message Decl {
293307
bool is_instance_function = 5;
294308

295309
// Documentation string for the overload.
310+
//
311+
// Provide examples of the overload behavior, preferring to use literal
312+
// values as input with a comment on the return value.
313+
//
314+
// Examples:
315+
//
316+
// // Determine whether a value of type <V> exists within a list<V>.
317+
// 2 in [1, 2, 3] // returns true
318+
//
319+
// // Determine whether a key of type <K> exists within a map<K,V>.
320+
// 'hello' in {'hi': 'you', 'hello': 'there'} // returns true
321+
// 'help' in {'hi': 'you', 'hello': 'there'} // returns false
322+
//
323+
// // Take the substring of a string starting at a specific character
324+
// // offset (inclusive).
325+
// "tacocat".substring(1) // returns "acocat"
326+
// "tacocat".substring(20) // error
327+
//
328+
// // Take the substring of a string starting at a specific character
329+
// // offset (inclusive) and ending at the given offset (exclusive).
330+
// "tacocat".substring(1, 6) // returns "acoca"
296331
string doc = 6;
297332
}
298333

299334
// Required. List of function overloads, must contain at least one overload.
300335
repeated Overload overloads = 1;
336+
337+
// Documentation string for the function that indicates the general purpose
338+
// of the function and its behavior.
339+
//
340+
// Documentation strings for the function should be general purpose with
341+
// specific examples provided in the overload doc string.
342+
//
343+
// Examples:
344+
//
345+
// The 'in' operator tests whether an item exists in a collection.
346+
//
347+
// The 'substring' function returns a substring of a target string.
348+
string doc = 2;
301349
}
302350

303351
// The fully qualified name of the declaration.

0 commit comments

Comments
 (0)