本文整理汇总了TypeScript中@argdown/core.ArgdownApplication.addPlugin方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ArgdownApplication.addPlugin方法的具体用法?TypeScript ArgdownApplication.addPlugin怎么用?TypeScript ArgdownApplication.addPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@argdown/core.ArgdownApplication
的用法示例。
在下文中一共展示了ArgdownApplication.addPlugin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ArgdownApplication
ModelPlugin,
PreselectionPlugin,
StatementSelectionPlugin,
ArgumentSelectionPlugin,
DataPlugin,
MapPlugin,
GroupPlugin,
ColorPlugin,
DotExportPlugin
} from "@argdown/core";
import { VizJsMap, DagreMap } from "../src/index";
import "babel-polyfill";
const app = new ArgdownApplication();
const parserPlugin = new ParserPlugin();
app.addPlugin(parserPlugin, "parse-input");
app.addPlugin(new DataPlugin(), "build-model");
const modelPlugin = new ModelPlugin();
app.addPlugin(modelPlugin, "build-model");
const preselectionPlugin = new PreselectionPlugin();
app.addPlugin(preselectionPlugin, "create-map");
const statementSelectionPlugin = new StatementSelectionPlugin();
app.addPlugin(statementSelectionPlugin, "create-map");
const argumentSelectionPlugin = new ArgumentSelectionPlugin();
app.addPlugin(argumentSelectionPlugin, "create-map");
const mapPlugin = new MapPlugin();
app.addPlugin(mapPlugin, "create-map");
const groupPlugin = new GroupPlugin();
app.addPlugin(groupPlugin, "create-map");
app.addPlugin(new ColorPlugin(), "colorize");
const dotExport = new DotExportPlugin();
示例2: describe
describe("DocumentSymbolPlugin", function() {
const parserPlugin = new ParserPlugin();
const modelPlugin = new ModelPlugin();
const documentSymbolPlugin = new DocumentSymbolPlugin();
app.addPlugin(parserPlugin, "parse-input");
app.addPlugin(modelPlugin, "build-model");
app.addPlugin(documentSymbolPlugin, "export-symbols");
it("sanity test", function() {
const source = `[T1]: Hello World`;
const result = app.run({
process: ["parse-input", "build-model", "export-symbols"],
input: source,
logLevel: "error"
});
expect(result.documentSymbols).to.exist;
expect(result.documentSymbols!.length).to.equal(1);
expect(result.documentSymbols![0].name).to.equal("[T1]");
});
it("can create document symbols for relations", function() {
const source = `
A
- B
+> C`;
const result = app.run({
process: ["parse-input", "build-model", "export-symbols"],
input: source,
logLevel: "error"
});
//console.log(JSON.stringify(result.documentSymbols, null, 2));
expect(result.documentSymbols).to.exist;
expect(result.documentSymbols!.length).to.equal(1);
expect(result.documentSymbols![0].name).to.equal("[Untitled 1]");
});
it("can create list of document symbols for headings, statements, arguments, relations and pcss", function() {
const source = `
# Heading 1
Hello Earth!
[S1]: Hello _World_!
## Heading 1.2
<A1>: Just because.
- <A2>: Basta.
# Heading 2
<A1>
(1) A
(2) B
----
(3) C`;
const result = app.run({
process: ["parse-input", "build-model", "export-symbols"],
input: source,
logLevel: "error"
});
// console.log(astToString(result.ast!));
//console.log(JSON.stringify(result.documentSymbols, null, 2));
expect(result.documentSymbols).to.exist;
expect(result.documentSymbols!.length).to.equal(2);
expect(result.documentSymbols![0].name).to.equal("# Heading 1");
expect(result.documentSymbols![0].children![0].name).to.equal("[Untitled 1]");
expect(result.documentSymbols![0].children![1].name).to.equal("[S1]");
expect(result.documentSymbols![0].children![2].name).to.equal("## Heading 1.2");
expect(result.documentSymbols![0].children![2].children![0].name).to.equal("<A1>");
expect(result.documentSymbols![0].children![2].children![0].children![0].name).to.equal("<- <A2>");
expect(result.documentSymbols![1].name).to.equal("# Heading 2");
expect(result.documentSymbols![1].children![0].name).to.equal("<A1>");
expect(result.documentSymbols![1].children![1].name).to.equal("PCS <A1>");
expect(result.documentSymbols![1].children![1].children![0].name).to.equal("(1) [Untitled 2]");
expect(result.documentSymbols![1].children![1].children![1].name).to.equal("(2) [Untitled 3]");
expect(result.documentSymbols![1].children![1].children![2].name).to.equal("----");
expect(result.documentSymbols![1].children![1].children![3].name).to.equal("(3) [Untitled 4]");
});
});