diff --git a/src/Markdown.ts b/src/Markdown.ts index 546d727..c4f81bf 100644 --- a/src/Markdown.ts +++ b/src/Markdown.ts @@ -61,10 +61,26 @@ const getExamples = (es: ReadonlyArray): string => .map((code) => paragraph(bold("Example")) + paragraph(fence("ts", code))) .join("\n\n") -const getLocationDescription = (projectName: string, module: Domain.Module): string => { +const getImportDescription = ( + projectName: string, + module: Domain.Module, + method: string +): string => { const namespace = module.path.slice(1).join("/").replace(/\.ts$/, "") - return paragraph( - `Part of the \`${module.name}\` module, imported from \`${projectName}/${namespace}\`.` + + return ( + paragraph( + `To import and use \`${method}\` from the "${module.name}" module:` + ) + + paragraph( + fence( + "ts", + `import * as ${module.name} from "${projectName}/${namespace}" + +// Can be accessed like this +${module.name}.${method}` + ) + ) ) } @@ -248,9 +264,9 @@ export const printModule = (module: Domain.Module, order: number): string => { ).join("\n") const tableOfContents = (content: string) => - "

Table of contents

\n\n" - + toc(content).content - + "\n\n" + "

Table of contents

\n\n" + + toc(content).content + + "\n\n" return prettify( [ @@ -277,13 +293,13 @@ export const printPrintableForAI = ( [ h1(printable.name), getDescription(printable.description), - getLocationDescription(projectName, module), + getImportDescription(projectName, module, printable.name), getExamples(printable.examples), - printable._tag === "Function" ? - getSignatures(printable.signatures) : - printable._tag === "Constant" ? - getSignature(printable.signature) : - "" + printable._tag === "Function" + ? getSignatures(printable.signatures) + : printable._tag === "Constant" + ? getSignature(printable.signature) + : "" ].join("\n") )