From 604f6a45cd3ffa2b84a4ebf671c83a7502820096 Mon Sep 17 00:00:00 2001 From: Matt Blank <34134349+mattblank11@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:52:24 -0500 Subject: [PATCH 1/3] Set when migrating Mintlify > Fern --- .../docs-importers/commons/src/FernDocsBuilder.ts | 2 ++ .../commons/src/FernDocsBuilderImpl.ts | 13 +++++++++++++ .../docs-importers/mintlify/src/MintlifyImporter.ts | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts b/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts index 35a3920d024..fb148b5287b 100644 --- a/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts +++ b/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts @@ -55,6 +55,8 @@ export abstract class FernDocsBuilder { public abstract setLayout({ layout }: { layout: docsYml.RawSchemas.LayoutConfig }): void; public abstract build({ outputDirectory }: { outputDirectory: AbsoluteFilePath }): void; + + public abstract setInstance({ companyName }: { companyName: string }): void; } export abstract class FernDocsNavigationBuilder { diff --git a/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts b/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts index 477e6b62ac4..18ed6808617 100644 --- a/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts +++ b/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts @@ -151,6 +151,19 @@ export class FernDocsBuilderImpl extends FernDocsBuilder { }) ); } + + public setInstance({ companyName }: { companyName: string }): void { + // We may append a suffix to the company name string to make it harder for + // other companies to build migrators for our docs. For now, we're not doing + // so but we can add that easily in the future. + const formattedCompanyString = companyName.toLowerCase().replace(" ", "-"); + + const fernDocsUrl = `https://${formattedCompanyString}.docs.buildwithfern.com`; + + this.docsYml.instances.push({ + url: fernDocsUrl + }); + } } export class TabbedNavigationBuilderImpl implements FernDocsNavigationBuilder { diff --git a/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts b/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts index 4aeb6008e14..38bf2619eb2 100644 --- a/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts +++ b/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts @@ -95,6 +95,13 @@ export class MintlifyImporter extends DocsImporter { } } this.context.logger.debug("Imported OpenAPI specs"); + + // We're currently setting one instance so that clients can generate docs out of the box, + // but they'll have the option to add additional instances and custom domains later. + builder.setInstance({ + companyName: mint.name + }); + this.context.logger.debug("Set instance"); } private async getNavigationBuilder({ From f94c58c17fc4c8e6ff5b92d83c45f19a5bb6bf41 Mon Sep 17 00:00:00 2001 From: Matt Blank <34134349+mattblank11@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:03:42 -0500 Subject: [PATCH 2/3] Update output docs.yml files --- .../mintlify/src/__test__/outputs/bland/fern/docs.yml | 3 ++- .../mintlify/src/__test__/outputs/layerfi/fern/docs.yml | 3 ++- .../mintlify/src/__test__/outputs/zep/fern/docs.yml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/docs-importers/mintlify/src/__test__/outputs/bland/fern/docs.yml b/packages/cli/docs-importers/mintlify/src/__test__/outputs/bland/fern/docs.yml index 63ce8f5b8f3..f8a69f03d02 100644 --- a/packages/cli/docs-importers/mintlify/src/__test__/outputs/bland/fern/docs.yml +++ b/packages/cli/docs-importers/mintlify/src/__test__/outputs/bland/fern/docs.yml @@ -1,4 +1,5 @@ -instances: [] +instances: + - url: https://bland-ai.docs.buildwithfern.com title: Bland AI favicon: logo.png logo: diff --git a/packages/cli/docs-importers/mintlify/src/__test__/outputs/layerfi/fern/docs.yml b/packages/cli/docs-importers/mintlify/src/__test__/outputs/layerfi/fern/docs.yml index e87d6815a29..fb67b2169d9 100644 --- a/packages/cli/docs-importers/mintlify/src/__test__/outputs/layerfi/fern/docs.yml +++ b/packages/cli/docs-importers/mintlify/src/__test__/outputs/layerfi/fern/docs.yml @@ -1,4 +1,5 @@ -instances: [] +instances: + - url: https://layer.docs.buildwithfern.com title: Layer favicon: favicon.png logo: diff --git a/packages/cli/docs-importers/mintlify/src/__test__/outputs/zep/fern/docs.yml b/packages/cli/docs-importers/mintlify/src/__test__/outputs/zep/fern/docs.yml index 4484474f4c3..e189b23d250 100644 --- a/packages/cli/docs-importers/mintlify/src/__test__/outputs/zep/fern/docs.yml +++ b/packages/cli/docs-importers/mintlify/src/__test__/outputs/zep/fern/docs.yml @@ -1,4 +1,5 @@ -instances: [] +instances: + - url: https://zep-documentation.docs.buildwithfern.com title: Zep Documentation favicon: logo/favicon.png logo: From 84fe2af69f0db26fbea9d2ca31c6c11032003c83 Mon Sep 17 00:00:00 2001 From: Matt Blank <34134349+mattblank11@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:24:57 -0500 Subject: [PATCH 3/3] Log instance url --- packages/cli/docs-importers/commons/src/FernDocsBuilder.ts | 2 +- .../cli/docs-importers/commons/src/FernDocsBuilderImpl.ts | 4 +++- packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts b/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts index fb148b5287b..9b9ca27f12a 100644 --- a/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts +++ b/packages/cli/docs-importers/commons/src/FernDocsBuilder.ts @@ -56,7 +56,7 @@ export abstract class FernDocsBuilder { public abstract build({ outputDirectory }: { outputDirectory: AbsoluteFilePath }): void; - public abstract setInstance({ companyName }: { companyName: string }): void; + public abstract setInstance({ companyName }: { companyName: string }): string; } export abstract class FernDocsNavigationBuilder { diff --git a/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts b/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts index 18ed6808617..eb6ecfadc2d 100644 --- a/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts +++ b/packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts @@ -152,7 +152,7 @@ export class FernDocsBuilderImpl extends FernDocsBuilder { ); } - public setInstance({ companyName }: { companyName: string }): void { + public setInstance({ companyName }: { companyName: string }): string { // We may append a suffix to the company name string to make it harder for // other companies to build migrators for our docs. For now, we're not doing // so but we can add that easily in the future. @@ -163,6 +163,8 @@ export class FernDocsBuilderImpl extends FernDocsBuilder { this.docsYml.instances.push({ url: fernDocsUrl }); + + return fernDocsUrl; } } diff --git a/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts b/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts index 38bf2619eb2..7db05d39088 100644 --- a/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts +++ b/packages/cli/docs-importers/mintlify/src/MintlifyImporter.ts @@ -98,10 +98,10 @@ export class MintlifyImporter extends DocsImporter { // We're currently setting one instance so that clients can generate docs out of the box, // but they'll have the option to add additional instances and custom domains later. - builder.setInstance({ + const instanceUrl = builder.setInstance({ companyName: mint.name }); - this.context.logger.debug("Set instance"); + this.context.logger.debug(`Added instance ${instanceUrl} to docs.yml`); } private async getNavigationBuilder({