tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

docgen.ts (1044B)


      1 /**
      2 * @license
      3 * Copyright 2022 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 import {ApiModel} from '@microsoft/api-extractor-model';
      8 
      9 import {MarkdownDocumenter} from './custom_markdown_documenter.js';
     10 
     11 export function docgen(jsonPath: string, outputDir: string): void {
     12  const apiModel = new ApiModel();
     13  apiModel.loadPackage(jsonPath);
     14 
     15  const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter({
     16    apiModel: apiModel,
     17    documenterConfig: undefined,
     18    outputFolder: outputDir,
     19  });
     20  markdownDocumenter.generateFiles();
     21 }
     22 
     23 export function spliceIntoSection(
     24  sectionName: string,
     25  content: string,
     26  sectionContent: string,
     27 ): string {
     28  const lines = content.split('\n');
     29  const offset =
     30    lines.findIndex(line => {
     31      return line.includes(`<!-- ${sectionName}-start -->`);
     32    }) + 1;
     33  const limit = lines.slice(offset).findIndex(line => {
     34    return line.includes(`<!-- ${sectionName}-end -->`);
     35  });
     36  lines.splice(offset, limit, ...sectionContent.split('\n'));
     37  return lines.join('\n');
     38 }