Skip to content
Snippets Groups Projects
Commit 045a8bf4 authored by Mathis Neumann's avatar Mathis Neumann
Browse files

documentation is itself a mock api

parent a8098d19
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,13 @@ To change this documentation:
3. change the `.md` (Markdown) files.
4. run `npm run build` to generate the HTML files in the `public/` directory.
If you want to have automatic building on file save, run `npm run develop` which will open a webserver on port 3000.
If you want to have automatic building on file save, run `npm run develop` which will open a webserver on port 3000. Note that this will not run the mock server (see below).
Note that the automatic building might not work on Windows maschines
Please note that `ignoring unrecognized block (warning code 5)` warnings occur for HTML comments `<!-- comment -->` which were used intentionally for better understand for documentation editors.
## Mock Service
If you want to change the behaviour, you will need to run `npm run build` in this directory.
This will generate files inside the `public/` directory, then run `node .` to serve then, including the api. This will start the server on `localhost:3000`.
\ No newline at end of file
//jshint globalstrict:true, esversion:6, node:true
'use strict';
const gulp = require('gulp');
const change = require('gulp-change');
const aglio = require('gulp-aglio');
const rename = require('gulp-rename');
const fs = require('fs');
gulp.task('resolveIncludes', function() {
return gulp.src('./src/main.md')
.pipe(change(replaceIncludes))
.pipe(gulp.dest('public/'));
});
gulp.task('aglio', function () {
gulp.src('src/main.md')
.pipe(aglio({ template: 'default' }))
.pipe(rename('index.html'))
.pipe(gulp.dest('public'));
});
gulp.task('default', ['aglio', 'resolveIncludes']);
// merges all files into one, because api blueprint does not specify include, but aglio does
function replaceIncludes(content) {
let newContent = content,
found;
const includePattern = /<!--\s*include\((.*.md)\)\s*-->/g;
const matches = [];
while (found = includePattern.exec(content)) {
matches.push(found);
includePattern.lastIndex = found.index+1;
}
matches.forEach(match => {
const fileName = match[1];
console.log('reading file', fileName, match[1]);
const fileContent = fs.readFileSync('./src/'+fileName);
newContent = newContent.replace(new RegExp('<!--\\s*include\\('+fileName+'\\)\\s*-->', 'g'), fileContent+'\n');
});
return newContent;
}
\ No newline at end of file
//jshint globalstrict:true, esversion:6, node:true
'use strict';
const koa = require('koa');
const koaStatic = require('koa-static');
const HTML_DIR = './public';
const PORT = process.env.PORT || 3000;
const app = koa();
app.use(koaStatic(HTML_DIR));
app.listen(PORT, () => {
console.log('running on port', PORT);
const drakov = require('drakov');
const argv = {
sourceFiles: 'public/main.md',
serverPort: PORT,
staticPaths: [
'public/=/'
],
discover: true,
disableCORS: true,
stealthMode: false,
delay: 50
};
drakov.run(argv, function(){
console.log('started on port', PORT);
});
\ No newline at end of file
......@@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "mkdir -p ./public && ./node_modules/.bin/aglio -i src/main.md -o public/index.html",
"build": "gulp",
"postinstall": "npm run build",
"develop": "./node_modules/.bin/aglio -i src/main.md --server"
},
......@@ -26,7 +26,10 @@
"license": "Apache",
"dependencies": {
"aglio": "^2.2.0",
"koa": "^1.2.0",
"koa-static": "^2.0.0"
"drakov": "^1.0.0",
"gulp": "^3.9.1",
"gulp-aglio": "0.0.10",
"gulp-change": "^1.0.0",
"gulp-rename": "^1.2.2",
}
}
......@@ -8,6 +8,10 @@ The API for visualising software architectures generated by the iObserve analysi
2. The `Meta Model Service` which is a read-only RESTful API to get retrieve all components of an architecture which is used by clients for visualisation.
3. A `Changelog Websocket Server` which clients (webbrowsers) can connect to to get new changelogs pushed whenever the `Changelog Parser` successfully applied a changelog.
## Mock-Server
Please note, that this documentation can also be used as a mock service which is automatically generated from the examples provided in this documentation.
Just use the current url as the base path (e.g. [/v1/systems/389cc862-177f-4fd8](/v1/systems/389cc862-177f-4fd8)). For more info, see the `README.md`.
## Changelog Constraints
To apply new changelogs, the sender (iObserve analysis) has to fullfill some contraints on changelogs.
These constraints guarantee the a client can request a valid state of the architecture at any point in time.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment