add hideDescription flag to JsDoc

This commit is contained in:
Felix Roos 2023-01-07 22:11:47 +01:00
parent 3992356517
commit 5733e00908
2 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import jsdoc from '../../../doc.json'; // doc.json is built with `npm run jsdoc-
const docs = jsdoc.docs.reduce((acc, obj) => Object.assign(acc, { [obj.longname]: obj }), {});
import { MiniRepl } from './MiniRepl';
export function JsDoc({ name, h = 3 }) {
export function JsDoc({ name, h = 3, hideDescription }) {
const item = docs[name];
if (!item) {
console.warn('Not found: ' + name);
@ -16,7 +16,7 @@ export function JsDoc({ name, h = 3 }) {
return (
<>
{!!h && <CustomHeading>{item.longname}</CustomHeading>}
<div dangerouslySetInnerHTML={{ __html: description }} />
{!hideDescription && <div dangerouslySetInnerHTML={{ __html: description }} />}
<ul>
{item.params?.map((param, i) => (
<li key={i}>

View File

@ -47,6 +47,7 @@ Usage:
- `name`: function name, as named with `@name` in jsdoc
- `h`: level of heading. `0` will hide the heading. Hiding it allows using a manual heading which results in a nav link being generated in the right sidebar.
- `hideDescription`: if set, the description will be hidden
### Writing jsdoc