moondockit

A MoonBit-first documentation site toolkit for package authors.

documentation
static-site
markdown
moonbit
mooncakes
moon add Estrella-11/moondockit@0.1.0
Download zip
Version
0.1.0
License
Apache-2.0
Last updated
last month
Downloads
23
README

#MoonDocKit

MoonDocKit is a MoonBit-first toolkit for turning package guides and generated interfaces into deployable static documentation sites.

#Library API

Create pages and build a deterministic output manifest:

///|
let guide : @moondockit.DocPage = {
title: "Quick Start",
slug: "quick-start",
source: "# Quick Start\n\nBuild MoonBit documentation.",
}

///|
let site : @moondockit.DocSite = { title: "Package Docs", pages: [guide] }

///|
let files = @moondockit.build_site_manifest(site)

The manifest contains a root page, rendered HTML pages, a JSON search index, an XML sitemap, and robots.txt without performing filesystem access.

#MoonBit API Documentation

Run moon info, then convert the generated interface into a documentation page:

///|
let api_page = @moondockit.mbti_to_page(interface_source)

parse_mbti extracts public functions, structs, enums, and traits. The bundled JavaScript-targeted CLI accepts --api pkg.generated.mbti to combine generated API documentation with handwritten Markdown guides.

The CLI also accepts --language, --description, --footer, and --site-url so package authors can configure generated metadata without editing renderer code.

#Quality and Validation

  • validate_site reports route and content diagnostics.
  • measure_site returns documentation metrics.
  • evaluate_quality returns explainable publish-readiness checks and a score.
  • inspect_manifest summarizes generated file types and sizes.

#Safety and Portability

Generated HTML escapes source text and sanitizes unsafe links. The reusable library is backend-neutral; Node.js is used only by the optional CLI filesystem adapter.

Repository: https://github.com/Estrella-11/moonbit_1

Mirror: https://gitlink.org.cn/Estrella/moonbit

Public docs: https://estrella-11.github.io/moonbit_1/

Generated API reference: https://estrella-11.github.io/moonbit_1/api-reference.html

Adoption guide: docs/adoption-playbook.md

Ecosystem impact: docs/ecosystem-impact.md

License: Apache-2.0

#
AnchoredHeading

pub(all) struct AnchoredHeading {
level : Int
title : String
anchor : String
}

A heading with a page-unique anchor.

#
ApiReference

pub(all) struct ApiReference {
package_name : String
symbols : Array[ApiSymbol]
}

Public package information extracted from a .mbti interface.

#
ApiSymbol

pub(all) struct ApiSymbol {
kind : String
name : String
signature : String
arity : Int
return_type : String
}

One public declaration extracted from a generated MoonBit interface.

#
BuildReport

pub(all) struct BuildReport {
file_count : Int
html_count : Int
data_count : Int
total_bytes : Int
files : Array[OutputFileInfo]
}

Aggregate report for generated output files.

#
DiagnosticLevel

pub(all) enum DiagnosticLevel {
DiagError
DiagWarning
}

Severity level for site validation diagnostics.

#
DocPage

pub(all) struct DocPage {
title : String
slug : String
source : String
}

A source page in a MoonDocKit documentation site.

#
DocSite

pub(all) struct DocSite {
title : String
pages : Array[DocPage]
}

Site metadata and pages.

#
DocumentMetrics

pub(all) struct DocumentMetrics {
heading_count : Int
paragraph_count : Int
list_item_count : Int
code_block_count : Int
word_count : Int
reading_minutes : Int
}

Content metrics for one parsed documentation page.

#
FrontMatter

pub(all) struct FrontMatter {
title : String?
order : Int?
tags : Array[String]
fields : Array[(String, String)]
}

Parsed page metadata from a leading front matter block.

#
MarkdownBlock

pub(all) enum MarkdownBlock {
Heading(Int, String)
Paragraph(String)
UnorderedList(Array[String])
BlockQuote(String)
CodeBlock(String, String)
}

Block-level Markdown nodes used by the documentation pipeline.

#
OutputFile

