-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9632a40
commit 4da4927
Showing
4 changed files
with
92 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// @ts-check | ||
import { MarkdownPageEvent } from 'typedoc-plugin-markdown'; | ||
|
||
/** | ||
* This plugin adds a title and description to the frontmatter of each markdown page for compliance with Mintlify. | ||
* | ||
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app | ||
*/ | ||
export function load(app) { | ||
app.renderer.on( | ||
MarkdownPageEvent.END, | ||
/** | ||
* @param {import('typedoc-plugin-markdown').MarkdownPageEvent} page | ||
*/ | ||
(page) => { | ||
if (page.contents) { | ||
if (page.contents.includes('.mdx')) { | ||
const regex = /(\.mdx)/g; | ||
page.contents = page.contents.replace(regex, ''); | ||
} | ||
} | ||
}, | ||
); | ||
} |
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 |
---|---|---|
@@ -1,27 +1,28 @@ | ||
// @ts-check | ||
import { MarkdownPageEvent } from 'typedoc-plugin-markdown' | ||
import { MarkdownPageEvent } from 'typedoc-plugin-markdown'; | ||
|
||
/** | ||
* This plugin adds a title and description to the frontmatter of | ||
* each markdown page for compliance with Mintlify. | ||
* This plugin adds a title and description to the frontmatter of each markdown page for compliance with Mintlify. | ||
* | ||
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app | ||
*/ | ||
export function load(app) { | ||
app.renderer.on( | ||
MarkdownPageEvent.BEGIN, | ||
/** @param {import('typedoc-plugin-markdown').MarkdownPageEvent} page */ | ||
(page) => { | ||
let summary = '' | ||
if (page.model?.comment?.summary) { | ||
summary = page.model.comment.summary[0].text + '...' | ||
summary = summary.replace(/\n/g, ' ') | ||
} | ||
page.frontmatter = { | ||
title: page.model?.name, | ||
description: summary, | ||
...page.frontmatter, | ||
} | ||
} | ||
) | ||
app.renderer.on( | ||
MarkdownPageEvent.BEGIN, | ||
/** | ||
* @param {import('typedoc-plugin-markdown').MarkdownPageEvent} page | ||
*/ | ||
(page) => { | ||
let summary = ''; | ||
if (page.model?.comment?.summary) { | ||
summary = page.model.comment.summary[0].text + '...'; | ||
summary = summary.replace(/\n/g, ' '); | ||
} | ||
page.frontmatter = { | ||
title: page.model?.name, | ||
description: summary, | ||
...page.frontmatter, | ||
}; | ||
}, | ||
); | ||
} |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// @ts-check | ||
import fs from 'fs' | ||
import fs from 'fs'; | ||
|
||
/** | ||
* This plugin parses and generates a navigation file for the documentation | ||
* that complies with Mintlify's navigation format. | ||
* This plugin parses and generates a navigation file for the documentation that complies with Mintlify's navigation | ||
* format. | ||
* | ||
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app | ||
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app | ||
*/ | ||
export function load(app) { | ||
app.renderer.postRenderAsyncJobs.push(async (renderer) => { | ||
const navigation = renderer.navigation | ||
if (!navigation) { | ||
return | ||
} | ||
const formattedNavigation = navigation.map((group) => ({ | ||
group: group.title, | ||
pages: (group.children || []).map((child) => `content/${child.url.replace('.mdx', '')}`), | ||
})) | ||
fs.writeFileSync('./docs/content/navigation.json', JSON.stringify(formattedNavigation, null, 2)) | ||
}) | ||
app.renderer.postRenderAsyncJobs.push(async (renderer) => { | ||
const navigation = renderer.navigation; | ||
if (!navigation) { | ||
return; | ||
} | ||
const formattedNavigation = navigation.map((group) => ({ | ||
group: group.title, | ||
pages: (group.children || []).map((child) => `content/${child.url.replace('.mdx', '')}`), | ||
})); | ||
fs.writeFileSync('./docs/content/navigation.json', JSON.stringify(formattedNavigation, null, 2)); | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,37 +1,38 @@ | ||
{ | ||
// base config | ||
"out": "docs/content", | ||
"tsconfig": "tsconfig.base.json", | ||
"entryPoints": ["./src/quais.ts"], | ||
// base config | ||
"out": "docs/content", | ||
"tsconfig": "tsconfig.base.json", | ||
"entryPoints": ["./src/quais.ts"], | ||
|
||
// specific inclusions and exclusions | ||
"excludeProtected": true, | ||
"excludeNotDocumented": true, | ||
"exclude": ["./src/_admin/**/*", "./src/_tests/**/*", "./src/testcases/**/*"], | ||
// specific inclusions and exclusions | ||
"excludeProtected": true, | ||
"excludeNotDocumented": true, | ||
"exclude": ["./src/_admin/**/*", "./src/_tests/**/*", "./src/testcases/**/*"], | ||
|
||
// plugins | ||
"plugin": [ | ||
"typedoc-plugin-remove-references", // remove additional references that clutter documentation | ||
"typedoc-plugin-markdown", // generate markdown files | ||
"typedoc-plugin-frontmatter", // add frontmatter to markdown files, prereq for the below custom plugin | ||
"./docs/plugins/typedoc-plugin-mintlify-frontmatter.mjs", // formats frontmatter to match mintlify | ||
"./docs/plugins/typedoc-plugin-navigation-output.mjs" // formats navigation to match mintlify | ||
], | ||
// plugins | ||
"plugin": [ | ||
"typedoc-plugin-remove-references", // remove additional references that clutter documentation | ||
"typedoc-plugin-markdown", // generate markdown files | ||
"typedoc-plugin-frontmatter", // add frontmatter to markdown files, prereq for the below custom plugin | ||
"./docs/plugins/typedoc-plugin-mintlify-frontmatter.mjs", // formats frontmatter to match mintlify | ||
"./docs/plugins/typedoc-plugin-navigation-output.mjs", // formats navigation to match mintlify | ||
"./docs/plugins/typedoc-plugin-link-formatter.mjs" // removes ".mdx" from links | ||
], | ||
|
||
// formatting + mintlify compatibility | ||
"fileExtension": ".mdx", // use mdx files for mintlfiy compatibility | ||
"entryFileName": "index.mdx", // rename entry from "README.md" to "index.mdx" | ||
"mergeReadme": true, // merge README.md into index.mdx | ||
"hidePageHeader": true, // hide page header, conflicts with mintlify | ||
"hidePageTitle": true, // hide page title, conflicts with mintlify | ||
"hideBreadcrumbs": true, // hide breadcrumbs, conflicts with mintlify | ||
"useCodeBlocks": true, // makes API definitions more readable | ||
"expandObjects": true, | ||
"parametersFormat": "table", // readability | ||
"propertiesFormat": "table", // readability | ||
"publicPath": "/content/", // format links for mintlify | ||
"navigation": { | ||
"includeCategories": true, | ||
"includeGroups": false | ||
} | ||
// formatting + mintlify compatibility | ||
"fileExtension": ".mdx", // use mdx files for mintlfiy compatibility | ||
"entryFileName": "index.mdx", // rename entry from "README.md" to "index.mdx" | ||
"mergeReadme": true, // merge README.md into index.mdx | ||
"hidePageHeader": true, // hide page header, conflicts with mintlify | ||
"hidePageTitle": true, // hide page title, conflicts with mintlify | ||
"hideBreadcrumbs": true, // hide breadcrumbs, conflicts with mintlify | ||
"useCodeBlocks": true, // makes API definitions more readable | ||
"expandObjects": true, | ||
"parametersFormat": "table", // readability | ||
"propertiesFormat": "table", // readability | ||
"publicPath": "/content/", // format links for mintlify | ||
"navigation": { | ||
"includeCategories": true, | ||
"includeGroups": false | ||
} | ||
} |