diff options
Diffstat (limited to 'src/client/docs/api')
| -rw-r--r-- | src/client/docs/api/endpoints/notes/create.yaml | 59 | ||||
| -rw-r--r-- | src/client/docs/api/endpoints/notes/timeline.yaml | 32 | ||||
| -rw-r--r-- | src/client/docs/api/endpoints/view.pug | 4 | ||||
| -rw-r--r-- | src/client/docs/api/entities/note.yaml | 4 | ||||
| -rw-r--r-- | src/client/docs/api/entities/view.pug | 2 | ||||
| -rw-r--r-- | src/client/docs/api/gulpfile.ts | 193 | ||||
| -rw-r--r-- | src/client/docs/api/mixins.pug | 14 |
7 files changed, 9 insertions, 299 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 |