summaryrefslogtreecommitdiff
path: root/src/client/docs
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-07-07 02:55:52 +0900
committerGitHub <noreply@github.com>2018-07-07 02:55:52 +0900
commitd5bad25c63f1b1d095da8b523dc02be471d7071a (patch)
tree381ce23594925e56ba09c16de076932193f35b47 /src/client/docs
parentMerge pull request #1846 from syuilo/l10n_master (diff)
parentw (diff)
downloadmisskey-d5bad25c63f1b1d095da8b523dc02be471d7071a.tar.gz
misskey-d5bad25c63f1b1d095da8b523dc02be471d7071a.tar.bz2
misskey-d5bad25c63f1b1d095da8b523dc02be471d7071a.zip
Merge pull request #1854 from syuilo/apis
:v:
Diffstat (limited to 'src/client/docs')
-rw-r--r--src/client/docs/api/endpoints/notes/create.yaml59
-rw-r--r--src/client/docs/api/endpoints/notes/timeline.yaml32
-rw-r--r--src/client/docs/api/endpoints/view.pug4
-rw-r--r--src/client/docs/api/entities/note.yaml4
-rw-r--r--src/client/docs/api/entities/view.pug2
-rw-r--r--src/client/docs/api/gulpfile.ts193
-rw-r--r--src/client/docs/api/mixins.pug14
-rw-r--r--src/client/docs/gulpfile.ts59
-rw-r--r--src/client/docs/layout.pug14
-rw-r--r--src/client/docs/style.styl2
-rw-r--r--src/client/docs/vars.ts64
11 files changed, 17 insertions, 430 deletions
diff --git a/src/client/docs/api/endpoints/notes/create.yaml b/src/client/docs/api/endpoints/notes/create.yaml
deleted file mode 100644
index 04ada2ecd5..0000000000
--- a/src/client/docs/api/endpoints/notes/create.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-endpoint: "notes/create"
-
-desc:
- ja: "投稿します。"
- en: "Compose new note."
-
-params:
- - name: "text"
- type: "string"
- optional: true
- desc:
- ja: "投稿の本文"
- en: "The text of your note"
- - name: "cw"
- type: "string"
- optional: true
- desc:
- ja: "コンテンツの警告。このパラメータを指定すると設定したテキストで投稿のコンテンツを隠す事が出来ます。"
- en: "Content Warning"
- - name: "mediaIds"
- type: "id(DriveFile)[]"
- optional: true
- desc:
- ja: "添付するメディア(1~4つ)"
- en: "Media you want to attach (1~4)"
- - name: "replyId"
- type: "id(Note)"
- optional: true
- desc:
- ja: "返信する投稿"
- en: "The note you want to reply"
- - name: "renoteId"
- type: "id(Note)"
- optional: true
- desc:
- ja: "引用する投稿"
- en: "The note you want to quote"
- - name: "poll"
- type: "object"
- optional: true
- desc:
- ja: "投票"
- en: "The poll"
- defName: "poll"
- def:
- - name: "choices"
- type: "string[]"
- optional: false
- desc:
- ja: "投票の選択肢"
- en: "Choices of a poll"
-
-res:
- - name: "createdNote"
- type: "entity(Note)"
- optional: false
- desc:
- ja: "作成した投稿"
- en: "A note that created"
diff --git a/src/client/docs/api/endpoints/notes/timeline.yaml b/src/client/docs/api/endpoints/notes/timeline.yaml
deleted file mode 100644
index 71c346f355..0000000000
--- a/src/client/docs/api/endpoints/notes/timeline.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-endpoint: "notes/timeline"
-
-desc:
- ja: "タイムラインを取得します。"
- en: "Get your timeline."
-
-params:
- - name: "limit"
- type: "number"
- optional: true
- desc:
- ja: "取得する最大の数"
- - name: "sinceId"
- type: "id(Note)"
- optional: true
- desc:
- ja: "指定すると、この投稿を基点としてより新しい投稿を取得します"
- - name: "untilId"
- type: "id(Note)"
- optional: true
- desc:
- ja: "指定すると、この投稿を基点としてより古い投稿を取得します"
- - name: "sinceDate"
- type: "number"
- optional: true
- desc:
- ja: "指定した時間を基点としてより新しい投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
- - name: "untilDate"
- type: "number"
- optional: true
- desc:
- ja: "指定した時間を基点としてより古い投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
diff --git a/src/client/docs/api/endpoints/view.pug b/src/client/docs/api/endpoints/view.pug
index f8795c8442..24fff1b798 100644
--- a/src/client/docs/api/endpoints/view.pug
+++ b/src/client/docs/api/endpoints/view.pug
@@ -17,7 +17,7 @@ block main
p#desc= desc[lang] || desc['ja']
section
- h2 %i18n:docs.api.endpoints.params%
+ h2= i18n('docs.api.endpoints.params')
+propTable(params)
if paramDefs
@@ -28,5 +28,5 @@ block main
if res
section
- h2 %i18n:docs.api.endpoints.res%
+ h2= i18n('docs.api.endpoints.res')
+propTable(res)
diff --git a/src/client/docs/api/entities/note.yaml b/src/client/docs/api/entities/note.yaml
index 6fd26543bb..c508dab3db 100644
--- a/src/client/docs/api/entities/note.yaml
+++ b/src/client/docs/api/entities/note.yaml
@@ -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
diff --git a/src/client/docs/api/entities/view.pug b/src/client/docs/api/entities/view.pug
index ac938151a7..a930f71eb6 100644
--- a/src/client/docs/api/entities/view.pug
+++ b/src/client/docs/api/entities/view.pug
@@ -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
diff --git a/src/client/docs/api/gulpfile.ts b/src/client/docs/api/gulpfile.ts
deleted file mode 100644
index 0eb8b88287..0000000000
--- a/src/client/docs/api/gulpfile.ts
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * 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 locales from '../../../../locales';
-import I18nReplacer from '../../../build/i18n';
-import fa from '../../../build/fa';
-import config from './../../../config';
-
-import generateVars from '../vars';
-
-const langs = Object.keys(locales);
-
-const kebab = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
-
-// WIP type
-const parseParam = (param: any) => {
- const id = param.type.match(/^id\((.+?)\)|^id/);
- const entity = param.type.match(/^entity\((.+?)\)/);
- const isObject = /^object/.test(param.type);
- const isDate = /^date/.test(param.type);
- const isArray = /\[\]$/.test(param.type);
- if (id) {
- param.kind = 'id';
- param.type = 'string';
- param.entity = id[1];
- if (isArray) {
- param.type += '[]';
- }
- }
- if (entity) {
- param.kind = 'entity';
- param.type = 'object';
- param.entity = entity[1];
- if (isArray) {
- param.type += '[]';
- }
- }
- if (isObject) {
- param.kind = 'object';
- }
- if (isDate) {
- param.kind = 'date';
- param.type = 'string';
- if (isArray) {
- param.type += '[]';
- }
- }
-
- return param;
-};
-
-const sortParams = (params: Array<{name: string}>) => {
- params.sort((a, b) => {
- if (a.name < b.name)
- return -1;
- if (a.name > b.name)
- return 1;
- return 0;
- });
- return params;
-};
-
-// WIP type
-const extractDefs = (params: any[]) => {
- let defs: any[] = [];
-
- params.forEach(param => {
- if (param.def) {
- defs.push({
- name: param.defName,
- params: sortParams(param.def.map((p: any) => parseParam(p)))
- });
-
- const childDefs = extractDefs(param.def);
-
- defs = defs.concat(childDefs);
- }
- });
-
- return sortParams(defs);
-};
-
-gulp.task('doc:api', [
- 'doc:api:endpoints',
- 'doc:api:entities'
-]);
-
-gulp.task('doc:api:endpoints', async () => {
- const commonVars = await generateVars();
- glob('./src/client/docs/api/endpoints/**/*.yaml', (globErr, files) => {
- if (globErr) {
- console.error(globErr);
- return;
- }
- //console.log(files);
- files.forEach(file => {
- const ep: any = yaml.safeLoad(fs.readFileSync(file, 'utf-8'));
- const vars = {
- endpoint: ep.endpoint,
- url: {
- host: config.api_url,
- path: ep.endpoint
- },
- desc: ep.desc,
- // @ts-ignore
- params: sortParams(ep.params.map(p => parseParam(p))),
- paramDefs: extractDefs(ep.params),
- // @ts-ignore
- res: ep.res ? sortParams(ep.res.map(p => parseParam(p))) : null,
- resDefs: ep.res ? extractDefs(ep.res) : null,
- };
- langs.forEach(lang => {
- pug.renderFile('./src/client/docs/api/endpoints/view.pug', Object.assign({}, vars, {
- lang,
- title: ep.endpoint,
- src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/endpoints/${ep.endpoint}.yaml`,
- kebab,
- common: commonVars
- }), (renderErr, html) => {
- if (renderErr) {
- console.error(renderErr);
- return;
- }
- const i18n = new I18nReplacer(lang);
- html = html.replace(i18n.pattern, i18n.replacement);
- html = fa(html);
- const htmlPath = `./built/client/docs/${lang}/api/endpoints/${ep.endpoint}.html`;
- mkdirp(path.dirname(htmlPath), (mkdirErr) => {
- if (mkdirErr) {
- console.error(mkdirErr);
- return;
- }
- fs.writeFileSync(htmlPath, html, 'utf-8');
- });
- });
- });
- });
- });
-});
-
-gulp.task('doc:api:entities', async () => {
- const commonVars = await generateVars();
- glob('./src/client/docs/api/entities/**/*.yaml', (globErr, files) => {
- if (globErr) {
- console.error(globErr);
- return;
- }
- files.forEach(file => {
- const entity = yaml.safeLoad(fs.readFileSync(file, 'utf-8')) as any;
- const vars = {
- name: entity.name,
- desc: entity.desc,
- // WIP type
- props: sortParams(entity.props.map((p: any) => parseParam(p))),
- propDefs: extractDefs(entity.props),
- };
- langs.forEach(lang => {
- pug.renderFile('./src/client/docs/api/entities/view.pug', Object.assign({}, vars, {
- lang,
- title: entity.name,
- src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/entities/${kebab(entity.name)}.yaml`,
- kebab,
- common: commonVars
- }), (renderErr, html) => {
- if (renderErr) {
- console.error(renderErr);
- return;
- }
- const i18n = new I18nReplacer(lang);
- html = html.replace(i18n.pattern, i18n.replacement);
- html = fa(html);
- const htmlPath = `./built/client/docs/${lang}/api/entities/${kebab(entity.name)}.html`;
- mkdirp(path.dirname(htmlPath), (mkdirErr) => {
- if (mkdirErr) {
- console.error(mkdirErr);
- return;
- }
- fs.writeFileSync(htmlPath, html, 'utf-8');
- });
- });
- });
- });
- });
-});
diff --git a/src/client/docs/api/mixins.pug b/src/client/docs/api/mixins.pug
index 913135a85f..79665a61e3 100644
--- a/src/client/docs/api/mixins.pug
+++ b/src/client/docs/api/mixins.pug
@@ -1,10 +1,9 @@
mixin propTable(props)
table.props
thead: tr
- th %i18n:docs.api.props.name%
- th %i18n:docs.api.props.type%
- th %i18n:docs.api.props.optional%
- th %i18n:docs.api.props.description%
+ th= i18n('docs.api.props.name')
+ th= i18n('docs.api.props.type')
+ th= i18n('docs.api.props.description')
tbody
each prop in props
tr
@@ -29,9 +28,4 @@ mixin propTable(props)
| )
else if prop.kind == 'date'
| (Date)
- td.optional
- if prop.optional
- | %i18n:docs.api.props.yes%
- else
- | %i18n:docs.api.props.no%
- td.desc!= prop.desc[lang] || prop.desc['ja']
+ td.desc!= prop.desc ? prop.desc[lang] || prop.desc['ja'] : null
diff --git a/src/client/docs/gulpfile.ts b/src/client/docs/gulpfile.ts
index 4683a04659..2a95dfbfee 100644
--- a/src/client/docs/gulpfile.ts
+++ b/src/client/docs/gulpfile.ts
@@ -2,73 +2,14 @@
* 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 mkdirp from 'mkdirp';
const stylus = require('gulp-stylus');
const cssnano = require('gulp-cssnano');
-import I18nReplacer from '../../build/i18n';
-import fa from '../../build/fa';
-import generateVars from './vars';
-
-require('./api/gulpfile.ts');
-
gulp.task('doc', [
- 'doc:docs',
- 'doc:api',
'doc:styles'
]);
-gulp.task('doc:docs', async () => {
- const commonVars = await generateVars();
-
- glob('./src/client/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,
- title: fs.readFileSync(file, 'utf-8').match(/^h1 (.+?)\r?\n/)[1],
- src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/${name}.${lang}.pug`,
- };
- pug.renderFile(file, vars, (renderErr, content) => {
- if (renderErr) {
- console.error(renderErr);
- return;
- }
-
- pug.renderFile('./src/client/docs/layout.pug', Object.assign({}, vars, {
- content
- }), (renderErr2, html) => {
- if (renderErr2) {
- console.error(renderErr2);
- return;
- }
- const i18n = new I18nReplacer(lang);
- html = html.replace(i18n.pattern, i18n.replacement);
- html = fa(html);
- const htmlPath = `./built/client/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/client/docs/**/*.styl')
.pipe(stylus())
diff --git a/src/client/docs/layout.pug b/src/client/docs/layout.pug
index 1d9ebcb4cd..4186d2d365 100644
--- a/src/client/docs/layout.pug
+++ b/src/client/docs/layout.pug
@@ -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
diff --git a/src/client/docs/style.styl b/src/client/docs/style.styl
index bc165f8728..3b13617588 100644
--- a/src/client/docs/style.styl
+++ b/src/client/docs/style.styl
@@ -10,7 +10,7 @@ main
margin 0 0 0 256px
padding 64px
width 100%
- max-width 768px
+ max-width 800px
section
margin 32px 0
diff --git a/src/client/docs/vars.ts b/src/client/docs/vars.ts
deleted file mode 100644
index 93082767e3..0000000000
--- a/src/client/docs/vars.ts
+++ /dev/null
@@ -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;
-}