summaryrefslogtreecommitdiff
path: root/src/web/docs/api/endpoints
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/docs/api/endpoints')
-rw-r--r--src/web/docs/api/endpoints/gulpfile.ts75
-rw-r--r--src/web/docs/api/endpoints/posts/create.yaml33
-rw-r--r--src/web/docs/api/endpoints/posts/timeline.yaml32
-rw-r--r--src/web/docs/api/endpoints/style.styl10
-rw-r--r--src/web/docs/api/endpoints/view.pug73
5 files changed, 69 insertions, 154 deletions
diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts
deleted file mode 100644
index a2c3944709..0000000000
--- a/src/web/docs/api/endpoints/gulpfile.ts
+++ /dev/null
@@ -1,75 +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 config from './../../../../conf';
-
-const parseParam = param => {
- const id = param.type.match(/^id\((.+?)\)/);
- const object = param.type.match(/^object\((.+?)\)/);
- const isArray = /\[\]$/.test(param.type);
- if (id) {
- param.kind = 'id';
- param.type = 'string';
- param.entity = id[1];
- if (isArray) {
- param.type += '[]';
- }
- }
- if (object) {
- param.kind = 'object';
- param.type = 'object';
- param.def = object[1];
- if (isArray) {
- param.type += '[]';
- }
- }
-
- return param;
-};
-
-gulp.task('doc:endpoints', () => {
- glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => {
- if (globErr) {
- console.error(globErr);
- return;
- }
- //console.log(files);
- files.forEach(file => {
- const ep = yaml.safeLoad(fs.readFileSync(file, 'utf-8'));
- const vars = {
- endpoint: ep.endpoint,
- url: `${config.api_url}/${ep.endpoint}`,
- desc: ep.desc,
- params: ep.params.map(p => parseParam(p)),
- paramDefs: Object.keys(ep.paramDefs).map(key => ({
- name: key,
- params: ep.paramDefs[key].map(p => parseParam(p))
- })),
- res: ep.res.map(p => parseParam(p))
- };
- pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => {
- if (renderErr) {
- console.error(renderErr);
- return;
- }
- const htmlPath = `./built/web/docs/api/endpoints/${ep.endpoint}.html`;
- mkdirp(path.dirname(htmlPath), (mkdirErr) => {
- if (mkdirErr) {
- console.error(mkdirErr);
- return;
- }
- fs.writeFileSync(htmlPath, html, 'utf-8');
- });
- });
- });
- });
-});
diff --git a/src/web/docs/api/endpoints/posts/create.yaml b/src/web/docs/api/endpoints/posts/create.yaml
index b6613038a7..5e2307dab4 100644
--- a/src/web/docs/api/endpoints/posts/create.yaml
+++ b/src/web/docs/api/endpoints/posts/create.yaml
@@ -7,43 +7,42 @@ desc:
params:
- name: "text"
type: "string"
- optional: false
+ optional: true
desc:
ja: "投稿の本文"
- en: "Text of a post"
+ en: "The text of your post"
- name: "media_ids"
type: "id(DriveFile)[]"
optional: true
desc:
- ja: "添付するメディア"
- en: "Media you want to attach"
+ ja: "添付するメディア(1~4つ)"
+ en: "Media you want to attach (1~4)"
- name: "reply_id"
type: "id(Post)"
optional: true
desc:
ja: "返信する投稿"
- en: "A post you want to reply"
+ en: "The post you want to reply"
- name: "repost_id"
type: "id(Post)"
optional: true
desc:
ja: "引用する投稿"
- en: "A post you want to quote"
+ en: "The post you want to quote"
- name: "poll"
- type: "object(poll)"
+ type: "object"
optional: true
desc:
ja: "投票"
- en: "A poll"
-
-paramDefs:
- poll:
- - name: "choices"
- type: "string[]"
- optional: false
- desc:
- ja: "投票の選択肢"
- en: "Choices of a poll"
+ en: "The poll"
+ defName: "poll"
+ def:
+ - name: "choices"
+ type: "string[]"
+ optional: false
+ desc:
+ ja: "投票の選択肢"
+ en: "Choices of a poll"
res:
- name: "created_post"
diff --git a/src/web/docs/api/endpoints/posts/timeline.yaml b/src/web/docs/api/endpoints/posts/timeline.yaml
new file mode 100644
index 0000000000..e1d78c082e
--- /dev/null
+++ b/src/web/docs/api/endpoints/posts/timeline.yaml
@@ -0,0 +1,32 @@
+endpoint: "posts/timeline"
+
+desc:
+ ja: "タイムラインを取得します。"
+ en: "Get your timeline."
+
+params:
+ - name: "limit"
+ type: "number"
+ optional: true
+ desc:
+ ja: "取得する最大の数"
+ - name: "since_id"
+ type: "id(Post)"
+ optional: true
+ desc:
+ ja: "指定すると、この投稿を基点としてより新しい投稿を取得します"
+ - name: "max_id"
+ type: "id(Post)"
+ optional: true
+ desc:
+ ja: "指定すると、この投稿を基点としてより古い投稿を取得します"
+ - name: "since_date"
+ type: "number"
+ optional: true
+ desc:
+ ja: "指定した時間を基点としてより新しい投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
+ - name: "max_date"
+ type: "number"
+ optional: true
+ desc:
+ ja: "指定した時間を基点としてより古い投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
diff --git a/src/web/docs/api/endpoints/style.styl b/src/web/docs/api/endpoints/style.styl
index 12c06fe3af..07fb7ec2a3 100644
--- a/src/web/docs/api/endpoints/style.styl
+++ b/src/web/docs/api/endpoints/style.styl
@@ -1,4 +1,4 @@
-@import "../../style"
+@import "../style"
#url
padding 8px 12px
@@ -6,11 +6,3 @@
color #fff
background #222e40
border-radius 4px
-
-table
- .name
- font-weight bold
-
- .type
- font-family Consolas, 'Courier New', Courier, Monaco, monospace
-
diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug
index d9de9cb74a..9ba1c4e852 100644
--- a/src/web/docs/api/endpoints/view.pug
+++ b/src/web/docs/api/endpoints/view.pug
@@ -1,60 +1,27 @@
-doctype html
+extends ../../layout.pug
+include ../mixins
-mixin i18n(xs)
- each text, lang in xs
- span(class=`i18n ${lang}`)= text
+block meta
+ link(rel="stylesheet" href="/assets/api/endpoints/style.css")
-mixin table(params)
- table
- thead: tr
- th Name
- th Type
- th Optional
- th Description
- tbody
- each param in params
- tr
- td.name= param.name
- td.type
- if param.kind == 'id'
- | #{param.type} (ID of
- = ' '
- a(href=`/docs/api/entities/${param.entity}`)= param.entity
- | )
- else if param.kind == 'object'
- | #{param.type} (
- a(href=`#${param.def}`)= param.def
- | )
- else
- = param.type
- td.optional= param.optional.toString()
- td.desc: +i18n(param.desc)
+block main
+ h1= endpoint
-html
- head
- meta(charset="UTF-8")
- title #{endpoint} | Misskey API
- link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css")
+ p#url= url
- body
- main
- h1= endpoint
+ p#desc= desc[lang] || desc['ja']
- p#url= url
+ section
+ h2 Params
+ +propTable(params)
- p#desc: +i18n(desc)
-
- section
- h2 Params
- +table(params)
-
- if paramDefs
- each paramDef in paramDefs
- section(id= paramDef.name)
- h3= paramDef.name
- +table(paramDef.params)
-
- section
- h2 Response
- +table(res)
+ if paramDefs
+ each paramDef in paramDefs
+ section(id= paramDef.name)
+ h3= paramDef.name
+ +propTable(paramDef.params)
+ if res
+ section
+ h2 Response
+ +propTable(res)