Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 13 additions & 47 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,48 +1,14 @@
{
"browser" : true,
"devel" : true,
"jquery" : true,
"couch" : false,
"es5" : false,
"node" : true,
"rhino" : false,
"prototypejs" : false,
"mootools" : false,

"asi" : false,
"bitwise" : false,
"boss" : false,
"curly" : true,
"debug" : false,
"eqeqeq" : true,
"eqnull" : true,
"evil" : false,
"forin" : false,
"immed" : true,
"laxbreak" : false,
"maxerr" : 100,
"maxlen" : 0,
"newcap" : true,
"noarg" : true,
"noempty" : false,
"nonew" : false,
"nomen" : false,
"onevar" : false,
"passfail" : false,
"plusplus" : false,
"regexp" : false,
"undef" : false,
"unused" : "vars",
"sub" : true,
"strict" : true,
"globalstrict": true,
"white" : true,
"expr" : true,
"smarttabs": true,
"predef" : [
"describe",
"it",
"beforeEach",
"afterEach"
]
}
"globals": [
"exports"
],
"eqnull": true,
"expr": true,
"noarg": true,
"node": true,
"trailing": true,
"unused": true,
"laxbreak": true,
"laxcomma": true,
"browser": true
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ Generate from included example data
apidoc-markdown -p examples -o examples/example.md


[View generated example](https://github.com/martinj/node-apidoc-markdown/blob/master/examples/example.md)
[View generated example](https://github.com/martinj/node-apidoc-markdown/blob/master/examples/example.md)
## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y
36 changes: 36 additions & 0 deletions bin/apidoc-markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs'),
path = require('path'),
optimist = require('optimist'),
apidocMarkdown = require('..');

var join = path.join;

var argv = optimist
.usage('Generate markdown documentation from apidoc data.' + '\n' +
'Usage: apidoc-markdown -p [path] -o [output file]')
.demand(['output'])
.alias({
'path': 'p',
'output': 'o',
'template': 't'
})
.describe({
path: 'Path to generated apidoc output. Where api_data.json & api_project.json resides.',
output: 'Output file to write.',
template: 'Path to EJS template file, if not specified the default template will be used.',
prepend: 'Prepend file after TOC'
}).argv;

var apidocRoot = argv.path || join(process.cwd(), 'doc');

var dataPath = join(apidocRoot, 'api_data.json'),
templatePath = argv.template,
projectPath = join(apidocRoot, 'api_project.json'),
prependPath = argv.prepend;

var markdown = apidocMarkdown(dataPath, projectPath, templatePath, prependPath);

fs.writeFileSync(argv.output, markdown);
console.log('Wrote apidoc-markdown to: ' + argv.output);
10 changes: 5 additions & 5 deletions examples/api_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
},
"examples": [
{
"title": " Response (example):",
"title": "Response (example):",
"content": " HTTP/1.1 400 Bad Request\n {\n \"error\": \"UserNameTooShort\"\n }\n"
}
]
Expand Down Expand Up @@ -325,7 +325,7 @@
},
"examples": [
{
"title": " Response (example):",
"title": "Response (example):",
"content": " HTTP/1.1 400 Bad Request\n {\n \"error\": \"UserNameTooShort\"\n }\n"
}
]
Expand Down Expand Up @@ -373,7 +373,7 @@
},
"examples": [
{
"title": " Response (example):",
"title": "Response (example):",
"content": " HTTP/1.1 400 Bad Request\n {\n \"error\": \"UserNameTooShort\"\n }\n"
}
]
Expand Down Expand Up @@ -408,7 +408,7 @@
},
"examples": [
{
"title": " Response (example):",
"title": "Response (example):",
"content": " HTTP/1.1 400 Bad Request\n {\n \"error\": \"UserNameTooShort\"\n }\n"
}
]
Expand All @@ -425,4 +425,4 @@
"url": "",
"filename": "example/example.js"
}
]
]
64 changes: 36 additions & 28 deletions examples/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

apidoc example project

- [User](#user)
- [Read data of a User](#read-data-of-a-user)
- [Create a new User](#create-a-new-user)
- [Change a new User](#change-a-new-user)

- [example/example.js](#example-example-js)
- [Read data of a User](#read-data-of-a-user)
- [Create a new User](#create-a-new-user)
- [Change a new User](#change-a-new-user)


# User
# example/example.js

## Read data of a User

Compare Verison 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0.

GET /user/:id
`GET /user/:id`

### Parameters
| Name | Type | Description |
|------|------|-------------|
| `id` | _String_ | The Users-ID. |

### Success Parameters

| Name | Type | Description |
|---------|-----------|--------------------------------------|
| id | String | The Users-ID. |
#### Success 200
| Name | Type | Description |
|------|------|-------------|
| `id` | _String_ | The Users-ID. |
| `registered` | _Date_ | Registration Date. |
| `name` | _Date_ | Fullname of the User. |

### Examples

CURL example:

```
curl -i -X POST http://localhost:3001/example
-H 'Content-Type: application/json' \
Expand All @@ -37,7 +42,6 @@ CURL example:
### Success Response

Success-Response (example):

```
HTTP/1.1 200 OK
{
Expand All @@ -47,62 +51,66 @@ Success-Response (example):
}

```

### Error Response

Error-Response (example):

```
HTTP/1.1 401 Not Authenticated
{
"error": "NoAccessRight"
}

```

## Create a new User

In this case "apiErrorStructure" is defined and used.
Define blocks with params that will be used in several functions, so you dont have to rewrite them.

POST /user
`POST /user`

### Parameters
| Name | Type | Description |
|------|------|-------------|
| `name` | _String_ | Name of the User. |

| Name | Type | Description |
|---------|-----------|--------------------------------------|
| name | String | Name of the User. |
### Success Parameters

### Error Response
#### Success 200
| Name | Type | Description |
|------|------|-------------|
| `id` | _String_ | The new Users-ID. |

Response (example):
### Error Response

Response (example):
```
HTTP/1.1 400 Bad Request
{
"error": "UserNameTooShort"
}

```

## Change a new User

This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure"

PUT /user/:id
`PUT /user/:id`

### Parameters

| Name | Type | Description |
|---------|-----------|--------------------------------------|
| name | String | Name of the User. |
| Name | Type | Description |
|------|------|-------------|
| `name` | _String_ | Name of the User. |

### Error Response

Response (example):

Response (example):
```
HTTP/1.1 400 Bad Request
{
"error": "UserNameTooShort"
}

```

59 changes: 0 additions & 59 deletions index.js

This file was deleted.

Loading