Created
July 14, 2015 15:45
-
-
Save zaki-yama/2ceeff12878de98fa762 to your computer and use it in GitHub Desktop.
aglioを使ったAPIドキュメント作成用のgulpfile
This file contains hidden or 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
| # ディレクトリ構成 | |
| ├── apidocs | |
| │ ├── api.md | |
| │ ├── layout.md | |
| │ └── questions.md | |
| ├── gulpfile.js | |
| ├── package.json | |
| └── published | |
| ├── index.html | |
| └── index.md |
This file contains hidden or 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
| 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']); |
This file contains hidden or 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
| { | |
| "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