當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ArgdownApplication.addPlugin方法代碼示例

本文整理匯總了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();
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:31,代碼來源:index.ts

示例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]");
  });
});
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:78,代碼來源:DocumentSymbolPlugin.spec.ts


注:本文中的@argdown/core.ArgdownApplication.addPlugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。