
Model.pudu
Pudu61 lines1.9 KB
1/** @Docgen.Api.Model — declarations of Pudu modules as documented reference items */2module PuduLangDocgen.Api.Model34/** @Docgen.Api.Parameter — one named parameter and its written type */5export type Parameter = { name: Str, kind: Str }67/** @Docgen.Api.Member — a declaration: function, type, trait, constant, field, variant, or method */8export type Member = {9 uid: Str,10 name: Str,11 kind: Str,12 signature: Str,13 doc: Str,14 line: Int,15 exported: Bool,16 parameters: Array[Parameter],17 returns: Str,18 members: Array[Member]19}2021/** @Docgen.Api.Implementation — a trait implemented for a type, with documented methods */22export type Implementation = { contract: Str, target: Str, line: Int, methods: Array[Member] }2324/** @Docgen.Api.Unit — one module: its documentation, imports, declarations, and implementations */25export type Unit = {26 uid: Str,27 path: Str,28 doc: Str,29 line: Int,30 imports: Array[(Str, Str)],31 members: Array[Member],32 implementations: Array[Implementation]33}343536export fn isType(kind: Str) -> Bool {37 kind == "record" || kind == "union" || kind == "alias" || kind == "opaque" || kind == "trait"38}394041export fn summary(doc: Str) -> Str {42 var lines: Array[Str] = []43 for line in doc.split("\n") {44 if line.trim().isEmpty() {45 if !lines.isEmpty() { break }46 } else if line.trim().startsWith("#") || line.trim().startsWith("```") {47 break48 } else { lines = lines.push(line.trim()) }49 }50 lines.join(" ")51}525354export fn remarks(doc: Str) -> Str {55 let lines = doc.split("\n")56 var index = 057 while index < lines.length() && lines[index].trim().isEmpty() { index = index + 1 }58 while index < lines.length() && !lines[index].trim().isEmpty() && !lines[index].trim().startsWith("#") && !lines[index].trim().startsWith("```") { index = index + 1 }59 lines.slice(index, lines.length()).join("\n").trim()60}61