Code Monkey home page Code Monkey logo

conga-annotations's People

Contributors

createvibe avatar greenkeeperio-bot avatar jaumard avatar jvkassi avatar lampjunkie avatar mattlo avatar qiuzuhui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

conga-annotations's Issues

File annotations

I love this lib and would like to use it. I just have one question: Does it have file annotation support?

If at the top of your file, you place a docblock with annotations will it parse? Like this:

/**
 * @author RWOverdijk
 * @version 0.1.0
 */

Simple example

Hi,

I've just tried to run the example shown in the README file, but no matter how I've tried, it seems that the reader.get*Annotations() methods are always returning empty arrays. Could you give me a hint?

Thanks

Empty metadata when loading content

Hi,

I m actually trying to use your library to create my own annotations, but I cant make what I need.

In fact, I have a simple annotation :
var Annotation = require('conga-annotations').Annotation;

module.exports = Annotation.extend({

/**
 * The name of the annotation

 * @type {String}
 */
annotation: 'Inject',

/**
 * The possible targets
 *
 * (Annotation.CONSTRUCTOR, Annotation.PROPERTY, Annotation.METHOD)
 *
 * @type {Array}
 */
targets: [Annotation.PROPERTY],

/**
 * The main value
 *
 * @type {String}
 */
value: 'default value',

/**
 * An additional attribute
 *
 * @type {String}
 */
sample: 'default value for sample',

/**
 * Optional initialization method that
 * can be used to transform data
 *
 * @param  {Object} data
 * @return {void}
 */
init: function (data) {
    // do something with data
    console.log(data);
}

});

And here's my parser :
var path = require('path');
var annotations = require('conga-annotations');

// create the registry
var registry = new annotations.Registry();

// add annotations to the registry
registry.registerAnnotation(path.join(__dirname, 'annotations', 'InjectAnnotation'));

// create the annotation reader
var reader = new annotations.Reader(registry);

// parse the annotations from a file
reader.parse(path.join(__dirname, 'FileToParse.js'));

// get the annotations
var propertyAnnotations = reader.getPropertyAnnotations();
console.log(propertyAnnotations);
// loop through and handle the annotations
propertyAnnotations.forEach(function (annotation) {

// @MyConstructorAnnotation
if (annotation.annotation === 'Inject') {

    // do something with the annotation data
    console.log(annotation.target); // -> "MySample"
    console.log(annotation.value); // -> "some value"
    console.log(annotation.sample); // -> "here is an attribute value"
}

});

When I try to log the _metadata in reader.js line 103, it seems that it' fully empty and giving me this :

{ methods: [],
properties: [],
fileComment: '/**',
path: 'F:\AnnotationLibrary\FileToParse.js' }

Is this a problem with the current version or am I doing it wrong ?

CRLF vs LF

Thanks for the parser. It's working perfectly for my needs except for one issue.

On Windows with JavaScript files containing line endings of CRLF the parser fails to find any annotations. If I change the line endings to LF it works fine.

Support

Hello,

I'd like to ask if this repo is maintained, if there is any chances a PR would be reviewed and merged if passes the review.
Sorry for creating an issue for this.

Invalid or unexpected token SyntaxError with commas inside annotations

If I have an annotation with commas within the quoted string I get a SyntaxError (stack below). This happens in both 1.0.0 & 1.0.1.

SyntaxError: Invalid or unexpected token
    at Object.exports.runInContext (vm.js:66:16)
    at AttributeParser.<anonymous> (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\attribute-parser.js:165:14)
    at Array.forEach (native)
    at AttributeParser.parse (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\attribute-parser.js:124:11)
    at Reader.parseAnnotations (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\reader.js:260:45)
    at Reader.parseMethodAnnotations (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\reader.js:131:17)
    at Reader.<anonymous> (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\reader.js:81:39)

    at Array.forEach (native)
    at Reader.parse (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\node_modules\@conga\annotations\lib\reader.js:80:15)
    at parseStepDefinition (d:\Glass\GLASS-vc12-trunk\test\cucumber\doc\parser.js:219:9)

ES6/ES2015 support ?

There two questions here ^^ first, annotations works under ES2015 classes ?
Want to do something like:

'use strict'

const Controller = require('controller')

/**
 * @MyClass("DefaultController")
 * @description Default Controller 
 */
module.exports = class DefaultController extends Controller {

  /**
   * Return some info 
   * @MyAnnotation("toto")
   */
  info (request, reply) {

  }
}

Second question is, there any plan for migrate Annotations to classes instead of object ?

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.