pub(all) struct OutputFile {
path : String
content : String
}

A generated output file ready for a CLI to write to disk.

#
OutputFileInfo

pub(all) struct OutputFileInfo {
path : String
kind : String
byte_count : Int
}

File metadata derived from a generated output manifest.

#
ParsedDocument

pub(all) struct ParsedDocument {
front_matter : FrontMatter
blocks : Array[MarkdownBlock]
}

Markdown source split into metadata and body blocks.

#
QualityCheck

pub(all) struct QualityCheck {
name : String
passed : Bool
message : String
}

One quality gate check result.

#
QualityGate

pub(all) struct QualityGate {
passed : Bool
score : Int
checks : Array[QualityCheck]
}

Aggregate quality gate result for a documentation site.

#
RenderedPage

pub(all) struct RenderedPage {
path : String
html : String
}

A rendered page that can be written to disk by a CLI package.

#
RouteEntry

pub(all) struct RouteEntry {
title : String
slug : String
path : String
order : Int?
tags : Array[String]
}

Planned route metadata for one documentation page.

#
SearchEntry

pub(all) struct SearchEntry {
title : String
path : String
text : String
tags : Array[String]
}

Searchable text metadata for one route.

#
SiteDiagnostic

pub(all) struct SiteDiagnostic {
level : DiagnosticLevel
code : String
message : String
page : String?
}

A validation finding for a site or one source page.

#
SiteMetrics

pub(all) struct SiteMetrics {
page_count : Int
heading_count : Int
code_block_count : Int
word_count : Int
reading_minutes : Int
}

Aggregate content metrics for a documentation site.

#
SiteOptions

pub(all) struct SiteOptions {
language : String
description : String
site_url : String
footer : String
}

Page template options used by generated HTML pages.

#
SiteSummary

pub(all) struct SiteSummary {
page_count : Int
output_count : Int
search_entry_count : Int
tag_count : Int
}

Aggregate metadata for a documentation site.

#
SiteTheme

pub(all) struct SiteTheme {
background : String
surface : String
text : String
accent : String
border : String
code_background : String
code_text : String
sidebar_width_px : Int
content_width_px : Int
}

Visual theme values used by generated HTML pages.

#
TocItem

pub(all) struct TocItem {
level : Int
title : String
anchor : String
}

A heading entry extracted from a source page.

#
ValidationReport

pub(all) struct ValidationReport {
diagnostics : Array[SiteDiagnostic]
}

Site validation result returned before rendering or publishing.

#
blocks_to_toc

fn blocks_to_toc(blocks : Array[MarkdownBlock]) -> Array[TocItem]

Extract heading entries from parsed Markdown blocks.

#
build_index_page

fn build_index_page(site : DocSite) -> String?

Build a lightweight root page that directs visitors to the first route.

#
build_output_manifest_json

fn build_output_manifest_json(files : Array[OutputFile]) -> String

Build a machine-readable manifest for generated output files.

#
build_robots_txt

fn build_robots_txt() -> String

Build a robots.txt file that points crawlers to the generated sitemap.

#
build_search_index

fn build_search_index(site : DocSite) -> String

Build a small JSON search index for the rendered site.

#
build_site_manifest

fn build_site_manifest(site : DocSite) -> Array[OutputFile]

Build all static output files for a site without touching the filesystem.

#
build_site_manifest_with_options

fn build_site_manifest_with_options(site : DocSite, theme : SiteTheme, options : SiteOptions) -> Array[OutputFile]

Build all static output files using custom theme and template options.

#
build_site_manifest_with_theme

fn build_site_manifest_with_theme(site : DocSite, theme : SiteTheme) -> Array[OutputFile]

Build all static output files for a site using a custom theme.

#
build_site_report

fn build_site_report(site : DocSite) -> BuildReport

Build a report for the default generated site manifest.

#
build_sitemap

fn build_sitemap(site : DocSite) -> String

Build a minimal XML sitemap for generated HTML pages.

#
collect_search_entries

fn collect_search_entries(site : DocSite) -> Array[SearchEntry]

