From bdc8812c129f6d623fc331682c3722d7d6896278 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 23 Jul 2019 08:47:02 -0700 Subject: [PATCH] chore(tsdocs): remove the workaround for constructor md file name We had to rename it from `(construcotr).md` to `_constructor_.md`. Now it's fixed by https://github.com/microsoft/web-build-tools/pull/1410. --- .../src/__tests__/acceptance/tsdocs.acceptance.ts | 12 +++++------- packages/tsdocs/src/update-api-md-docs.ts | 14 +------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts b/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts index 2210274b0912..cb68c6382b4a 100644 --- a/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts +++ b/packages/tsdocs/src/__tests__/acceptance/tsdocs.acceptance.ts @@ -9,7 +9,6 @@ import pEvent from 'p-event'; import * as path from 'path'; import {runExtractorForMonorepo, updateApiDocs} from '../..'; import {runExtractorForPackage} from '../../monorepo-api-extractor'; -import {fixConstructorName} from '../../update-api-md-docs'; const runCLI = require('@loopback/build').runCLI; @@ -23,7 +22,9 @@ describe('tsdocs', function() { const API_MD_FILES = [ 'pkg1.md', - 'pkg1.pet.(constructor).md', + // It was `'pkg1.pet._constructor_.md'` before + // https://github.com/microsoft/web-build-tools/pull/1410 + 'pkg1.pet._constructor_.md', 'pkg1.pet.greet.md', 'pkg1.pet.kind.md', 'pkg1.pet.md', @@ -102,10 +103,7 @@ describe('tsdocs', function() { }); const files = await fs.readdir(SITE_APIDOCS_ROOT); - expect(files.sort()).to.eql([ - 'index.md', - ...API_MD_FILES.map(fixConstructorName), - ]); + expect(files.sort()).to.eql(['index.md', ...API_MD_FILES]); for (const f of files) { const md = await fs.readFile(path.join(SITE_APIDOCS_ROOT, f), 'utf-8'); @@ -135,6 +133,6 @@ permalink: /doc/en/lb4/apidocs.index.html path.join(SITE_APIDOCS_ROOT, 'pkg1.pet._constructor_.md'), 'utf-8', ); - expect(constructorDoc).to.not.match(/\.\(constructor\)/); + expect(constructorDoc).to.not.match(/\.\(constructor\)\.md/); }); }); diff --git a/packages/tsdocs/src/update-api-md-docs.ts b/packages/tsdocs/src/update-api-md-docs.ts index 0d4a8301a17f..8994beba9ceb 100644 --- a/packages/tsdocs/src/update-api-md-docs.ts +++ b/packages/tsdocs/src/update-api-md-docs.ts @@ -126,7 +126,6 @@ async function addJekyllMetadata( } const docFile = path.join(apiDocsRoot, f); - const targetDocFile = path.join(apiDocsRoot, fixConstructorName(f)); let doc = await fs.readFile(docFile, 'utf-8'); if (isPackage && options.generateDefaultPackageDoc) { @@ -165,20 +164,9 @@ permalink: /doc/en/lb4/apidocs.${name}.html ${doc} `; - // Fix `*.(constructor)` - doc = fixConstructorName(doc); - if (!options.dryRun) { - await fs.writeFile(targetDocFile, doc, 'utf-8'); - if (targetDocFile !== docFile) { - await fs.remove(docFile); - } + await fs.writeFile(docFile, doc, 'utf-8'); } } return true; } - -// Fix `*.(constructor)` -export function fixConstructorName(name: string) { - return name.replace(/\.\(constructor\)/g, '._constructor_'); -}