violin-annotationsdeprecated

Annotation parser for Node.js

Usage no npm install needed!

<script type="module">
  import violinAnnotations from 'https://cdn.skypack.dev/violin-annotations';
</script>

README

violin-annotations

Annotation parser for Node.js

Installation

npm install violin-annotations

Will install the latest version of violin-annotations

Example

// ClassAnnotation.js

var util = require("util");

var Annotation = require("violin-annotations").Annotation,
    Target = require("violin-annotations").Target;

function ClassAnnotation(parameters) {
    Annotation.call(this, parameters);
}
util.inherits(ClassAnnotation, Annotation);

/**
 * Sample attribute
 */
ClassAnnotation.prototype.sample = "Hello world !";

ClassAnnotation.getTargets = function () {
    return [
        Target.CLASS_ANNOTATION
    ];
};

/**
 * @inheritDoc
 */
ClassAnnotation.getName =
    ClassAnnotation.prototype.getName = function () {
        return "ClassAnnotation";
    };

module.exports = ClassAnnotation;
// MyClass.js

/**
 * @ClassAnnotation(sample="Hello annotations")
 */
function MyClass() {

}

module.exports = MyClass;
var Parser = require("violin-annotations"),
    parser = new Parser();

parser.getRegistry().registerAnnotationFile("ClassAnnotation.js");

parser.parseFile("MyClass.js", function (annotations) {
    console.log(annotations);
});