-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace referenced markdown (#4191)
* fix: replace referenced markdown * add dry test * fix
- Loading branch information
1 parent
fe4da35
commit 268a463
Showing
8 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
packages/cli/docs-resolver/src/__test__/__snapshots__/dry.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`converts to api reference node 1`] = ` | ||
"# Relative Path | ||
### Snippet | ||
Hello, I'm a snippet. | ||
\`\`\`js title="fibonacci.js" | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); | ||
\`\`\` | ||
# Relative Path 2 | ||
### Snippet | ||
Hello, I'm a snippet. | ||
\`\`\`js title="fibonacci.js" | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); | ||
\`\`\` | ||
# Relative Path 3 | ||
### Snippet | ||
Hello, I'm a snippet. | ||
\`\`\`js title="fibonacci.js" | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); | ||
\`\`\` | ||
# Absolute Path | ||
### Snippet | ||
Hello, I'm a snippet. | ||
\`\`\`js title="fibonacci.js" | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); | ||
\`\`\` | ||
# Indented | ||
<div> | ||
### Snippet | ||
Hello, I'm a snippet. | ||
\`\`\`js title="fibonacci.js" | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); | ||
\`\`\` | ||
</div> | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { docsYml } from "@fern-api/configuration"; | ||
import { AbsoluteFilePath, resolve } from "@fern-api/fs-utils"; | ||
import { createMockTaskContext } from "@fern-api/task-context"; | ||
import { loadDocsWorkspace } from "@fern-api/workspace-loader"; | ||
import { DocsDefinitionResolver } from "../DocsDefinitionResolver"; | ||
|
||
const context = createMockTaskContext(); | ||
|
||
it("converts to api reference node", async () => { | ||
const docsWorkspace = await loadDocsWorkspace({ | ||
fernDirectory: resolve(AbsoluteFilePath.of(__dirname), "fixtures/dry/fern"), | ||
context | ||
}); | ||
|
||
if (docsWorkspace == null) { | ||
throw new Error("Workspace is null"); | ||
} | ||
|
||
const resolver = new DocsDefinitionResolver( | ||
"domain", | ||
docsWorkspace, | ||
[], | ||
context, | ||
undefined, | ||
async (_files) => [], | ||
async (_opts) => "" | ||
); | ||
|
||
const resolved = await resolver.resolve(); | ||
|
||
expect(resolved.pages["page.mdx"]?.markdown).toMatchSnapshot(); | ||
}); |
4 changes: 4 additions & 0 deletions
4
packages/cli/docs-resolver/src/__test__/fixtures/dry/fern/docs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
instances: [] | ||
navigation: | ||
- page: Testing Page | ||
path: ./page.mdx |
Empty file.
14 changes: 14 additions & 0 deletions
14
packages/cli/docs-resolver/src/__test__/fixtures/dry/fern/fibonacci.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function fibonacci(num) { | ||
let n1 = 0, n2 = 1, nextTerm; | ||
|
||
console.log('Fibonacci Sequence:'); | ||
for (let i = 1; i <= num; i++) { | ||
console.log(n1); | ||
nextTerm = n1 + n2; | ||
n1 = n2; | ||
n2 = nextTerm; | ||
} | ||
} | ||
|
||
// Example: Log the first 10 terms of the Fibonacci sequence | ||
fibonacci(10); |
33 changes: 33 additions & 0 deletions
33
packages/cli/docs-resolver/src/__test__/fixtures/dry/fern/page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Relative Path | ||
|
||
<Markdown src="./snippet.md" /> | ||
|
||
<Code src="./fibonacci.js" /> | ||
|
||
# Relative Path 2 | ||
|
||
<Markdown src="snippet.md" /> | ||
|
||
<Code src="fibonacci.js" /> | ||
|
||
# Relative Path 3 | ||
|
||
<Markdown src="../fern/snippet.md" /> | ||
|
||
<Code src="../fern/fibonacci.js" /> | ||
|
||
# Absolute Path | ||
|
||
<Markdown src="/snippet.md" /> | ||
|
||
<Code src="/fibonacci.js" /> | ||
|
||
# Indented | ||
|
||
<div> | ||
|
||
<Markdown src="./snippet.md" /> | ||
|
||
<Code src="./fibonacci.js" /> | ||
|
||
</div> |
3 changes: 3 additions & 0 deletions
3
packages/cli/docs-resolver/src/__test__/fixtures/dry/fern/snippet.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Snippet | ||
|
||
Hello, I'm a snippet. |