mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Add usageGuide/configurationGuide to PluginInfo, make trimPluginDescription dynamic
Previously trimPluginDescription was hardcoded to trim 6 spaces from the beginning of every line. Now the function looks at the last non- empty line and uses its indentation to determine how many spaces to trim from the other lines.
This commit is contained in:
parent
86b1df0a6a
commit
a905e82492
1 changed files with 15 additions and 5 deletions
|
@ -23,21 +23,31 @@ import { mergeConfig } from "knub/dist/configUtils";
|
|||
|
||||
const SLOW_RESOLVE_THRESHOLD = 1500;
|
||||
|
||||
/**
|
||||
* Wrapper for the string type that indicates the text will be parsed as Markdown later
|
||||
*/
|
||||
type TMarkdown = string;
|
||||
|
||||
export interface PluginInfo {
|
||||
prettyName: string;
|
||||
description?: string;
|
||||
description?: TMarkdown;
|
||||
usageGuide?: TMarkdown;
|
||||
configurationGuide?: TMarkdown;
|
||||
}
|
||||
|
||||
export interface CommandInfo {
|
||||
description?: string;
|
||||
basicUsage?: string;
|
||||
description?: TMarkdown;
|
||||
basicUsage?: TMarkdown;
|
||||
parameterDescriptions?: {
|
||||
[key: string]: string;
|
||||
[key: string]: TMarkdown;
|
||||
};
|
||||
}
|
||||
|
||||
export function trimPluginDescription(str) {
|
||||
return trimIndents(trimEmptyStartEndLines(str), 6);
|
||||
const emptyLinesTrimmed = trimEmptyStartEndLines(str);
|
||||
const lines = emptyLinesTrimmed.split("\n");
|
||||
const lastLineIndentation = (lines[lines.length - 1].match(/^ +/g) || [""])[0].length;
|
||||
return trimIndents(emptyLinesTrimmed, lastLineIndentation);
|
||||
}
|
||||
|
||||
export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plugin<TConfig> {
|
||||
|
|
Loading…
Add table
Reference in a new issue