mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat(utils): JSDoc for all APIs (#6980)
* feat(utils): JSDoc for all APIs * fix tests
This commit is contained in:
parent
b8d2a4e84d
commit
2eeb0e46a2
31 changed files with 637 additions and 255 deletions
|
@ -13,7 +13,7 @@ import type {
|
|||
DocsMarkdownOption,
|
||||
SourceToPermalink,
|
||||
VersionMetadata,
|
||||
BrokenMarkdownLink,
|
||||
DocBrokenMarkdownLink,
|
||||
} from '../../types';
|
||||
import {VERSIONED_DOCS_DIR, CURRENT_VERSION_NAME} from '../../constants';
|
||||
|
||||
|
@ -156,22 +156,22 @@ describe('linkify', () => {
|
|||
filePath: doc5,
|
||||
link: 'docNotExist1.md',
|
||||
contentPaths: versionCurrent,
|
||||
} as BrokenMarkdownLink);
|
||||
} as DocBrokenMarkdownLink);
|
||||
expect(onBrokenMarkdownLink).toHaveBeenNthCalledWith(2, {
|
||||
filePath: doc5,
|
||||
link: './docNotExist2.mdx',
|
||||
contentPaths: versionCurrent,
|
||||
} as BrokenMarkdownLink);
|
||||
} as DocBrokenMarkdownLink);
|
||||
expect(onBrokenMarkdownLink).toHaveBeenNthCalledWith(3, {
|
||||
filePath: doc5,
|
||||
link: '../docNotExist3.mdx',
|
||||
contentPaths: versionCurrent,
|
||||
} as BrokenMarkdownLink);
|
||||
} as DocBrokenMarkdownLink);
|
||||
expect(onBrokenMarkdownLink).toHaveBeenNthCalledWith(4, {
|
||||
filePath: doc5,
|
||||
link: './subdir/docNotExist4.md',
|
||||
contentPaths: versionCurrent,
|
||||
} as BrokenMarkdownLink);
|
||||
} as DocBrokenMarkdownLink);
|
||||
});
|
||||
|
||||
it('transforms absolute links in versioned docs', async () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
|||
} from './types';
|
||||
|
||||
import _ from 'lodash';
|
||||
import {getElementsAround, toMessageRelativeFilePath} from '@docusaurus/utils';
|
||||
import {toMessageRelativeFilePath} from '@docusaurus/utils';
|
||||
import type {DocMetadataBase, DocNavLink} from '../types';
|
||||
|
||||
export function isCategoriesShorthand(
|
||||
|
@ -225,11 +225,11 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|||
return {sidebarName, next: undefined, previous: undefined};
|
||||
}
|
||||
|
||||
const {previous, next} = getElementsAround(
|
||||
navigationItems,
|
||||
currentItemIndex,
|
||||
);
|
||||
return {sidebarName, previous, next};
|
||||
return {
|
||||
sidebarName,
|
||||
previous: navigationItems[currentItemIndex - 1],
|
||||
next: navigationItems[currentItemIndex + 1],
|
||||
};
|
||||
}
|
||||
|
||||
function getCategoryGeneratedIndexList(): SidebarItemCategoryWithGeneratedIndex[] {
|
||||
|
@ -268,11 +268,11 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|||
const currentItemIndex = navigationItems.findIndex(
|
||||
isCurrentCategoryGeneratedIndexItem,
|
||||
);
|
||||
const {previous, next} = getElementsAround(
|
||||
navigationItems,
|
||||
currentItemIndex,
|
||||
);
|
||||
return {sidebarName, previous, next};
|
||||
return {
|
||||
sidebarName,
|
||||
previous: navigationItems[currentItemIndex - 1],
|
||||
next: navigationItems[currentItemIndex + 1],
|
||||
};
|
||||
}
|
||||
|
||||
function checkSidebarsDocIds(validDocIds: string[], sidebarFilePath: string) {
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
/// <reference types="@docusaurus/module-type-aliases" />
|
||||
|
||||
import type {Sidebars} from './sidebars/types';
|
||||
import type {Tag, FrontMatterTag} from '@docusaurus/utils';
|
||||
import type {
|
||||
BrokenMarkdownLink as IBrokenMarkdownLink,
|
||||
Tag,
|
||||
FrontMatterTag,
|
||||
BrokenMarkdownLink,
|
||||
ContentPaths,
|
||||
} from '@docusaurus/utils/lib/markdownLinks';
|
||||
} from '@docusaurus/utils';
|
||||
import type {VersionBanner} from '@docusaurus/plugin-content-docs';
|
||||
|
||||
export type DocFile = {
|
||||
|
@ -133,11 +134,11 @@ export type LoadedContent = {
|
|||
loadedVersions: LoadedVersion[];
|
||||
};
|
||||
|
||||
export type BrokenMarkdownLink = IBrokenMarkdownLink<VersionMetadata>;
|
||||
export type DocBrokenMarkdownLink = BrokenMarkdownLink<VersionMetadata>;
|
||||
|
||||
export type DocsMarkdownOption = {
|
||||
versionsMetadata: VersionMetadata[];
|
||||
siteDir: string;
|
||||
sourceToPermalink: SourceToPermalink;
|
||||
onBrokenMarkdownLink: (brokenMarkdownLink: BrokenMarkdownLink) => void;
|
||||
onBrokenMarkdownLink: (brokenMarkdownLink: DocBrokenMarkdownLink) => void;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue