diff --git a/app/views/api.js b/app/views/api.js
index dc748f5..de75432 100644
--- a/app/views/api.js
+++ b/app/views/api.js
@@ -1,7 +1,5 @@
"use strict";
-
-
// I M P O R T S
import asyncHtml from "choo-async/html";
@@ -20,24 +18,17 @@ const filePathBlockchain = "/contrib/devtools/generated/api_v1.json";
const filePathSdk = "/lbry/docs/api.json";
const rawGitHubBase = "https://raw.githubusercontent.com/lbryio/";
-if (!process.env.GITHUB_OAUTH_TOKEN) // No point in rendering this page
- throw new Error("Missing GitHub token");
-
const octokit = new Octokit({
auth: `token ${process.env.GITHUB_OAUTH_TOKEN}`
});
-
-
// E X P O R T
-export default async(state) => {
+export default async state => {
const { tag } = state;
const { wildcard } = state.params;
- const repository = wildcard === "sdk" ?
- "lbry-sdk" :
- "lbrycrd";
+ const repository = wildcard === "sdk" ? "lbry-sdk" : "lbrycrd";
state.lbry = {
title: tag ? tag + " API Documentation" : "API Documentation",
@@ -123,8 +114,6 @@ export default async(state) => {
}
};
-
-
// H E L P E R S
function createApiContent(apiDetails) {
@@ -133,20 +122,33 @@ function createApiContent(apiDetails) {
apiDetails.forEach(apiDetail => {
let apiDetailsReturns = "";
- if (apiDetail.returns)
- apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
+ if (apiDetail.returns) apiDetailsReturns = JSON.parse(JSON.stringify(apiDetail.returns));
apiContent.push(`
${apiDetail.name}
${apiDetail.description}
- ${apiDetail.arguments.length ? `
Arguments
${renderArguments(apiDetail.arguments).join("")}
` : ""}
- ${apiDetail.returns ? `
Returns
${dedent(apiDetailsReturns)}
` : ""}
+ ${
+ apiDetail.arguments.length ?
+ `
Arguments
${renderArguments(
+ apiDetail.arguments
+ ).join("")}
` :
+ ""
+}
+ ${
+ apiDetail.returns ?
+ `
Returns
${dedent(apiDetailsReturns)}
` :
+ ""
+}
- ${apiDetail.examples && apiDetail.examples.length ? renderExamples(apiDetail.examples).join("") : `
// example(s) for ${apiDetail.name} to come later
`}
+ ${
+ apiDetail.examples && apiDetail.examples.length ?
+ renderExamples(apiDetail.examples).join("") :
+ `
// example(s) for ${apiDetail.name} to come later
`
+}
`);
});
@@ -232,7 +234,12 @@ function createSdkSidebar(apiDetails) {
apiSidebar.push(`
${
+ typeof arg.description === "string" ?
+ arg.description.replace(//g, ">") :
+ ""
+}
`);
});
@@ -352,11 +364,15 @@ function renderExamples(args) {
${arg.lbrynet ? `