Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit f8c9f73

Browse files
committed
Merge pull request #51 from apiaryio/shared/attributes-description
Attributes description
2 parents 7d25ee8 + cf9f9e3 commit f8c9f73

28 files changed

+1175
-1304
lines changed

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,39 @@ node_modules/
2121
.cproject
2222
.project
2323
.settings
24+
25+
# OS X and Xcode specific
26+
.DS_Store
27+
build/
28+
*.pbxuser
29+
!default.pbxuser
30+
*.mode1v3
31+
!default.mode1v3
32+
*.mode2v3
33+
!default.mode2v3
34+
*.perspectivev3
35+
!default.perspectivev3
36+
*.xcodeproj/*.xcworkspace
37+
xcuserdata
38+
xcshareddata
39+
profile
40+
*.moved-aside
41+
DerivedData
42+
.idea/
43+
44+
# Generated files
45+
config.mk
46+
config.gypi
47+
bin/
48+
vendor/
49+
.vagrant/
50+
tmp/
51+
52+
# Ruby
53+
.bundle/
54+
features/support/env-win.rb
55+
56+
# Eclipse specific
57+
.cproject
58+
.project
59+
.settings

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "snowcrash"]
2-
path = snowcrash
3-
url = https://github.com/apiaryio/snowcrash.git
1+
[submodule "drafter"]
2+
path = drafter
3+
url = https://github.com/apiaryio/drafter.git

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: node_js
2+
node_js:
3+
- "0.12"
4+
- "0.11"
5+
- "0.10"
6+
- "0.8"
7+
- iojs
8+
script: "npm install && npm test"
9+
before_install:
10+
- git submodule update --init --recursive
11+
- ruby -e "\`npm i -g npm\` if '`npm -v`'<'2.0.0'"
12+
notifications:
13+
email:
14+
recipients:
15+
- z@apiary.io
16+
on_success: change
17+
on_failure: always
18+
hipchat:
19+
rooms:
20+
secure: "ZRKSctculEtR03uTxeUjWxQ8lDeC3v7hJJrmPS7JDGPBlzpzlJau1NHu3Zex\nkKWmKHH29t6otZ5tAWF3THDdUssk5VbIRMCpoEEVMJeHuBZijje7nwk2JZR/\ncPwNsIZ4keaAxujh9BBWC0i+PbkrTRxhrzIHTntawInL33ZQP9Q="
21+
template:
22+
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (<a href="%{build_url}">Details</a>/<a href="%{compare_url}">Change view</a>)'
23+
format: html

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# Protagonist
44

5-
[![Circle CI](https://circleci.com/gh/apiaryio/protagonist.svg?style=svg)](https://circleci.com/gh/apiaryio/protagonist)
6-
[![AppVeyor](https://ci.appveyor.com/api/projects/status/8ny3ffe2xf40yn22/branch/master?svg=true)](https://ci.appveyor.com/project/zdne/protagonist/branch/master)
5+
[![Circle CI](https://circleci.com/gh/apiaryio/protagonist.svg?style=shield)](https://circleci.com/gh/apiaryio/protagonist)
6+
[![AppVeyor](https://ci.appveyor.com/api/projects/status/uaa6ivk97urmoucr?svg=true)](https://ci.appveyor.com/project/Apiary/protagonist)
7+
78

89

910
### API Blueprint Parser for Node.js
@@ -18,6 +19,8 @@ The best way to install Protagonist is by using its [NPM package](https://npmjs.
1819
$ npm install protagonist
1920
```
2021

22+
Works smoothly with node.js ~0.8.15, 0.10.x, 0.12.x and iojs v1.x.x
23+
2124
## Getting started
2225

2326
```js
@@ -47,7 +50,7 @@ will produce the following object (`result` variable):
4750
```json
4851
{
4952
"ast": {
50-
"_version": "2.1",
53+
"_version": "3.0",
5154
"metadata": [],
5255
"name": "",
5356
"description": "",
@@ -110,7 +113,7 @@ will produce the following object (`result` variable):
110113

111114
+ `ast` ... This is the abstract syntax tree (AST) of the parsed blueprint.
112115

113-
The structure under this key is **1:1** with the [AST Blueprint serialization JSON media type v2.1](https://github.com/apiaryio/api-blueprint-ast#json-serialization)`vnd.apiblueprint.ast.raw+json; version=2.1`.
116+
The structure under this key is **1:1** with the [AST Blueprint serialization JSON media type v3.0](https://github.com/apiaryio/api-blueprint-ast#example-json-serialization)`vnd.apiblueprint.ast.raw+json; version=3.0`.
114117

115118
+ `warnings` ... Array of the parser warnings as occurred during the parsing
116119
+ `code` ... Warning [group](https://github.com/apiaryio/snowcrash/blob/master/src/SourceAnnotation.h#L128) code
@@ -137,6 +140,7 @@ Protagonist uses [node-gyp](https://github.com/TooTallNate/node-gyp) build tool.
137140
$ git clone git://github.com/apiaryio/protagonist.git
138141
$ cd protagonist
139142
$ git submodule update --init --recursive
143+
$ npm install
140144
```
141145

142146
3. Build:
@@ -150,7 +154,6 @@ Protagonist uses [node-gyp](https://github.com/TooTallNate/node-gyp) build tool.
150154
Inside the protagonist repository run:
151155

152156
```sh
153-
$ npm install
154157
$ npm test
155158
```
156159

binding.gyp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@
66
{
77
"target_name": "protagonist",
88
"include_dirs": [
9-
"./snowcrash/src",
10-
"./snowcrash/ext/markdown-parser/src",
11-
"./snowcrash/ext/markdown-parser/ext/sundown/src",
12-
"./snowcrash/ext/markdown-parser/ext/sundown/html",
9+
"drafter/src",
10+
"drafter/ext/snowcrash/src",
11+
"drafter/ext/snowcrash/ext/markdown-parser/src",
12+
"drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src",
13+
"drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html",
14+
"drafter/ext/sos/src",
15+
"<!(node -e \"require('nan')\")"
1316
],
1417
"sources": [
1518
"src/annotation.cc",
16-
"src/blueprint.cc",
17-
"src/sourcemap.cc",
1819
"src/parse.cc",
1920
"src/protagonist.cc",
2021
"src/protagonist.h",
21-
"src/result.cc"
22+
"src/result.cc",
23+
"src/v8_wrapper.cc"
2224
],
2325
"dependencies": [
24-
"./snowcrash/snowcrash.gyp:libsnowcrash",
25-
"./snowcrash/snowcrash.gyp:libmarkdownparser",
26-
"./snowcrash/snowcrash.gyp:libsundown"
26+
"drafter/drafter.gyp:libdrafter",
27+
"drafter/ext/snowcrash/snowcrash.gyp:libsnowcrash",
28+
"drafter/ext/snowcrash/snowcrash.gyp:libmarkdownparser",
29+
"drafter/ext/snowcrash/snowcrash.gyp:libsundown",
30+
"drafter/drafter.gyp:libsos"
2731
]
2832
}
2933
]

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
'variables': {
1212
'target_arch%': 'ia32',
13-
'libsnowcrash_type%': 'static_library'
13+
'libdrafter_type%': 'static_library'
1414
},
1515
'target_defaults': {
1616
'configurations': {

drafter

Submodule drafter added at 92f2676

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "protagonist",
3-
"version": "0.17.2",
3+
"version": "0.19.0",
44
"description": "API Blueprint Parser",
55
"author": "Apiary.io <support@apiary.io>",
66
"main": "./build/Release/protagonist",
@@ -11,6 +11,9 @@
1111
"engines": {
1212
"node": ">=0.8.15"
1313
},
14+
"dependencies": {
15+
"nan": "~1.6.x"
16+
},
1417
"devDependencies": {
1518
"coffee-script": "~1.6.0",
1619
"mocha": "~1.17.1",

snowcrash

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/annotation.cc

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,44 @@ Persistent<Function> SourceAnnotation::constructor;
1616

1717
void SourceAnnotation::Init(Handle<Object> exports)
1818
{
19-
HandleScope scope;
19+
NanScope();
2020

21-
Local<FunctionTemplate> t = FunctionTemplate::New(New);
21+
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
22+
t->SetClassName(NanNew<String>("SourceAnnotation"));
2223
t->InstanceTemplate()->SetInternalFieldCount(1);
23-
t->SetClassName(String::NewSymbol("SourceAnnotation"));
2424

25-
constructor = Persistent<Function>::New(t->GetFunction());
26-
exports->Set(String::NewSymbol("SourceAnnotation"), constructor);
25+
NanAssignPersistent<Function>(constructor, t->GetFunction());
26+
exports->Set(NanNew<String>("SourceAnnotation"), t->GetFunction());
2727
}
2828

29-
Handle<Value> SourceAnnotation::New(const Arguments& args)
29+
NAN_METHOD(SourceAnnotation::New)
3030
{
31-
HandleScope scope;
31+
NanScope();
32+
3233
SourceAnnotation* annotation = ::new SourceAnnotation();
3334
annotation->Wrap(args.This());
34-
return scope.Close(args.This());
35-
}
3635

37-
Handle<Value> SourceAnnotation::NewInstance()
38-
{
39-
HandleScope scope;
40-
Local<Object> instance = constructor->NewInstance();
41-
return scope.Close(instance);
36+
NanReturnValue(args.This());
4237
}
4338

4439
static Local<Object> WrapSourceCharactersRange(const mdp::CharactersRange& range)
4540
{
46-
Local<Object> rangeObject = Object::New();
41+
Local<Object> rangeObject = NanNew<Object>();
4742

48-
rangeObject->Set(String::NewSymbol("index"), Number::New(range.location));
49-
rangeObject->Set(String::NewSymbol("length"), Number::New(range.length));
43+
rangeObject->Set(NanNew<String>("index"), NanNew<Number>(range.location));
44+
rangeObject->Set(NanNew<String>("length"), NanNew<Number>(range.length));
5045
return rangeObject;
5146
}
5247

5348
Local<Object> SourceAnnotation::WrapSourceAnnotation(const snowcrash::SourceAnnotation& annotation)
5449
{
55-
Local<Object> annotationWrap = constructor->NewInstance();
50+
Local<Function> cons = NanNew<Function>(constructor);
51+
Local<Object> annotationWrap = cons->NewInstance();
5652

57-
annotationWrap->Set(String::NewSymbol("code"), Number::New(annotation.code));
58-
annotationWrap->Set(String::NewSymbol("message"), String::New(annotation.message.c_str()));
53+
annotationWrap->Set(NanNew<String>("code"), NanNew<Number>(annotation.code));
54+
annotationWrap->Set(NanNew<String>("message"), NanNew<String>(annotation.message.c_str()));
5955

60-
Local<Object> location = Array::New(annotation.location.size());
56+
Local<Object> location = NanNew<Array>(annotation.location.size());
6157
size_t i = 0;
6258
for (mdp::CharactersRangeSet::const_iterator it = annotation.location.begin();
6359
it != annotation.location.end();
@@ -66,6 +62,6 @@ Local<Object> SourceAnnotation::WrapSourceAnnotation(const snowcrash::SourceAnno
6662
location->Set(i, WrapSourceCharactersRange(*it));
6763
}
6864

69-
annotationWrap->Set(String::NewSymbol("location"), location);
65+
annotationWrap->Set(NanNew<String>("location"), location);
7066
return annotationWrap;
7167
}

0 commit comments

Comments
 (0)