Skip to content

Instantly share code, notes, and snippets.

@zaki-yama
Created July 14, 2015 15:45
Show Gist options
  • Select an option

  • Save zaki-yama/2ceeff12878de98fa762 to your computer and use it in GitHub Desktop.

Select an option

Save zaki-yama/2ceeff12878de98fa762 to your computer and use it in GitHub Desktop.
aglioを使ったAPIドキュメント作成用のgulpfile
# ディレクトリ構成
├── apidocs
│ ├── api.md
│ ├── layout.md
│ └── questions.md
├── gulpfile.js
├── package.json
└── published
├── index.html
└── index.md
var gulp = require('gulp'),
aglio = require('gulp-aglio'),
browserSync = require('browser-sync'),
rename = require('gulp-rename'),
rimraf = require('rimraf'),
ejs = require('gulp-ejs');
var reload = browserSync.reload;
var TEMPLATE_FILES = ['apidocs/**/*.md'],
LAYOUT_FILE = 'apidocs/layout.md',
PUBLISHED_DIR = 'published';
gulp.task('combine', function(){
return gulp.src(LAYOUT_FILE)
.pipe(ejs({},{ ext: '.md' }))
.pipe(rename('index.md'))
.pipe(gulp.dest(PUBLISHED_DIR));
});
gulp.task('generate-api-docs', ['combine'], function() {
return gulp.src(PUBLISHED_DIR + '/index.md')
.pipe(aglio({template: 'default'}))
.pipe(gulp.dest(PUBLISHED_DIR));
});
gulp.task('watch', function () {
gulp.watch(TEMPLATE_FILES, ['generate-api-docs', reload]);
});
gulp.task('browserSync', function() {
browserSync({
logConnections: true,
logFileChanges: true,
notify: true,
port: 8088,
open: false,
server: {
baseDir: PUBLISHED_DIR
}
});
});
gulp.task('clean', function(cb) {
rimraf(PUBLISHED_DIR, cb);
});
gulp.task('publish', ['clean', 'generate-api-docs']);
gulp.task('default', ['generate-api-docs', 'watch', 'browserSync']);
{
"name": "aglio-sample",
"version": "1.0.0",
"description": "Sample API Document with aglio",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"API Blueprint",
"aglio"
],
"author": "Shingo Yamazaki",
"license": "MIT",
"devDependencies": {
"browser-sync": "^2.7.13",
"gulp": "^3.9.0",
"gulp-aglio": "0.0.7",
"gulp-ejs": "^1.1.0",
"gulp-rename": "^1.2.2",
"rimraf": "^2.4.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment