0
0
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,20 +36,30 @@ 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;
} }
const htmlPath = `./built/web/docs/${lang}/${name}.html`;
mkdirp(path.dirname(htmlPath), (mkdirErr) => { pug.renderFile('./src/web/docs/layout.pug', Object.assign({}, vars, {
if (mkdirErr) { content
console.error(mkdirErr); }), (renderErr2, html) => {
if (renderErr2) {
console.error(renderErr2);
return; return;
} }
fs.writeFileSync(htmlPath, html, 'utf-8'); 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');
});
}); });
}); });
}); });

View File

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

View File

@ -1,9 +1,3 @@
extends ./layout.pug h1 Misskey ドキュメント
block title p Misskeyのドキュメントへようこそ
| Misskey ドキュメント
block main
h1 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();