]> git.r.bdr.sh - rbdr/r.bdr.sh/blobdiff - api.gmi
Add old reference back
[rbdr/r.bdr.sh] / api.gmi
diff --git a/api.gmi b/api.gmi
index 3e4860767fe0f51866e7c4ca3d7bf366db24eb29..d0d99ad5285587383853068ca6e3e386174135ec 100644 (file)
--- a/api.gmi
+++ b/api.gmi
@@ -2,9 +2,10 @@
 --- description: API Notation
 # API Notation
 
-The following document attempts to define a legend for easy specification of APIs for components. Any suggestions to improve are welcome.
+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.
 
 ```
+// Anything after two forward slashes is a comment
 NameOfClass.WithPossibleNamespace
    + class property
    - instance property
@@ -16,40 +17,45 @@ NameOfClass.WithPossibleNamespace
   <- dispatched events (instance)
   :: class method
    # instance method
-   
+
 Other symbols
   => returns
-->() callback return
+  #> throws
 [xx] optional
 <xx> data type
 
-Recommended order: class first, then sockets, then instance. Internally: Properties, events, methods.
-
-// Anything after two forward slashes is a comment
+Recommended order: class first, then sockets, then instance. Internally:
+Properties, events, methods.
 ```
 
-Here's an example of usage
+Or, with some examples:
 
 ```
-HypotheticalModule
-  +staticProperty <String>
-  +anotherStaticProperty <Boolean>
-  ::toggleAnotherStaticProperty()
-  ::setStaticProperty(newValue <String>)
-  -instanceProperty <Number>
-  -anotherInstanceProperty <String>
-  #instanceMethodSync([optionalParameter]<Boolean>) => resultOfCall <String>
-  #instanceMethodAsync(someValue <Number>, [callback] <Function>) ->(error <String|null>, result <Number|null>)
+// Definitions start with object / module / class names, with namespaces
+// separated by periods. Types are marked between angular brackets.
+Definitions.Models.Post
+  // Properties.
+  +static_property <Type>
+  -instance_property <Types<Can<Be<Nested>>>>
+  // Methods. Parameters are listed in parentheses, and comma separated.
+  // Optional values are inside brackets
+  // => defines return values
+  // #> defines thrown exceptions, can be comma separated.
+  ::static_methods(parameter_label <Type>) => ReturnValueType #> BadTimesException,UnknownError
+  #update(text <String>, [options] <GlobalOptions.tOptions>) => Promise<Void>
+  // Listened Events
+  +>static_listener(parameters_expected <Bool>)
+  ->instance_listener()
+  ~>network_events(peer <Networking.Peer>)
+  // Emitted Events
+  <+emitted_statically(payload <StaticEventPayload>)
+  <-emitted_by_instance(reason <String>, code <Int>)
+  <~emitted_through_network(text <String>)
 ```
 
-Here's another example but with events.
+When defining function types, you may use parameter lists, returns and throws notation as well.
 
 ```
-EventHypotheticalClass
-  +>AnotherClass<+staticEventToListen(eventData <PredefinedObject>)
-  <+staticEventDispatched(someData <SomeData>)
-  ~>listenedSocketEvent(eventData <SomeObject>)
-  <~dispatchedSocketEvent(eventData <BlaBla>)
-  ->AnotherClass<-instanceEventToListen(eventData <Object>)
-  <-instanceEventDispatched(specificDataType <DefinedObject>)
+HypotheticalModule
+  #transform<T>( Function<T>(payload <T>) => <T>, announce <Bool>) => <Bool>
 ```