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


TypeScript node.argdown類代碼示例

本文整理匯總了TypeScript中@argdown/node.argdown的典型用法代碼示例。如果您正苦於以下問題:TypeScript argdown類的具體用法?TypeScript argdown怎麽用?TypeScript argdown使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了argdown類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

export const handler = async (args: Arguments<IGeneralCliOptions>) => {
  let config = await argdown.loadConfig(args.config);
  config.logLevel = args.verbose ? "verbose" : config.logLevel;
  config.watch = args.watch || config.watch;
  config.logParserErrors = args.logParserErrors || config.logParserErrors;
  await argdown.load(config).catch(e => console.log(e));
};
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:7,代碼來源:DefaultCommand.ts

示例2: function

export const handler = async function(
  args: Arguments<IGeneralCliOptions & IHtmlCliOptions>
) {
  let config = await argdown.loadConfig(args.config);

  config.html = config.html || {};

  if (args.headless) {
    config.html.headless = true;
  }
  if (args.title) {
    config.title = args.title;
  }
  if (args.lang) {
    config.html.lang = args.lang;
  }

  if (args.inputGlob) {
    config.inputPath = args.inputGlob;
  }
  config.saveAs = config.saveAs || {};
  if (args.outputDir) {
    config.saveAs.outputDir = args.outputDir;
  }

  config.logLevel = args.verbose ? "verbose" : config.logLevel;
  config.watch = args.watch || config.watch;
  config.process = ["load-file", "parse-input"];
  config.logParserErrors = args.logParserErrors || config.logParserErrors;
  if (config.logParserErrors) {
    config.process.push("log-parser-errors");
  }
  config.process.push("build-model");
  config.process.push("colorize");
  config.process.push("export-html");

  if (!args.stdout || args.outputDir) {
    config.process.push("save-as-html");
  }

  if (args.css) {
    config.html.css = args.css;
  } else if (!args.stdout || args.outputDir) {
    config.process.push("copy-default-css");
  }
  if (args.stdout) {
    config.process.push("stdout-html");
  }

  await argdown.load(config).catch((e: Error) => console.log(e.message));
};
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:51,代碼來源:HtmlCommand.ts

