summaryrefslogtreecommitdiff
path: root/src/web/docs/gulpfile.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-15 06:41:57 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-15 06:41:57 +0900
commit169b99a358f166185147970b916adf1a09d23de3 (patch)
tree0d776993023e81ca7665efa1d896655e2d7cf928 /src/web/docs/gulpfile.ts
parent:v: (diff)
downloadmisskey-169b99a358f166185147970b916adf1a09d23de3.tar.gz
misskey-169b99a358f166185147970b916adf1a09d23de3.tar.bz2
misskey-169b99a358f166185147970b916adf1a09d23de3.zip
:v:
Diffstat (limited to 'src/web/docs/gulpfile.ts')
-rw-r--r--src/web/docs/gulpfile.ts64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/web/docs/gulpfile.ts b/src/web/docs/gulpfile.ts
new file mode 100644
index 0000000000..6f2351dacb
--- /dev/null
+++ b/src/web/docs/gulpfile.ts
@@ -0,0 +1,64 @@
+/**
+ * Gulp tasks
+ */
+
+import * as fs from 'fs';
+import * as path from 'path';
+import * as glob from 'glob';
+import * as gulp from 'gulp';
+import * as pug from 'pug';
+//import * as yaml from 'js-yaml';
+import * as mkdirp from 'mkdirp';
+import stylus = require('gulp-stylus');
+import cssnano = require('gulp-cssnano');
+
+//import config from './../../conf';
+
+import generateVars from './vars';
+
+require('./api/gulpfile.ts');
+
+gulp.task('doc', [
+ 'doc:docs',
+ 'doc:api',
+ 'doc:styles'
+]);
+
+const commonVars = generateVars();
+
+gulp.task('doc:docs', () => {
+ glob('./src/web/docs/**/*.*.pug', (globErr, files) => {
+ if (globErr) {
+ console.error(globErr);
+ return;
+ }
+ files.forEach(file => {
+ const [, name, lang] = file.match(/docs\/(.+?)\.(.+?)\.pug$/);
+ const vars = {
+ common: commonVars,
+ lang: lang
+ };
+ pug.renderFile(file, vars, (renderErr, html) => {
+ if (renderErr) {
+ console.error(renderErr);
+ return;
+ }
+ const htmlPath = `./built/web/docs/${lang}/${name}.html`;
+ mkdirp(path.dirname(htmlPath), (mkdirErr) => {
+ if (mkdirErr) {
+ console.error(mkdirErr);
+ return;
+ }
+ fs.writeFileSync(htmlPath, html, 'utf-8');
+ });
+ });
+ });
+ });
+});
+
+gulp.task('doc:styles', () =>
+ gulp.src('./src/web/docs/**/*.styl')
+ .pipe(stylus())
+ .pipe((cssnano as any)())
+ .pipe(gulp.dest('./built/web/assets/docs/'))
+);