Skip to content

Commit c8e8c43

Browse files
committed
chore(docs): added troubleshooting docs page
1 parent 90c1490 commit c8e8c43

File tree

11 files changed

+93
-43
lines changed

11 files changed

+93
-43
lines changed

devtools/packages/prebuild-options/tasks/generate-docs.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ asIndexPage: true
2929
outputPage.push('# Plugin Options');
3030
if (docsConfig.docsPath === '/docs') {
3131
outputPage.push(
32-
`This page documents additional options that are exposed by this plugin.
33-
34-
*Note: The options must be set at root level and will be ignored inside [packageOptions](https://typedoc.org/documents/Options.Package_Options.html).*`,
32+
`This page documents additional options that are exposed by this plugin.`,
3533
);
3634
} else {
3735
if (docsConfig.presets) {
@@ -145,10 +143,10 @@ ${presetsJson}
145143
? `import { Callout, FileTree } from 'nextra/components';`
146144
: '',
147145
];
148-
const optionLevel =
149-
categories.length === 1 && !docsConfig.presets ? '##' : '###';
146+
let optionLevel = categories.length > 1 ? '##' : '###';
150147
if (categories.length > 1) {
151148
out.push(`# ${getDocsTitle(categoryName)}`);
149+
optionLevel = '##';
152150
if (Object.keys(categoryDescriptions)?.length) {
153151
out.push(categoryDescriptions[categoryName]);
154152
}

docs/app/layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const footer = <Footer></Footer>;
4141

4242
export default async function RootLayout({ children }) {
4343
return (
44-
<html lang="en" dir="ltr" suppressHydrationWarning>
44+
<html lang="en" dir="ltr">
4545
<Head>
4646
<link rel="icon" href="/logos/markdown-logo.svg" type="image/png" />
4747
</Head>

docs/components/option-link.jsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import Link from 'next/link';
2-
31
export const OptionLink = ({ type, name }) => {
42
return (
5-
<Link
3+
<a
64
href={`/docs/options/${type}-options#${name.toLowerCase()}`}
7-
className="whitespace-nowrap _text-primary-600 _underline _decoration-from-font [text-underline-position:from-font]"
5+
className="x:focus-visible:nextra-focus x:text-primary-600 x:underline x:hover:no-underline x:decoration-from-font x:[text-underline-position:from-font]"
86
>
9-
<code class="nextra-code">{name}</code>
10-
</Link>
7+
<code className="nextra-code">{name}</code>
8+
</a>
119
);
1210
};

docs/components/package-description.jsx

-16
This file was deleted.

docs/components/package-version.jsx

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import { readFileSync } from 'fs';
2-
import * as path from 'path';
1+
import { packageVersions } from '../utils/package-versions';
2+
3+
export function PackageVersion({ name }) {
4+
const version = packageVersions[name];
35

4-
export async function PackageVersion({ name }) {
5-
const packageJsonPath = path.join(
6-
process.cwd(),
7-
`../packages/${name}/package.json`,
8-
);
9-
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
106
return (
117
<strong className="inline-flex items-center rounded-md bg-gray-100 px-2 py-1 mt-3 text-sm font-bold text-gray-600 ring-1 ring-inset ring-gray-500/10">
12-
Version: {packageJson.version}
8+
Version: {version}
139
</strong>
1410
);
1511
}

docs/content/docs/_meta.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default {
1919
type: 'separator',
2020
title: 'Support',
2121
},
22+
troubleshooting: '',
2223
versioning: '',
2324
CHANGELOG: 'Changelog',
2425
'migration-guide': 'Migration Guide (v4)',

docs/content/docs/index.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
title: 'Introduction'
33
---
44

5-
import { Cards, Callout } from 'nextra/components';
6-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
{/* prettier-ignore */}
76
import { faGithub } from '@fortawesome/free-brands-svg-icons';
7+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8+
import { Callout, Cards } from 'nextra/components';
89

910
# typedoc-plugin-markdown
1011

docs/content/docs/options/index.mdx

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { Callout } from 'nextra/components';
88

99
This page documents additional options that are exposed by this plugin.
1010

11-
_Note: The options must be set at root level and will be ignored inside [packageOptions](https://typedoc.org/documents/Options.Package_Options.html)._
12-
1311
## File Options
1412

1513
Options that are used by the plugin's [routers](/docs/output-file-structure) to configure how files are output.

docs/content/docs/troubleshooting.mdx

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Troubleshooting
2+
3+
This guide covers common issues you may encounter when using the typedoc-plugin-markdown, along with solutions and explanations.
4+
5+
## TypeDoc Loaded Multiple Times
6+
7+
**Symptom:**
8+
9+
You're running TypeDoc and see the following error which is preventing docs from being generated:
10+
11+
> **[warning] TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc.**
12+
13+
**Why?**:
14+
15+
This plugin declares TypeDoc as a peer dependency, so it won't install TypeDoc automatically.
16+
17+
If you're running TypeDoc in a standard setup and you're seeing this warning, your package manager is likely resolving dependencies in a way that causes multiple instances of TypeDoc to be loaded.
18+
19+
When installing globally, be aware of [npm/cli#7057](https://github.com/npm/cli/issues/7057).
20+
21+
**Solution:**
22+
23+
Use the `--legacy-peer-deps` flag when installing packages.
24+
25+
## `packageOptions` Not Working
26+
27+
**Symptom:**
28+
29+
You are setting options inside `packageOptions`, but they are being ignored.
30+
31+
**Why?**
32+
33+
The `packageOptions` field only applies to conversion options. Options exposed by this plugin apply during rendering, not conversion. That's why they won't work if placed inside `packageOptions`.
34+
35+
**Solution:**
36+
37+
Place all plugin specific options at the root level of your TypeDoc configuration.
38+
39+
See [TypeDoc packageOptions](https://typedoc.org/documents/Options.Package_Options.html).
40+
41+
## MDX Compilation Failed
42+
43+
**Symptom:**
44+
45+
You're using an MDX parser and see this error (or similar):
46+
47+
> **Error: MDX compilation failed**
48+
>
49+
> Cause: Could not parse expression with acorn
50+
51+
**Why?**
52+
53+
This is almost certainly caused by invalid MDX syntax in doc comments.
54+
55+
**Solution:**
56+
57+
- Wrap invalid MDX in backticks to treat it as a code block.
58+
- Enable <OptionLink type="utility" name="sanitizeComments" /> to automatically escape problematic characters.
59+
- Switch to CommonMark, if supported by your parser.

docs/mdx-components.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useMDXComponents as getThemeComponents } from 'nextra-theme-docs';
22
import { OptionLink } from './components/option-link';
3-
import { PackageDescription } from './components/package-description';
43
import { PackageVersion } from './components/package-version';
54

65
// Get the default MDX components
@@ -11,7 +10,6 @@ export function useMDXComponents(components) {
1110
return {
1211
...themeComponents,
1312
...components,
14-
PackageDescription,
1513
PackageVersion,
1614
OptionLink,
1715
};

docs/utils/package-versions.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { readFileSync } from 'fs';
2+
import path from 'path';
3+
4+
function getVersion(name: string): string {
5+
const packageJsonPath = path.join(
6+
process.cwd(),
7+
'../packages',
8+
name,
9+
'package.json',
10+
);
11+
const json = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
12+
return json.version;
13+
}
14+
15+
export const packageVersions = {
16+
'typedoc-plugin-markdown': getVersion('typedoc-plugin-markdown'),
17+
};

0 commit comments

Comments
 (0)