This commit is contained in:
syuilo 2017-12-16 00:19:10 +09:00
parent 3bcdbe151f
commit e1cc715589
8 changed files with 33 additions and 37 deletions

View file

@ -1,9 +1,6 @@
extends ../../layout.pug extends ../../layout.pug
include ../mixins include ../mixins
block title
| #{endpoint} | Misskey API
block meta block meta
link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css") link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css")

View file

@ -1,9 +1,6 @@
extends ../../layout.pug extends ../../layout.pug
include ../mixins include ../mixins
block title
| #{name} | Misskey API
block meta block meta
link(rel="stylesheet" href="/assets/docs/api/entities/style.css") link(rel="stylesheet" href="/assets/docs/api/entities/style.css")

View file

@ -108,12 +108,13 @@ gulp.task('doc:api:endpoints', () => {
paramDefs: extractDefs(ep.params), paramDefs: extractDefs(ep.params),
res: sortParams(ep.res.map(p => parseParam(p))), res: sortParams(ep.res.map(p => parseParam(p))),
resDefs: extractDefs(ep.res), resDefs: extractDefs(ep.res),
kebab,
common: commonVars
}; };
langs.forEach(lang => { langs.forEach(lang => {
pug.renderFile('./src/web/docs/api/endpoints/view.pug', Object.assign({}, vars, { pug.renderFile('./src/web/docs/api/endpoints/view.pug', Object.assign({}, vars, {
lang lang,
title: ep.endpoint,
kebab,
common: commonVars
}), (renderErr, html) => { }), (renderErr, html) => {
if (renderErr) { if (renderErr) {
console.error(renderErr); console.error(renderErr);
@ -146,12 +147,13 @@ gulp.task('doc:api:entities', () => {
desc: entity.desc, desc: entity.desc,
props: sortParams(entity.props.map(p => parseParam(p))), props: sortParams(entity.props.map(p => parseParam(p))),
propDefs: extractDefs(entity.props), propDefs: extractDefs(entity.props),
kebab,
common: commonVars
}; };
langs.forEach(lang => { langs.forEach(lang => {
pug.renderFile('./src/web/docs/api/entities/view.pug', Object.assign({}, vars, { pug.renderFile('./src/web/docs/api/entities/view.pug', Object.assign({}, vars, {
lang lang,
title: entity.name,
kebab,
common: commonVars
}), (renderErr, html) => { }), (renderErr, html) => {
if (renderErr) { if (renderErr) {
console.error(renderErr); console.error(renderErr);

View file

@ -36,13 +36,22 @@ gulp.task('doc:docs', () => {
const [, name, lang] = file.match(/docs\/(.+?)\.(.+?)\.pug$/); const [, name, lang] = file.match(/docs\/(.+?)\.(.+?)\.pug$/);
const vars = { const vars = {
common: commonVars, common: commonVars,
lang: lang lang: lang,
title: fs.readFileSync(file, 'utf-8').match(/^h1 (.+?)\r?\n/)[1]
}; };
pug.renderFile(file, vars, (renderErr, html) => { pug.renderFile(file, vars, (renderErr, content) => {
if (renderErr) { if (renderErr) {
console.error(renderErr); console.error(renderErr);
return; return;
} }
pug.renderFile('./src/web/docs/layout.pug', Object.assign({}, vars, {
content
}), (renderErr2, html) => {
if (renderErr2) {
console.error(renderErr2);
return;
}
const htmlPath = `./built/web/docs/${lang}/${name}.html`; const htmlPath = `./built/web/docs/${lang}/${name}.html`;
mkdirp(path.dirname(htmlPath), (mkdirErr) => { mkdirp(path.dirname(htmlPath), (mkdirErr) => {
if (mkdirErr) { if (mkdirErr) {
@ -55,6 +64,7 @@ gulp.task('doc:docs', () => {
}); });
}); });
}); });
});
gulp.task('doc:styles', () => gulp.task('doc:styles', () =>
gulp.src('./src/web/docs/**/*.styl') gulp.src('./src/web/docs/**/*.styl')

View file

@ -1,9 +1,3 @@
extends ./layout.pug
block title
| Misskey Docs
block main
h1 Misskey Docs h1 Misskey Docs
p Welcome to docs of Misskey. p Welcome to docs of Misskey.

View file

@ -1,9 +1,3 @@
extends ./layout.pug
block title
| Misskey ドキュメント
block main
h1 Misskey ドキュメント h1 Misskey ドキュメント
p Misskeyのドキュメントへようこそ p Misskeyのドキュメントへようこそ

View file

@ -5,7 +5,7 @@ html(lang= lang)
meta(charset="UTF-8") meta(charset="UTF-8")
meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no") meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no")
title title
block title | #{title} | Misskey Docs
link(rel="stylesheet" href="/assets/docs/style.css") link(rel="stylesheet" href="/assets/docs/style.css")
block meta block meta
@ -27,3 +27,5 @@ html(lang= lang)
li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint
main main
block main block main
if content
| !{content}

View file

@ -27,7 +27,7 @@ export default function() {
title: {} title: {}
}; };
} }
vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r?\n\th1 (.+?)\r?\n/)[1]; vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/^h1 (.+?)\r?\n/)[1];
}); });
vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();