MCPcopy Create free account
hub / github.com/Effect-TS/effect / printModule

Function printModule

packages/tools/docgen/src/Printer.ts:320–348  ·  view source on GitHub ↗
(module: Domain.Module)

Source from the content-addressed store, hash-verified

318 * @since 0.6.0
319 */
320export const printModule = (module: Domain.Module) => {
321 return Effect.gen(function*() {
322 const description = yield* printModel(module.name, module.doc, {
323 postfix: "overview"
324 })
325
326 const printables = pipe(
327 sortByName(getPrintables(module)),
328 Array.groupBy((printable) =>
329 printable.doc.category.length === 0 ? DEFAULT_CATEGORY : printable.doc.category.join(", ")
330 ),
331 Record.toEntries,
332 Array.sort(byCategory)
333 )
334
335 const strings = yield* Effect.forEach(printables, ([category, printables]) =>
336 Effect.gen(function*() {
337 const out = `\n\n# ${category}`
338 const strings = yield* Effect.forEach(sortByName(printables), (printable) => print(printable))
339 return out + strings.map((s) => "\n\n" + s).join("")
340 }))
341
342 const content = strings.join("")
343
344 return `${description}
345
346<!-- toc -->${content}`
347 }).pipe(Effect.provideService(Parser.Source, module.source))
348}
349
350const defaultPrettierOptions: Prettier.Options = {
351 parser: "markdown",

Callers

nothing calls this directly

Calls 8

printModelFunction · 0.85
getPrintablesFunction · 0.85
joinMethod · 0.80
printFunction · 0.70
pipeMethod · 0.65
forEachMethod · 0.65
pipeFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected