Giter Club home page Giter Club logo

node-annotation's Introduction

#node-annotation - 0.1

This is the first early release for this library. It's purpose is to add annotations support to JavaScript, were you will be able to relate commands to your class, method or property, based on the comments of your file.

##How it Works

To the lib work properly in this version, you will need to write your comments like the example below:

/**
 * annotationName(annotationValue);
 */

Each annotation should follow this structure, where a name must be defined (it can be any name, unless isn't a reserved one). Also there is some predefined annotationsName that will automatically insert annotations in one of the namespaces of the library.

Those predefined names are: Class, Method and Property, and as you can imagine, it is used to define what annotations belongs to the class, properties and so on.

It's important to notice the presence of (;) ... this is needed to split all the annotations correctly, even when there is just one.

###Annotation Value

The annotation value should be a valid type of JavaScript or a JSON object.

##Example Usage

var annotation = require('annotation');

annotation(fullFilePath, function(AnnotationReader) {
    //get annotations related to the class
    console.log(AnnotationReader.getClassAnnotations());

    //get annotations related to the method test
    console.log(AnnotationReader.getMethodAnnotations('test'));

    //get annotations related to the property test
    console.log(AnnotationReader.getPropertyAnnotations('test'));
});

Example of the commented file:

/**
 * @Class();
 * @shouldBeImported();
 * @parse(
 *     {
 *      "hehe": "test",
 *      "foo": {
 *          "value": "bar"
 *      }
 *     }
 * );
 */
var ClassFoo = function() {
    /**
     * @Property("test");
     * @test("test");
     * @type {string}
     */
    this.name = 'test';
}

/**
 * @Method("test");
 * @testing("test");
 */
ClassFoo.prototype.test = function() {}

node-annotation's People

Contributors

gquental avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.