Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-docgen

Documentation publishing for Pudu: articles, API references, navigation, search, and static websites

0.1.0Apache-2.01

InstallClose

CustomBuild.pudu

Pudu43 lines1.6 KB

GitHub ↗
1/** @Samples.CustomBuild.Program — a site built from Pudu code with a page transform and a post-processor */2module CustomBuild34import Std.Io as Io5import PuduLangDocgen.Build as Build6import PuduLangDocgen as Docgen7import PuduLangDocgen.Docset as Docset89// <transform>10/// Adds a review notice to the end of every article.11fn reviewed(page: Docgen.Page) -> Docgen.Page {12  if page.kind != "article" { return page }13  Docgen.Page{..page, body: page.body + "<p class=\"review-note\">Reviewed for release 0.1.</p>\n"}14}15// </transform>1617// <postprocess>18/// Adds a robots.txt that points crawlers at the sitemap.19fn robots(artifacts: Array[Docgen.Artifact]) -> Array[Docgen.Artifact] {20  let text = "User-agent: *\nAllow: /\nSitemap: https://docs.example.com/sitemap.xml\n"21  artifacts.push(Docgen.Artifact{path: "robots.txt", content: text})22}23// </postprocess>2425// <main>26/// Builds the project and prints every diagnostic; answers 0 on success and 1 on failure.27fn main() -> Int {28  let extending = Build.Extensions{pages: [reviewed], artifacts: [robots]}29  let chosen = Docset.Options{..Docset.options(), output: "_preview", warningsAsErrors: true}30  match Docset.build("docs/docgen.json", &chosen, &extending) {31    case Ok(report) => {32      for problem in report.diagnostics { let _said = Io.writeLine(Docgen.describe(&problem)) }33      let _summary = Io.writeLine("written " + show(report.written.length()) + ", unchanged " + show(report.unchanged.length()) + ", removed " + show(report.removed.length()))34      035    }36    case Err(problems) => {37      for problem in problems { let _said = Io.writeErrorLine(Docgen.describe(&problem)) }38      139    }40  }41}42// </main>43