当前位置: 首页>>代码示例>>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;未经允许,请勿转载。