From f5d8346eccae50d719e4db6804beb818e67beed8 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 3 Apr 2024 22:40:02 +0200 Subject: [PATCH] docs: add jsdocs for main exports (#55) --- src/_parse.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ src/automd.ts | 34 ++++++++++++++++++++++++++++++++-- src/config.ts | 12 ++++++------ src/generator.ts | 14 ++++++++++++++ src/transform.ts | 39 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 132 insertions(+), 9 deletions(-) diff --git a/src/_parse.ts b/src/_parse.ts index 30a7b67..c5cbd8a 100644 --- a/src/_parse.ts +++ b/src/_parse.ts @@ -2,13 +2,38 @@ import { destr } from "destr"; import { camelCase } from "scule"; export interface Block { + /** + * The name of the generator to use for updates. + */ generator: string; + + /** + * The arguments that are passed to the generator. + */ rawArgs: string; + + /** + * The current content of the block. + */ contents: string; + + /** + * The location of the content in the original document. + */ loc: { start: number; end: number }; + + /** + * The location including the automd comments. + */ _loc: { start: number; end: number }; } +/** + * Searches a markdown document for special sections that `automd` can update. + * + * @param md - The markdown document as a string. + * @returns an array of blocks that can be updated automatically. {@link Block} + */ export function findBlocks(md: string): Block[] { const blocks: Block[] = []; @@ -36,10 +61,27 @@ export function findBlocks(md: string): Block[] { return blocks; } +/** + * Checks if a markdown document contains sections that can be automatically updated. + * + * @param md - The markdown document as a string. + * @returns true if there are `automd` sections, false otherwise. + */ export function containsAutomd(md: string) { return /^