-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate api html doc from multiple raml
- Loading branch information
1 parent
16f5497
commit 737837c
Showing
7 changed files
with
1,008 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
@import 'variables'; | ||
|
||
|
||
|
||
// application wide styles and overrides | ||
@import 'global'; | ||
@import 'overrides'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
var _ = require('lodash'); | ||
var raml2html = require('raml2html'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise = require('bluebird'); | ||
|
||
var configWithDefaultTemplates = raml2html.getDefaultConfig(); | ||
console.log('raml2html: ', configWithDefaultTemplates); | ||
//var configWithCustomTemplates = raml2html.getDefaultConfig('my-custom-template.nunjucks', __dirname); | ||
var source = ['./src/plugins/users/user/raml/users.raml'] | ||
// source can either be a filename, url, file contents (string) or parsed RAML object | ||
raml2html.render(source, configWithDefaultTemplates).then(function(result) { | ||
// Save the result to a file or do something else with the result | ||
console.log('raml2html done: ', result); | ||
}, function(error) { | ||
// Output error | ||
console.error(error) | ||
}); | ||
|
||
var sources = [ | ||
'api.raml', | ||
'users/raml/users.raml', | ||
'dbSchema/raml/db.explorer.raml' | ||
]; | ||
|
||
sources = _.map(sources, function(source){ | ||
return path.join(__dirname, '/../src/plugins', source) | ||
}) | ||
|
||
var outputPath = 'build'; | ||
console.log('sources: ', sources); | ||
Promise.all(_.map(sources, function(source){ | ||
//console.log('raml2html in: ', source); | ||
return raml2html.render(source, configWithDefaultTemplates).then(function(result) { | ||
//console.log('raml2html result: ', result); | ||
var outputFile = path.basename(source, '.raml'); | ||
let resultFilename = path.join(outputPath, outputFile + ".html"); | ||
console.log('raml2html writing to file: ', resultFilename); | ||
fs.writeFileSync(resultFilename, result); | ||
}, function(error) { | ||
// Output error | ||
console.error(error); | ||
throw error; | ||
}); | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Welcome to the API documentation. | ||
|
||
* [Users API](users.html) | ||
* [Database explorer API](db.explorer.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#%RAML 0.8 | ||
--- | ||
title: Starhackit | ||
baseUri: http://localhost | ||
version: v1 | ||
protocols: [ HTTP, HTTPS ] | ||
documentation: | ||
- title: Summary | ||
content: !include api.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#%RAML 0.8 | ||
--- | ||
title: Starhackit | ||
baseUri: http://localhost:8080/api/v1/db | ||
version: v1 | ||
mediaType: application/json | ||
protocols: [ HTTP, HTTPS ] | ||
documentation: | ||
- title: Database Explorer REST API | ||
content: 'Database Explorer REST API documentation' | ||
|
||
/schema: | ||
description: Get the database schema | ||
get: | ||
responses: | ||
200: | ||
body: | ||
example: !include db.schema.out.sample.json |
Oops, something went wrong.