Simple Annotation
Simple Annotation is a module for nodejs. With this module you can easily add annotation to nodejs. This module is customizable. The module will search for comments in files and after this it search for your registered annotations.
Installation
npm i simple-annotation
Example
Example file with annotation.
/** * @AnnotationClassString AnnotationClassString * @AnnotationClassObject {"hello": 123} * @AnnotationClassArray [1234] * @AnnotationClassInt 12345 */ /** * @AnnotationES6Function AnnotationES6Function */ { return str; }moduleexports = test;
In this example we try to get the annotation with name AnnotationES6Function.
var Annotation = ; Annotation; var obj = ; // Important !! Add only absolute paths, relative paths will be ignored.obj; var all = obj;var one = obj; forvar i in all console;
Create Annotation
Annotation;
Value/Return Types
What are value or return types? A value type is the right hand of a annotation and a return type is the function/class/variable under the annotation.
/*** @AnnotationName ValueType*/module{ return str;};
All Preconfigured Types are overridable.
Return Types
Name | Type |
---|---|
ES6class | ECMA Script 6 Class |
ES6function | ECMA Script 6 Function |
function | <= ES5 Functions |
var | <= ES5 Functions Variable |
Annotation Value Types
Name | Type |
---|---|
string | string |
array | array |
object | object |
int | integer |
empty | empty string |
Preconfigured return types pattern
<= ES5 function
//Function 1module{ return str;}; //Function 2var { return str;};exportsmyTestFunction2 = myTestFunction2; //Function 3const myTestFunction3 = { return str;};exportsmyTestFunction3 = myTestFunction3; //Function 4let { return str;};exportsmyTestFunction5 = myTestFunction5; //Function 5exports { return str;};
<= ES5 variable
var testVar = "test123Variable";exportstestVar = testVar;
Create a Type
Value Type
var Annotation = ;Annotation;
Return Type
var Annotation = ;Annotation;
To Do
- Add findBy() function
- Refactoring (DRY, KISS, more Comments)