2019-08-22 01:22:26 +03:00
|
|
|
<template>
|
|
|
|
<div v-if="loading">
|
|
|
|
Loading...
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2019-10-10 21:58:00 +03:00
|
|
|
<h1>{{ data.info.prettyName || data.name }}</h1>
|
2019-08-22 01:22:26 +03:00
|
|
|
|
2019-10-05 14:46:00 +03:00
|
|
|
<!-- Description -->
|
|
|
|
<MarkdownBlock :content="data.info.description" class="content"></MarkdownBlock>
|
|
|
|
|
2019-10-10 21:58:00 +03:00
|
|
|
<Tabs>
|
|
|
|
<Tab :active="tab === 'usage'">
|
2019-10-25 21:45:18 +03:00
|
|
|
<router-link class="unstyled" v-bind:to="'/docs/plugins/' + pluginName + '/usage'">Usage</router-link>
|
2019-10-10 21:58:00 +03:00
|
|
|
</Tab>
|
|
|
|
<Tab :active="tab === 'configuration'">
|
2019-10-25 21:45:18 +03:00
|
|
|
<router-link class="unstyled" v-bind:to="'/docs/plugins/' + pluginName + '/configuration'">Configuration</router-link>
|
2019-10-10 21:58:00 +03:00
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
2019-08-22 02:58:32 +03:00
|
|
|
|
2019-09-29 15:53:14 +03:00
|
|
|
<!-- Usage tab -->
|
|
|
|
<div class="usage" v-if="tab === 'usage'">
|
2019-10-05 14:46:00 +03:00
|
|
|
<div v-if="!hasUsageInfo">
|
|
|
|
This plugin has no usage information.
|
|
|
|
See <router-link v-bind:to="'/docs/plugins/' + pluginName + '/configuration'">Configuration</router-link>.
|
|
|
|
</div>
|
2019-08-22 01:22:26 +03:00
|
|
|
|
2019-09-29 15:53:14 +03:00
|
|
|
<!-- Usage guide -->
|
|
|
|
<div v-if="data.info.usageGuide">
|
2019-10-10 21:58:00 +03:00
|
|
|
<h2 id="usage-guide">Usage guide</h2>
|
2019-09-29 15:53:14 +03:00
|
|
|
<MarkdownBlock :content="data.info.usageGuide" class="content"></MarkdownBlock>
|
2019-08-22 02:58:32 +03:00
|
|
|
</div>
|
|
|
|
|
2019-09-29 15:53:14 +03:00
|
|
|
<!-- Command list -->
|
|
|
|
<div v-if="data.commands.length">
|
2019-10-10 21:58:00 +03:00
|
|
|
<h2 id="commands">Commands</h2>
|
|
|
|
<div v-for="command in data.commands" class="mb-4">
|
2019-10-25 23:14:21 +03:00
|
|
|
<h3 class="text-xl mb-0">
|
|
|
|
!{{ command.trigger }}
|
|
|
|
<span v-for="alias in command.config.aliases"> <span class="text-gray-600">/</span> !{{ alias }}</span>
|
|
|
|
</h3>
|
|
|
|
<MarkdownBlock v-if="command.config.extra.info && command.config.extra.info.description"
|
|
|
|
:content="command.config.extra.info.description"
|
|
|
|
class="content">
|
|
|
|
</MarkdownBlock>
|
2019-09-29 15:53:14 +03:00
|
|
|
|
2019-10-25 23:14:21 +03:00
|
|
|
<div v-bind:class="{'-mt-2': command.config.extra.info && command.config.extra.info.description}">
|
|
|
|
<div v-if="command.config.extra.info && command.config.extra.info.basicUsage">
|
|
|
|
<span class="font-semibold">Basic usage:</span> <code class="inline-code">{{ command.config.extra.info.basicUsage }}</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-08-22 02:58:32 +03:00
|
|
|
|
2019-10-10 21:58:00 +03:00
|
|
|
<Expandable class="mt-4">
|
|
|
|
<template v-slot:title>Additional information</template>
|
|
|
|
<template v-slot:content>
|
2019-10-25 23:14:21 +03:00
|
|
|
<div v-if="command.config.extra.info && command.config.extra.info.usageGuide">
|
|
|
|
<div class="font-semibold">Usage guide:</div>
|
|
|
|
<MarkdownBlock :content="command.config.extra.info.usageGuide"
|
|
|
|
class="content">
|
|
|
|
</MarkdownBlock>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="command.config.extra.info && command.config.extra.info.examples">
|
|
|
|
<div class="font-semibold">Examples:</div>
|
|
|
|
<MarkdownBlock :content="command.config.extra.info.examples"
|
|
|
|
class="content">
|
|
|
|
</MarkdownBlock>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p v-if="command.config.extra.requiredPermission">
|
|
|
|
<span class="font-semibold">Permission:</span>
|
|
|
|
<code class="inline-code">{{ command.config.extra.requiredPermission }}</code>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<span class="font-semibold">Signatures:</span>
|
2019-10-10 21:58:00 +03:00
|
|
|
<ul>
|
2019-09-29 15:53:14 +03:00
|
|
|
<li>
|
2019-10-10 22:55:31 +03:00
|
|
|
<code class="inline-code bg-gray-900">
|
2019-09-29 15:53:14 +03:00
|
|
|
!{{ command.trigger }}
|
|
|
|
<span v-for="param in command.parameters">{{ renderParameter(param) }} </span>
|
|
|
|
</code>
|
2019-08-22 02:58:32 +03:00
|
|
|
</li>
|
|
|
|
</ul>
|
2019-09-29 15:53:14 +03:00
|
|
|
|
|
|
|
<div class="mt-2" v-if="command.parameters.length">
|
2019-10-25 23:14:21 +03:00
|
|
|
<span class="font-semibold">Command arguments:</span>
|
2019-10-10 21:58:00 +03:00
|
|
|
<ul>
|
2019-09-29 15:53:14 +03:00
|
|
|
<li v-for="param in command.parameters">
|
|
|
|
<code>{{ renderParameter(param) }}</code>
|
2019-10-05 14:46:00 +03:00
|
|
|
<router-link :to="'/docs/reference/argument-types#' + (param.type || 'string')">{{ param.type || 'string' }}</router-link>
|
2019-10-25 23:14:21 +03:00
|
|
|
<MarkdownBlock v-if="command.config.extra.info && command.config.extra.info.parameterDescriptions && command.config.extra.info.parameterDescriptions[param.name]"
|
|
|
|
:content="command.config.extra.info.parameterDescriptions[param.name]"
|
2019-09-29 15:53:14 +03:00
|
|
|
class="content">
|
|
|
|
</MarkdownBlock>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2019-10-05 14:46:00 +03:00
|
|
|
|
|
|
|
<div class="mt-2" v-if="command.config.options && command.config.options.length">
|
2019-10-25 23:14:21 +03:00
|
|
|
<span class="font-semibold">Options:</span>
|
2019-10-10 22:55:31 +03:00
|
|
|
<ul>
|
2019-10-05 14:46:00 +03:00
|
|
|
<li v-for="opt in command.config.options">
|
|
|
|
<code>{{ renderOption(opt) }}</code>
|
|
|
|
<router-link :to="'/docs/reference/argument-types#' + (opt.type || 'string')">{{ opt.type || 'string' }}</router-link>
|
2019-10-25 23:14:21 +03:00
|
|
|
<MarkdownBlock v-if="command.config.extra.info && command.config.extra.info.optionDescriptions && command.config.extra.info.optionDescriptions[opt.name]"
|
|
|
|
:content="command.config.extra.info.optionDescriptions[opt.name]"
|
2019-10-05 14:46:00 +03:00
|
|
|
class="content">
|
|
|
|
</MarkdownBlock>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2019-10-10 21:58:00 +03:00
|
|
|
</template>
|
|
|
|
</Expandable>
|
2019-09-29 15:53:14 +03:00
|
|
|
</div>
|
2019-08-22 01:22:26 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-09-29 15:53:14 +03:00
|
|
|
|
|
|
|
<!-- Configuration tab -->
|
|
|
|
<div class="configuration" v-if="tab === 'configuration'">
|
|
|
|
<!-- Basic config info -->
|
2019-10-10 21:58:00 +03:00
|
|
|
<p>
|
2019-10-11 02:09:31 +03:00
|
|
|
<strong>Name in config:</strong> <code>{{ data.name }}</code><br>
|
2019-09-29 15:53:14 +03:00
|
|
|
To enable this plugin with default configuration, add <code>{{ data.name }}: {}</code> to the <code>plugins</code> list in config
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<!-- Configuration guide -->
|
|
|
|
<div v-if="data.info.configurationGuide">
|
2019-10-10 21:58:00 +03:00
|
|
|
<h2 id="configuration-guide">Configuration guide</h2>
|
2019-09-29 15:53:14 +03:00
|
|
|
<MarkdownBlock :content="data.info.configurationGuide" class="content"></MarkdownBlock>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Default configuration -->
|
2019-10-10 21:58:00 +03:00
|
|
|
<h2 id="default-configuration">Default configuration</h2>
|
2019-10-25 21:45:18 +03:00
|
|
|
<CodeBlock code-lang="yaml">{{ renderConfiguration(data.defaultOptions) }}</CodeBlock>
|
2019-09-29 15:53:14 +03:00
|
|
|
|
|
|
|
<!-- Config schema -->
|
2019-10-10 21:58:00 +03:00
|
|
|
<h2 id="config-schema">Config schema</h2>
|
2019-10-11 01:59:56 +03:00
|
|
|
<Expandable class="wide">
|
|
|
|
<template v-slot:title>Click to expand</template>
|
|
|
|
<template v-slot:content>
|
2019-10-25 21:45:18 +03:00
|
|
|
<CodeBlock code-lang="plain">{{ data.configSchema }}</CodeBlock>
|
2019-10-11 01:59:56 +03:00
|
|
|
</template>
|
|
|
|
</Expandable>
|
2019-09-29 15:53:14 +03:00
|
|
|
</div>
|
2019-08-22 01:22:26 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2019-10-10 21:58:00 +03:00
|
|
|
<script lang="ts">
|
2019-08-22 01:22:26 +03:00
|
|
|
import Vue from "vue";
|
|
|
|
import {mapState} from "vuex";
|
|
|
|
import yaml from "js-yaml";
|
2019-10-10 21:58:00 +03:00
|
|
|
import CodeBlock from "./CodeBlock.vue";
|
|
|
|
import MarkdownBlock from "./MarkdownBlock.vue";
|
|
|
|
import Tabs from "../Tabs.vue";
|
|
|
|
import Tab from "../Tab.vue";
|
|
|
|
import Expandable from "../Expandable.vue";
|
|
|
|
import { DocsState } from "../../store/types";
|
2019-09-29 15:53:14 +03:00
|
|
|
|
|
|
|
const validTabs = ['usage', 'configuration'];
|
|
|
|
const defaultTab = 'usage';
|
2019-08-22 01:22:26 +03:00
|
|
|
|
|
|
|
export default {
|
2019-10-10 21:58:00 +03:00
|
|
|
components: { CodeBlock, MarkdownBlock, Tabs, Tab, Expandable },
|
2019-08-22 01:22:26 +03:00
|
|
|
|
|
|
|
async mounted() {
|
|
|
|
this.loading = true;
|
2019-10-05 14:46:00 +03:00
|
|
|
|
2019-08-22 01:22:26 +03:00
|
|
|
await this.$store.dispatch("docs/loadPluginData", this.pluginName);
|
2019-10-05 14:46:00 +03:00
|
|
|
|
|
|
|
// If there's no usage info, use Configuration as the default tab
|
|
|
|
if (!this.hasUsageInfo && ! this.$route.params.tab) {
|
|
|
|
this.tab = 'configuration';
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:22:26 +03:00
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
renderConfiguration(options) {
|
|
|
|
return yaml.safeDump({
|
|
|
|
[this.pluginName]: options,
|
|
|
|
});
|
|
|
|
},
|
2019-08-22 02:58:32 +03:00
|
|
|
renderParameter(param) {
|
|
|
|
let str = `${param.name}`;
|
|
|
|
if (param.rest) str += '...';
|
|
|
|
if (param.required) {
|
|
|
|
return `<${str}>`;
|
|
|
|
} else {
|
|
|
|
return `[${str}]`;
|
|
|
|
}
|
|
|
|
},
|
2019-10-05 14:46:00 +03:00
|
|
|
renderOption(opt) {
|
2019-10-25 20:25:25 +03:00
|
|
|
let str = `-${opt.name}`;
|
2019-10-05 14:46:00 +03:00
|
|
|
if (opt.shortcut) {
|
|
|
|
str += `|-${opt.shortcut}`;
|
|
|
|
}
|
|
|
|
if (opt.required) {
|
|
|
|
return `<${str}>`;
|
|
|
|
} else {
|
|
|
|
return `[${str}]`;
|
|
|
|
}
|
|
|
|
},
|
2019-08-22 01:22:26 +03:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
pluginName: this.$route.params.pluginName,
|
2019-09-29 15:53:14 +03:00
|
|
|
tab: validTabs.includes(this.$route.params.tab)
|
|
|
|
? this.$route.params.tab
|
|
|
|
: defaultTab,
|
2019-08-22 01:22:26 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState("docs", {
|
2019-10-10 21:58:00 +03:00
|
|
|
data(state: DocsState) {
|
2019-08-22 01:22:26 +03:00
|
|
|
return state.plugins[this.pluginName];
|
|
|
|
},
|
2019-10-05 14:46:00 +03:00
|
|
|
hasUsageInfo() {
|
|
|
|
if (!this.data) return true;
|
|
|
|
if (this.data.commands.length) return true;
|
|
|
|
if (this.data.info.usageGuide) return true;
|
|
|
|
return false;
|
|
|
|
},
|
2019-08-22 01:22:26 +03:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|