Debian Codegraph @

examples/class/inline-doc.ck

raw
1 // show how to add descriptions with classes and functions
2 // @doc: descriptions added in this manner are associatd
3 // with respective classes and functions and will appear in the
4 // .help() runtime info mechanism, as well as in documentation
5 // generated using CKDoc.
6 // @example: example ChucK files can be associatec with class
7 // definitions and will be appear in CKDoc-generated documentation
8 // NOTE: file paths expected to be relative the CKDoc.examplesRoot
9 // (examples do not appear in the .help() funtime info)
10 //
11 // requires: chuck-1.5.5.8 or higher
12
13 // add inline documenation (processed at compile-time)
14 // (@doc and @example must appear right before the target)
15 @example "foo1.ck"
16 @example ["foo2.ck", "foo3.ck"]
17 @doc "this is a description for the class Foo"
18 public class Foo
19 {
20 // add inline documenation (processed at compile-time)
21 // (@doc must appear immediately before the function definition)
22 @doc "a function in Foo, bar() likes calling his friends"
23 fun void bar()
24 {
25 beth();
26 kenny();
27 }
28
29 // add inline documenation (processed at compile-time)
30 @doc "beth() is working on a novel about shared memory"
31 fun static void beth()
32 { }
33
34 // add inline documenation (processed at compile-time)
35 @doc "kenny() is fun, and expects nothing in return"
36 fun static void kenny()
37 { }
38
39 // add inline documentation for variable
40 @doc "this here is a variable called varFoo"
41 5 => int varFoo;
42
43 // add inline documentation for variable
44 @doc "this here is a static variable called varBar"
45 10 => static int varBar;
46
47 // add inline documentation for variable (but hide it)
48 @doc "(hidden) this variable is documented but hidden from ckdoc"
49 15 => static int varBarHidden;
50 }
51
52 // print runtime info about Foo...
53 // (will also appear in documentation generated by CKDoc)
54 <<< CKDoc.describe( Foo ) >>>;
55 <<< CKDoc.describe( Foo.beth ) >>>;
56 <<< CKDoc.describe( Foo.kenny ) >>>;
57
58 // with an instance, can also get info about instanced functions
59 Foo f;
60 <<< CKDoc.describe( f ) >>>;
61 <<< CKDoc.describe( f.bar ) >>>;
62
63 // print the ckdoc for Foo
64 Foo.help();