Collect structured search entries before JSON serialization.

#
default_site_options

fn default_site_options() -> SiteOptions

Return default generated page metadata and footer options.

#
default_theme

fn default_theme() -> SiteTheme

Return the default MoonDocKit page theme.

#
diagnostics_to_text

fn diagnostics_to_text(report : ValidationReport) -> String

Render diagnostics as stable text for CLI output and logs.

#
empty_front_matter

fn empty_front_matter() -> FrontMatter

Return empty front matter metadata.

#
evaluate_quality

fn evaluate_quality(site : DocSite) -> QualityGate

Evaluate a documentation site against basic publish-readiness checks.

#
extract_headings

fn extract_headings(blocks : Array[MarkdownBlock]) -> Array[AnchoredHeading]

Extract headings and assign page-unique anchors.

#
extract_toc

fn extract_toc(markdown : String) -> Array[TocItem]

Extract level-1 and level-2 headings from Markdown source.

#
has_validation_errors

fn has_validation_errors(report : ValidationReport) -> Bool

Return true when a validation report contains at least one error.

#
html_escape

fn html_escape(input : String) -> String

Escape text for safe HTML output.

#
inspect_manifest

fn inspect_manifest(files : Array[OutputFile]) -> BuildReport

Inspect generated output files and return a deterministic build report.

#
mbti_to_page

fn mbti_to_page(source : String) -> DocPage

Convert a generated MoonBit interface into a documentation page.

#
measure_blocks

fn measure_blocks(blocks : Array[MarkdownBlock]) -> DocumentMetrics

Measure content size and structure for parsed Markdown blocks.

#
measure_document

fn measure_document(markdown : String) -> DocumentMetrics

Measure content size and structure for one Markdown document.

#
measure_site

fn measure_site(site : DocSite) -> SiteMetrics

Measure aggregate content size and structure for all site pages.

#
parse_blocks

fn parse_blocks(markdown : String) -> Array[MarkdownBlock]

Parse a useful Markdown subset into block-level nodes.

#
parse_document

fn parse_document(markdown : String) -> ParsedDocument

Parse optional front matter and Markdown blocks.

#
parse_mbti

fn parse_mbti(source : String) -> ApiReference

Parse a generated MoonBit interface into public API declarations.

#
plan_routes

fn plan_routes(site : DocSite) -> Array[RouteEntry]

Build a stable route table for all pages in a site.

#
render_blocks

fn render_blocks(blocks : Array[MarkdownBlock]) -> String

Render parsed Markdown blocks to HTML.

#
render_markdown

fn render_markdown(markdown : String) -> String

Render a useful subset of Markdown into HTML.

#
render_page

fn render_page(site : DocSite, page : DocPage) -> RenderedPage

Render a complete HTML page with navigation.

#
render_page_with_options

fn render_page_with_options(site : DocSite, page : DocPage, theme : SiteTheme, options : SiteOptions) -> RenderedPage

Render a complete HTML page with custom theme and template options.

#
render_page_with_theme

fn render_page_with_theme(site : DocSite, page : DocPage, theme : SiteTheme) -> RenderedPage

Render a complete HTML page with navigation and a custom theme.

#
render_site

fn render_site(site : DocSite) -> Array[RenderedPage]

Render all pages in a documentation site.

#
render_site_with_options

fn render_site_with_options(site : DocSite, theme : SiteTheme, options : SiteOptions) -> Array[RenderedPage]

Render all pages in a documentation site with custom theme and options.

#
render_site_with_theme

fn render_site_with_theme(site : DocSite, theme : SiteTheme) -> Array[RenderedPage]

Render all pages in a documentation site with a custom theme.

#
slugify

fn slugify(title : String) -> String

Convert a heading or page title into a stable URL slug.

#
summarize_site

fn summarize_site(site : DocSite) -> SiteSummary

Summarize the generated site for demos, logs and validation.

#
validate_site

fn validate_site(site : DocSite) -> ValidationReport

Validate a site before rendering or publishing.

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io