2 --- description: API Notation
5 API 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.
8 The notation allows describing objects or modules, with properties, events and methods along with their types.
10 // Anything after two forward slashes is a comment
11 NameOfClass.WithPossibleNamespace
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)
31 With this artificial example, you can see how to use it for more complex cases:
34 // Definitions start with object / module / class names, with namespaces
35 // separated by periods. Types are marked between angular brackets.
36 Definitions.Models.Post
38 +static_property <Type>
39 -instance_property <Types<Can<Be<Nested>>>>
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.
44 ::static_methods(parameter_label <Type>) => ReturnValueType #> BadTimesException,UnknownError
45 #update(text <String>, [options] <GlobalOptions.tOptions>) => Promise<Void>
46 // Function types can include parameter lists, returns and throws as well.
47 #transform<T>( Function<T>(payload <T>) => <T>, announce <Bool>) => <Bool>
49 +>static_listener(parameters_expected <Bool>)
51 ~>network_events(peer <Networking.Peer>)
53 <+emitted_statically(payload <StaticEventPayload>)
54 <-emitted_by_instance(reason <String>, code <Int>)
55 <~emitted_through_network(text <String>)