This commit is contained in:
syuilo
2018-07-06 20:27:48 +09:00
parent fd67d5cb4c
commit 118db9b267
5 changed files with 135 additions and 92 deletions

View File

@@ -27,8 +27,8 @@ props:
type: "string"
optional: true
desc:
ja: "投稿の本文 (ローカルの場合Markdown風のフォーマット)"
en: "The text of this note (in Markdown like format if local)"
ja: "投稿の本文"
en: "The text of this note"
- name: "mediaIds"
type: "id(DriveFile)[]"
optional: true

View File

@@ -10,7 +10,7 @@ block main
p#desc= desc[lang] || desc['ja']
section
h2 %i18n:docs.api.entities.properties%
h2= i18n('docs.api.entities.properties')
+propTable(props)
if propDefs

View File

@@ -10,24 +10,24 @@ html(lang= lang)
block meta
//- FontAwesome style
style #{common.facss}
style #{facss}
body
nav
ul
each doc in common.docs
each doc in docs
li: a(href=`/docs/${lang}/${doc.name}`)= doc.title[lang] || doc.title['ja']
section
h2 API
ul
li Entities
ul
each entity in common.entities
li: a(href=`/docs/${lang}/api/entities/${common.kebab(entity)}`)= entity
each entity in entities
li: a(href=`/docs/${lang}/api/entities/${kebab(entity)}`)= entity
li Endpoints
ul
each endpoint in common.endpoints
li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint
each endpoint in endpoints
li: a(href=`/docs/${lang}/api/endpoints/${kebab(endpoint)}`)= endpoint
main
article
block main
@@ -38,4 +38,4 @@ html(lang= lang)
p
| %i18n:docs.edit-this-page-on-github%
a(href=src target="_blank") %i18n:docs.edit-this-page-on-github-link%
small= common.copyright
small= copyright

View File

@@ -1,64 +0,0 @@
import * as fs from 'fs';
import * as util from 'util';
import * as glob from 'glob';
import * as yaml from 'js-yaml';
import * as licenseChecker from 'license-checker';
import * as tmp from 'tmp';
import { fa } from '../../build/fa';
import config from '../../config';
import { licenseHtml } from '../../build/license';
const constants = require('../../const.json');
export default async function(): Promise<{ [key: string]: any }> {
const vars = {} as { [key: string]: any };
const endpoints = glob.sync('./src/client/docs/api/endpoints/**/*.yaml');
vars['endpoints'] = endpoints.map(ep => {
const _ep = yaml.safeLoad(fs.readFileSync(ep, 'utf-8')) as any;
return _ep.endpoint;
});
const entities = glob.sync('./src/client/docs/api/entities/**/*.yaml');
vars['entities'] = entities.map(x => {
const _x = yaml.safeLoad(fs.readFileSync(x, 'utf-8')) as any;
return _x.name;
});
const docs = glob.sync('./src/client/docs/**/*.*.pug');
vars['docs'] = {};
docs.forEach(x => {
const [, name, lang] = x.match(/docs\/(.+?)\.(.+?)\.pug$/);
if (vars['docs'][name] == null) {
vars['docs'][name] = {
name,
title: {}
};
}
vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/^h1 (.+?)\r?\n/)[1];
});
vars['kebab'] = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
vars['config'] = config;
vars['copyright'] = constants.copyright;
vars['facss'] = fa.dom.css();
vars['license'] = licenseHtml;
const tmpObj = tmp.fileSync();
fs.writeFileSync(tmpObj.name, JSON.stringify({
licenseText: ''
}), 'utf-8');
const dependencies = await util.promisify(licenseChecker.init).bind(licenseChecker)({
start: __dirname + '/../../../',
customPath: tmpObj.name
});
tmpObj.removeCallback();
vars['dependencies'] = dependencies;
return vars;
}