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.ts96
-rw-r--r--src/web/docs/api/endpoints/posts/create.yaml8
-rw-r--r--src/web/docs/api/endpoints/style.styl12
-rw-r--r--src/web/docs/api/endpoints/view.pug75
4 files changed, 26 insertions, 165 deletions
diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts
deleted file mode 100644
index e375447c55..0000000000
--- a/src/web/docs/api/endpoints/gulpfile.ts
+++ /dev/null
@@ -1,96 +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 entity = param.type.match(/^entity\((.+?)\)/);
- const isObject = /^object/.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';
- }
-
- return param;
-};
-
-const extractDefs = params => {
- const defs = [];
-
- params.forEach(param => {
- if (param.def) {
- defs.push({
- name: param.defName,
- params: param.def.map(p => parseParam(p))
- });
-
- const childDefs = extractDefs(param.def);
-
- defs.concat(childDefs);
- }
- });
-
- return defs;
-};
-
-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: extractDefs(ep.params),
- res: ep.res.map(p => parseParam(p)),
- resDefs: extractDefs(ep.res)
- };
- 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 498a99159c..5e2307dab4 100644
--- a/src/web/docs/api/endpoints/posts/create.yaml
+++ b/src/web/docs/api/endpoints/posts/create.yaml
@@ -10,7 +10,7 @@ params:
optional: true
desc:
ja: "投稿の本文"
- en: "Text of a post"
+ en: "The text of your post"
- name: "media_ids"
type: "id(DriveFile)[]"
optional: true
@@ -22,19 +22,19 @@ params:
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"
optional: true
desc:
ja: "投票"
- en: "A poll"
+ en: "The poll"
defName: "poll"
def:
- name: "choices"
diff --git a/src/web/docs/api/endpoints/style.styl b/src/web/docs/api/endpoints/style.styl
index ab74e100b5..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,13 +6,3 @@
color #fff
background #222e40
border-radius 4px
-
-table
- .name
- font-weight bold
-
- .name
- .type
- .optional
- 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 841ca8b3f9..cebef9fa5b 100644
--- a/src/web/docs/api/endpoints/view.pug
+++ b/src/web/docs/api/endpoints/view.pug
@@ -1,63 +1,30 @@
-doctype html
+extends ../../layout.pug
+include ../mixins
-mixin i18n(xs)
- each text, lang in xs
- span(class=`i18n ${lang}`)= text
+block title
+ | #{endpoint} | Misskey API
-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} (
- a(href=`/docs/api/entities/${param.entity}`)= param.entity
- | ID)
- else if param.kind == 'entity'
- | #{param.type} (
- a(href=`/docs/api/entities/${param.entity}`)= param.entity
- | )
- else if param.kind == 'object'
- | #{param.type} (
- a(href=`#${param.defName}`)= param.defName
- | )
- else
- = param.type
- td.optional= param.optional.toString()
- td.desc: +i18n(param.desc)
+block meta
+ link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css")
-html
- head
- meta(charset="UTF-8")
- title #{endpoint} | Misskey API
- link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css")
+block main
+ h1= endpoint
- body
- main
- h1= endpoint
+ p#url= url
- p#url= url
+ p#desc: +i18n(desc)
- p#desc: +i18n(desc)
+ section
+ h2 Params
+ +propTable(params)
- section
- h2 Params
- +table(params)
+ if paramDefs
+ each paramDef in paramDefs
+ section(id= paramDef.name)
+ h3= paramDef.name
+ +propTable(paramDef.params)
- if paramDefs
- each paramDef in paramDefs
- section(id= paramDef.name)
- h3= paramDef.name
- +table(paramDef.params)
-
- section
- h2 Response
- +table(res)
+ section
+ h2 Response
+ +propTable(res)