congajs / conga-annotations Goto Github PK
View Code? Open in Web Editor NEWAnnotation parser library for node.js
License: Other
Annotation parser library for node.js
License: Other
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
*/
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
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 ?
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.
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.
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)
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.