示例3: getRangeOfHeading

 public async getRangeOfHeading(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration,
   headingText: string
 ): Promise<vscode.Range> {
   const argdownConfig = config.argdownConfig;
   const input = doc.getText();
   const request: IArgdownRequest = {
     ...argdownConfig,
     input: input,
     process: ["parse-input", "build-model"],
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   if (!response.sections || response.sections.length == 0) {
     return new vscode.Range(0, 0, 0, 0);
   }
   const section = this.findSection(response.sections, headingText);
   if (section) {
     return new vscode.Range(
       (section.startLine || 1) - 1,
       (section.startColumn || 1) - 1,
       (section.startLine || 1) - 1,
       (section.startColumn || 1) - 1
     );
   }
   return new vscode.Range(0, 0, 0, 0);
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:28,代碼來源:ArgdownEngine.ts

示例4: async

export const handler = async (
  args: Arguments<IGeneralCliOptions & IJSONCliOptions>
) => {
  let config = await argdown.loadConfig(args.config);

  config.json = config.json || {};

  if (args.spaces !== null) {
    config.json.spaces = args.spaces;
  }
  if (args.removeEmbeddedRelations) {
    config.json.removeEmbeddedRelations = true;
  }
  if (args.removeMap) {
    config.json.exportMap = false;
  }

  if (args.inputGlob) {
    config.inputPath = args.inputGlob;
  }
  config.saveAs = config.saveAs || {};
  if (args.outputDir) {
    config.saveAs.outputDir = args.outputDir;
  }

  config.logLevel = args.verbose ? "verbose" : config.logLevel;
  config.watch = args.watch || config.watch;
  config.process = ["load-file", "parse-input"];
  config.logParserErrors = args.logParserErrors || config.logParserErrors;
  if (config.logParserErrors) {
    config.process.push("log-parser-errors");
  }
  config.process.push("build-model");
  config.process.push("colorize");
  config.process.push("export-json");

  if (!args.stdout || args.outputDir) {
    config.process.push("save-as-json");
  }
  if (args.stdout) {
    config.process.push("stdout-json");
  }

  await argdown.load(config).catch(e => console.log(e));
};
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:45,代碼來源:JSONCommand.ts

示例5: async

export const handler = async (
  args: Arguments<IGeneralCliOptions & ICompileCliOptions>
) => {
  let config = await argdown.loadConfig(args.config);

  if (args.inputGlob) {
    config.inputPath = args.inputGlob;
  }
  config.saveAs = config.saveAs || {};
  if (args.outputDir) {
    config.saveAs.outputDir = args.outputDir;
  }

  config.logLevel = args.verbose ? "verbose" : config.logLevel;
  config.watch = args.watch || config.watch;
  config.process = ["load-file"];
  if (!args.stdout || args.outputDir) {
    config.process.push("save-as-argdown");
  }
  if (args.stdout) {
    config.process.push("stdout-argdown");
  }
  await argdown.load(config).catch((e: Error) => console.log(e));
};
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:24,代碼來源:CompileCommand.ts

示例6: loadConfig

 public async loadConfig(
   configFile: string | undefined,
   resource: vscode.Uri
 ): Promise<IArgdownRequest> {
   if (!configFile) {
     return {};
   }
   const workspaceFolder = vscode.workspace.getWorkspaceFolder(resource);
   let configPath = configFile;
   if (workspaceFolder) {
     let rootPath = workspaceFolder.uri.fsPath;
     configPath = path.resolve(rootPath, configFile);
   } else if (!path.isAbsolute(configPath)) {
     return {};
   }
   return await argdown.loadConfig(configPath);
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:17,代碼來源:ArgdownEngine.ts

示例7: exportHtml

 public async exportHtml(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration
 ): Promise<string> {
   const argdownConfig = config.argdownConfig || {};
   const input = doc.getText();
   const request: IArgdownRequest = {
     ...argdownConfig,
     input: input,
     process: ["parse-input", "build-model", "export-html"],
     html: {
       ...argdownConfig.html,
       headless: true
     },
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   return response.html!;
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:19,代碼來源:ArgdownEngine.ts

示例8: getRangeOfMapNode

 public async getRangeOfMapNode(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration,
   id: string
 ): Promise<vscode.Range> {
   const argdownConfig = config.argdownConfig;
   const input = doc.getText();
   const request: IArgdownRequest = {
     ...argdownConfig,
     input: input,
     process: ["parse-input", "build-model", "build-map", "colorize"],
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   const node = this.findNodeInMapNodeTree(
     response.map!.nodes,
     (n: any) => n.id === id
   );
   if (node && node.type === ArgdownTypes.ARGUMENT_MAP_NODE) {
     const argument = response.arguments![node.title!];
     const desc = IArgument.getCanonicalMember(argument);
     if (desc) {
       return new vscode.Range(
         (desc.startLine || 1) - 1,
         (desc.startColumn || 1) - 1,
         (desc.endLine || 1) - 1,
         desc.endColumn || 1
       );
     }
   } else if (node && node.type === ArgdownTypes.STATEMENT_MAP_NODE) {
     const eqClass = response.statements![node.title!];
     const statement = IEquivalenceClass.getCanonicalMember(eqClass);
     if (statement) {
       return new vscode.Range(
         (statement.startLine || 1) - 1,
         (statement.startColumn || 1) - 1,
         (statement.endLine || 1) - 1,
         statement.endColumn || 1
       );
     }
   }
   return new vscode.Range(0, 0, 0, 0);
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:43,代碼來源:ArgdownEngine.ts

示例9: getMapNodeId

 public async getMapNodeId(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration,
   line: number,
   character: number
 ): Promise<string> {
   const argdownConfig = config.argdownConfig;
   const input = doc.getText();
   const request: IArgdownRequest = {
     ...argdownConfig,
     input: input,
     findElementAtPosition: {
       line: line + 1,
       character: character + 1
     },
     process: [
       "parse-input",
       "build-model",
       "build-map",
       "colorize",
       "find-element-at-position"
     ],
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   if (response.elementAtPosition) {
     const title = response.elementAtPosition.title;
     let nodeType = ArgdownTypes.ARGUMENT_MAP_NODE;
     if (response.elementAtPosition.type === ArgdownTypes.EQUIVALENCE_CLASS) {
       nodeType = ArgdownTypes.STATEMENT_MAP_NODE;
     }
     const node = this.findNodeInMapNodeTree(
       response.map!.nodes,
       n => n.title === title && n.type === nodeType
     );
     if (!node) {
       return "";
     }
     return node.id || "";
   }
   return "";
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:42,代碼來源:ArgdownEngine.ts

示例10: getMap

 public async getMap(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration
 ): Promise<IMap> {
   const argdownConfig = config.argdownConfig;
   const input = doc.getText();
   const request = {
     ...argdownConfig,
     input: input,
     process: [
       "parse-input",
       "build-model",
       "build-map",
       "transform-closed-groups",
       "colorize"
     ],
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   return response.map!;
 }
開發者ID:christianvoigt,項目名稱:argdown,代碼行數:21,代碼來源:ArgdownEngine.ts


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