feat(utils): JSDoc for all APIs (#6980)

* feat(utils): JSDoc for all APIs

* fix tests
This commit is contained in:
Joshua Chen 2022-03-24 21:34:31 +08:00 committed by GitHub
parent b8d2a4e84d
commit 2eeb0e46a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 637 additions and 255 deletions

View file

@ -10,12 +10,24 @@ import GithubSlugger from 'github-slugger';
// We create our own abstraction on top of the lib:
// - unify usage everywhere in the codebase
// - ability to add extra options
export type SluggerOptions = {maintainCase?: boolean};
export type SluggerOptions = {
/** Keep the headings' casing, otherwise make all lowercase. */
maintainCase?: boolean;
};
export type Slugger = {
/**
* Takes a Markdown heading like "Josh Cena" and sluggifies it according to
* GitHub semantics (in this case `josh-cena`). Stateful, because if you try
* to sluggify "Josh Cena" again it would return `josh-cena-1`.
*/
slug: (value: string, options?: SluggerOptions) => string;
};
/**
* A thin wrapper around github-slugger. This is a factory function that returns
* a stateful Slugger object.
*/
export function createSlugger(): Slugger {
const githubSlugger = new GithubSlugger();
return {