Skip to content

Commit 671280a

Browse files
author
Spencer Alger
committed
added api.md generation [ci skip]
1 parent 7905d9b commit 671280a

File tree

10 files changed

+1185
-33119
lines changed

10 files changed

+1185
-33119
lines changed

dist/elasticsearch.angular.js

Lines changed: 0 additions & 16297 deletions
This file was deleted.

dist/elasticsearch.angular.min.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

dist/elasticsearch.js

Lines changed: 0 additions & 16301 deletions
This file was deleted.

dist/elasticsearch.min.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/api.md

Lines changed: 974 additions & 375 deletions
Large diffs are not rendered by default.

docs/errors.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Errors
2+
3+
These are the standard Error types which may be passed back from the client. To access the constructors access the errors module via `require('elasticsearch').errors`.
4+
5+
## ConnectionFault
6+
The connection was unable to initiate or complete a request with the Elasticsearch node.
7+
8+
## NoConnections
9+
All of the connections in the ConnectionPool are dead.
10+
11+
## RequestTimeout
12+
The request timed-out.
13+
14+
## Serialization
15+
The response received from Elasticsearch could not be deserilaized.
16+
17+
## 503 or ServiceUnavailable
18+
Elasticsearch responded with a 503 status.
19+
20+
## 500 or InternalServerError
21+
Elasticsearch responded with a 500 status.
22+
23+
## 412 or PreconditionFailed
24+
Elasticsearch responded with a 412 status.
25+
26+
## 409 or Conflict
27+
Elasticsearch responded with a 409 status.
28+
29+
## 403 or Forbidden
30+
Elasticsearch responded with a 403 status.
31+
32+
## 404 or NotFound
33+
Elasticsearch responded with a 404 status.
34+
35+
## 400 or BadRequest
36+
Elasticsearch responded with a 400 status.
37+
38+
## Generic
39+
Elasticsearch responded with a status that does not map to it's own error type.

scripts/generate/js_api/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var clean = require('../../clean');
88
var urlParamRE = /\{(\w+)\}/g;
99

1010
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
11+
var docOutputPath = _.joinPath(__dirname, '../../../docs/api.md');
1112

1213
function download() {
1314
require('./actions').on('ready', function (actions) {
@@ -27,6 +28,9 @@ function download() {
2728
actions: actions,
2829
namespaces: _.unique(namespaces.sort(), true)
2930
}));
31+
fs.writeFileSync(docOutputPath, templates.apiDocs({
32+
actions: actions
33+
}));
3034
});
3135
}
3236

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# API
2+
3+
## Table Of Contents
4+
5+
<%
6+
7+
function esc(str) {
8+
return str.replace(/\|/g, '&#124;');
9+
}
10+
11+
var _paramWithDefault = paramWithDefault;
12+
paramWithDefault = function (name, _default) {
13+
return esc(_paramWithDefault(name, _default));
14+
};
15+
16+
var _paramType = paramType;
17+
paramType = function (type) {
18+
return esc(_paramType(type));
19+
};
20+
21+
_.each(actions, function (action) {%>
22+
- [<%= action.name %>](#<%= action.name.toLowerCase().replace(/[^\w]/g, '') %>)<%
23+
})
24+
25+
_.each(actions, function (action) {
26+
%>
27+
28+
### <%= action.name %>()
29+
30+
<%= action.docUrl %>
31+
32+
| Name | Type | Description |
33+
| ---- | ---- | ----------- |
34+
<%
35+
_.each(action.allParams, function(param, paramName) {
36+
%>|`<%= paramWithDefault(paramName, param.default) %>` | <%= paramType(param.type) %> | <%= esc(param.description || '') %>|
37+
<% })
38+
39+
}); %>

scripts/generate/js_api/templates/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ var templateGlobals = {
8787
paramType: function (type) {
8888
switch (type && type.toLowerCase ? type.toLowerCase() : 'any') {
8989
case 'time':
90-
return 'Date|Number';
90+
return 'Date or Number';
9191
case 'any':
9292
return '*';
9393
case 'enum':
9494
return 'String';
9595
case 'list':
96-
return 'String|ArrayOfStrings|Boolean';
96+
return 'String or String[] or Boolean';
9797
default:
9898
return _.ucfirst(type);
9999
}
@@ -125,5 +125,6 @@ fs.readdirSync(path.resolve(__dirname)).forEach(function (filename) {
125125
templates.text = templates.string;
126126

127127
module.exports = {
128-
apiFile: templates.api_file
128+
apiFile: templates.api_file,
129+
apiDocs: templates.api_docs
129130
};

src/lib/api.js

Lines changed: 125 additions & 125 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)