Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Set instance when migrating Mintlify > Fern #5093

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/docs-importers/commons/src/FernDocsBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/docs-importers/commons/src/FernDocsBuilderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export class MintlifyImporter extends DocsImporter<MintlifyImporter.Args> {
}
}
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to output the name here, as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, updating now!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RohinBhargava are you thinking that we should output the name from the mint file or the name we auto-generate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question! I think you have the most context, but I would assume mint.name, given the locality of the debug statement to the invocation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattblank11 could see this being: Added instance ${url} to docs.yml

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the input!

I agree with @dsinghvi on returning the url, if anything. IMO it's weird to return a string from the setInstance function but I don't love the alternative of creating a separate getInstanceUrl function. Feel free to push back on this!

}

private async getNavigationBuilder({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
instances: []
instances:
- url: https://bland-ai.docs.buildwithfern.com
title: Bland AI
favicon: logo.png
logo:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
instances: []
instances:
- url: https://layer.docs.buildwithfern.com
title: Layer
favicon: favicon.png
logo:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
instances: []
instances:
- url: https://zep-documentation.docs.buildwithfern.com
title: Zep Documentation
favicon: logo/favicon.png
logo:
Expand Down
Loading