]> git.r.bdr.sh - rbdr/r.bdr.sh/blame - api.gmi
Adjust the logic here
[rbdr/r.bdr.sh] / api.gmi
CommitLineData
b0ca5dae
RBR
1--- title: /api.html
2--- description: API Notation
f752d89a 3## API Notation
b0ca5dae 4
12629849 5API Notation is a language-agnostic notation to share the public API of components in code. It was created to standardize software specification documents in teams that need to review code across several languages.
b0ca5dae 6
f752d89a
RBR
7## Reference
8The notation allows describing objects or modules, with properties, events and methods along with their types.
bfaa6658
RBR
9```
10// Anything after two forward slashes is a comment
11NameOfClass.WithPossibleNamespace
12 + class property
13 - instance property
14 ~> listened events (socket)
15 +> listened events (class/module)
16 -> listened events (instance)
17 <~ dispatched events (socket)
18 <+ dispatched events(class/module)
19 <- dispatched events (instance)
20 :: class method
21 # instance method
f752d89a 22----
bfaa6658
RBR
23Other symbols
24 => returns
25 #> throws
26[xx] optional
27<xx> data type
bfaa6658
RBR
28```
29
f752d89a
RBR
30## Example
31With this artificial example, you can see how to use it for more complex cases:
b0ca5dae 32
b0ca5dae 33```
12629849
RBR
34// Definitions start with object / module / class names, with namespaces
35// separated by periods. Types are marked between angular brackets.
36Definitions.Models.Post
37 // Properties.
f752d89a
RBR
38 +static_property &lt;Type>
39 -instance_property &lt;Types&lt;Can&lt;Be&lt;Nested>>>>
12629849
RBR
40 // Methods. Parameters are listed in parentheses, and comma separated.
41 // Optional values are inside brackets
42 // => defines return values
43 // #> defines thrown exceptions, can be comma separated.
f752d89a
RBR
44 ::static_methods(parameter_label &lt;Type>) => ReturnValueType #> BadTimesException,UnknownError
45 #update(text &lt;String>, [options] &lt;GlobalOptions.tOptions>) => Promise&lt;Void>
46 // Function types can include parameter lists, returns and throws as well.
47 #transform&lt;T>( Function&lt;T>(payload &lt;T>) => &lt;T>, announce &lt;Bool>) => &lt;Bool>
12629849 48 // Listened Events
f752d89a 49 +>static_listener(parameters_expected &lt;Bool>)
12629849 50 ->instance_listener()
f752d89a 51 ~>network_events(peer &lt;Networking.Peer>)
12629849 52 // Emitted Events
f752d89a
RBR
53 &lt;+emitted_statically(payload &lt;StaticEventPayload>)
54 &lt;-emitted_by_instance(reason &lt;String>, code &lt;Int>)
55 &lt;~emitted_through_network(text &lt;String>)
b0ca5dae 56```