Skip to content

Commit

Permalink
chore(cli): redo docs validation so that we are forced to add fern ch…
Browse files Browse the repository at this point in the history
…eck rules (#4771)
  • Loading branch information
dsinghvi authored Sep 28, 2024
1 parent fc997bb commit f3cf580
Show file tree
Hide file tree
Showing 14 changed files with 600 additions and 486 deletions.
6 changes: 6 additions & 0 deletions fern/pages/changelogs/cli/2024-09-28.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 0.43.7
**`(fix):`** The `valid-markdown` rule has been updated to try and parse the markdown file into a
valid AST. If the file fails to parse, `fern check` will log an error as well
as the path to the markdown.


9 changes: 9 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- changelogEntry:
- summary: |
The `valid-markdown` rule has been updated to try and parse the markdown file into a
valid AST. If the file fails to parse, `fern check` will log an error as well
as the path to the markdown.
type: fix
irVersion: 53
version: 0.43.7

- changelogEntry:
- summary: |
The OpenAPI importer now appropriately brings in responses that are under the `text/event-stream`
Expand Down
1 change: 1 addition & 0 deletions packages/cli/docs-markdown-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { parseImagePaths, replaceImagePathsAndUrls } from "./parseImagePaths";
export { replaceReferencedMarkdown } from "./replaceReferencedMarkdown";
export { replaceReferencedCode } from "./replaceReferencedCode";
export { parseMarkdownToTree } from "./parseMarkdownToTree";
6 changes: 2 additions & 4 deletions packages/cli/docs-markdown-utils/src/parseImagePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fromMarkdown } from "mdast-util-from-markdown";
import { mdxFromMarkdown } from "mdast-util-mdx";
import { mdx } from "micromark-extension-mdx";
import { visit } from "unist-util-visit";
import { parseMarkdownToTree } from "./parseMarkdownToTree";

interface AbsolutePathMetadata {
absolutePathToMdx: AbsoluteFilePath;
Expand Down Expand Up @@ -48,10 +49,7 @@ export function parseImagePaths(

visitFrontmatterImages(data, ["image", "og:image", "og:logo", "twitter:image"], mapImage);

const tree = fromMarkdown(content, {
extensions: [mdx()],
mdastExtensions: [mdxFromMarkdown()]
});
const tree = parseMarkdownToTree(content);

let offset = 0;

Expand Down
11 changes: 11 additions & 0 deletions packages/cli/docs-markdown-utils/src/parseMarkdownToTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { fromMarkdown } from "mdast-util-from-markdown";
import { Root } from "mdast-util-from-markdown/lib";
import { mdxFromMarkdown } from "mdast-util-mdx";
import { mdx } from "micromark-extension-mdx";

export function parseMarkdownToTree(content: string): Root {
return fromMarkdown(content, {
extensions: [mdx()],
mdastExtensions: [mdxFromMarkdown()]
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`fern generate > missing docs page 1`] = `
"[docs]: Found 1 errors and 0 warnings. Run fern check --warnings to print out the warnings.
[docs]: docs.yml -> navigation -> 0 -> page
[docs]: docs.yml -> navigation -> 0 -> path
Path missing.md does not exist"
`;
Loading

0 comments on commit f3cf580

Please sign in to comment.