Skip to content

Commit

Permalink
fix(docs): write-docs-definition domain in slug and null changelog no…
Browse files Browse the repository at this point in the history
…de (#5015)
  • Loading branch information
abvthecity authored Oct 26, 2024
1 parent 50bf6cb commit f6f1153
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
5 changes: 5 additions & 0 deletions fern/pages/changelogs/cli/2024-10-26.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 0.45.0-rc25
**`(fix):`** - fixes how `write-docs-definition` handles urls containing `https://` prefix
- fixes how the docs definition resolver handles changelogs under api reference nodes


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function writeDocsDefinitionForProject({
);

const docsResolver = new DocsDefinitionResolver(
`https://${docsWorkspace.config.instances[0]?.url ?? "https://localhost:8080"}`,
docsWorkspace.config.instances[0]?.url ?? "http://localhost:8080",
docsWorkspace,
fernWorkspaces,
context
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- changelogEntry:
- summary: |
- fixes how `write-docs-definition` handles urls containing `https://` prefix
- fixes how the docs definition resolver handles changelogs under api reference nodes
type: fix
irVersion: 53
version: 0.45.0-rc25

- changelogEntry:
- summary: |
`fern docs dev` now runs in Node 16 - Node 22 environments.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-preview/src/runPreviewServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function runPreviewServer({
app.use(cors());

const instance = new URL(
wrapWithHttps(initialProject.docsWorkspaces?.config.instances[0]?.url ?? `localhost:${port}`)
wrapWithHttps(initialProject.docsWorkspaces?.config.instances[0]?.url ?? `http://localhost:${port}`)
);

let project = initialProject;
Expand Down
21 changes: 11 additions & 10 deletions packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { docsYml } from "@fern-api/configuration";
import { isNonNullish } from "@fern-api/core-utils";
import { APIV1Read, APIV1Write, FernNavigation } from "@fern-api/fdr-sdk";
import { APIV1Read, FernNavigation } from "@fern-api/fdr-sdk";
import { AbsoluteFilePath, relative, RelativeFilePath } from "@fern-api/fs-utils";
import { TaskContext } from "@fern-api/task-context";
import { DocsWorkspace, FernWorkspace } from "@fern-api/workspace-loader";
Expand Down Expand Up @@ -78,6 +78,12 @@ export class ApiReferenceNodeConverter {

public get(): FernNavigation.V1.ApiReferenceNode {
const pointsTo = FernNavigation.V1.followRedirects(this.#children);
const changelogNodeConverter = new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.workspace.changelog?.files.map((file) => file.absoluteFilepath),
this.docsWorkspace,
this.#idgen
).orUndefined();
return {
id: this.#idgen.get(this.apiDefinitionId),
type: "apiReference",
Expand All @@ -90,14 +96,9 @@ export class ApiReferenceNodeConverter {
hidden: this.apiSection.hidden,
hideTitle: this.apiSection.flattened,
showErrors: this.apiSection.showErrors,
changelog: new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.workspace.changelog?.files.map((file) => file.absoluteFilepath),
this.docsWorkspace,
this.#idgen
).toChangelogNode({
changelog: changelogNodeConverter?.toChangelogNode({
parentSlug: this.#slug,
viewers: []
viewers: undefined
}),
children: this.#children,
availability: undefined,
Expand Down Expand Up @@ -532,7 +533,7 @@ export class ApiReferenceNodeConverter {
return {
...child,
children,
pointsTo: FernNavigation.V1.followRedirects(children)
pointsTo: undefined
};
}
return child;
Expand Down Expand Up @@ -651,7 +652,7 @@ export class ApiReferenceNodeConverter {
overviewPageId: undefined,
availability: undefined,
apiDefinitionId: this.apiDefinitionId,
pointsTo: FernNavigation.V1.followRedirects(subpackageChildren),
pointsTo: undefined,
noindex: undefined,
playground: undefined,
authed: undefined,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/docs-resolver/src/ChangelogNodeConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export class ChangelogNodeConverter {
};
}

public orUndefined(): ChangelogNodeConverter | undefined {
return this.changelogFiles != null && this.changelogFiles.length > 0 ? this : undefined;
}

private groupByYear(
prefix: string,
entries: FernNavigation.V1.ChangelogEntryNode[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ exports[`write-docs-definition > petstore 1`] = `
"title": "API Reference",
"apiDefinitionId": "api-1",
"paginated": false,
"slug": "fern.docs.buildwithfern.com/api-reference",
"slug": "api-reference",
"hideTitle": false,
"showErrors": false,
"changelog": {
"id": "6665bc2f57c4a7045d347313a1566d91561ff2a3c9d17874a462ae73b7eb8593",
"type": "changelog",
"title": "Changelog",
"slug": "fern.docs.buildwithfern.com/api-reference/changelog",
"children": [],
"viewers": []
},
"children": [
{
"id": "api-1:subpackage_pets",
Expand All @@ -45,7 +37,7 @@ exports[`write-docs-definition > petstore 1`] = `
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "List all pets",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"slug": "api-reference/pets/list-pets"
},
{
"id": "api-1:endpoint_pets.createPets",
Expand All @@ -55,7 +47,7 @@ exports[`write-docs-definition > petstore 1`] = `
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "Create a pet",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/create-pets"
"slug": "api-reference/pets/create-pets"
},
{
"id": "api-1:endpoint_pets.showPetById",
Expand All @@ -65,21 +57,20 @@ exports[`write-docs-definition > petstore 1`] = `
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "Info for a specific pet",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/show-pet-by-id"
"slug": "api-reference/pets/show-pet-by-id"
}
],
"title": "Pets",
"slug": "fern.docs.buildwithfern.com/api-reference/pets",
"apiDefinitionId": "api-1",
"pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"slug": "api-reference/pets",
"apiDefinitionId": "api-1"
}
],
"pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"pointsTo": "api-reference/pets/list-pets"
}
]
}
},
"slug": "fern.docs.buildwithfern.com",
"slug": "",
"title": "fern | Documentation",
"hidden": false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@
"title": "API Reference",
"apiDefinitionId": "api-1",
"paginated": false,
"slug": "fern.docs.buildwithfern.com/api-reference",
"slug": "api-reference",
"hideTitle": false,
"showErrors": false,
"changelog": {
"id": "6665bc2f57c4a7045d347313a1566d91561ff2a3c9d17874a462ae73b7eb8593",
"type": "changelog",
"title": "Changelog",
"slug": "fern.docs.buildwithfern.com/api-reference/changelog",
"children": [],
"viewers": []
},
"children": [
{
"id": "api-1:subpackage_pets",
Expand All @@ -42,7 +34,7 @@
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "List all pets",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"slug": "api-reference/pets/list-pets"
},
{
"id": "api-1:endpoint_pets.createPets",
Expand All @@ -52,7 +44,7 @@
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "Create a pet",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/create-pets"
"slug": "api-reference/pets/create-pets"
},
{
"id": "api-1:endpoint_pets.showPetById",
Expand All @@ -62,21 +54,20 @@
"apiDefinitionId": "api-1",
"isResponseStream": false,
"title": "Info for a specific pet",
"slug": "fern.docs.buildwithfern.com/api-reference/pets/show-pet-by-id"
"slug": "api-reference/pets/show-pet-by-id"
}
],
"title": "Pets",
"slug": "fern.docs.buildwithfern.com/api-reference/pets",
"apiDefinitionId": "api-1",
"pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"slug": "api-reference/pets",
"apiDefinitionId": "api-1"
}
],
"pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets"
"pointsTo": "api-reference/pets/list-pets"
}
]
}
},
"slug": "fern.docs.buildwithfern.com",
"slug": "",
"title": "fern | Documentation",
"hidden": false
},
Expand Down

0 comments on commit f6f1153

Please sign in to comment.