moondockit

    A MoonBit-first documentation site toolkit with AI-enhanced docs, quality assessment, content summarization, cross-reference detection, coverage analysis, consistency checking, SEO metadata, content recommendations, and test generation.

    documentation
    static-site
    markdown
    moonbit
    mooncakes
    ai
    ai-docs
    quality-assessment
    content-summarization
    cross-reference
    coverage-analysis
    consistency-checker
    seo-metadata
    content-recommendations
    Download zip
    Version
    0.6.0
    License
    Apache-2.0
    Last updated
    last month
    Downloads
    74

    No dependencies

    #MoonDocKit

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

    Try it without installing anything: the real renderer, compiled from this MoonBit source to JavaScript, runs in the browser at https://estrella-11.github.io/moonbit_1/playground/. Type Markdown on the left, see the generated page on the right, with live quality metrics.

    #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. Use --theme package or --theme api for built-in package-guide and API-reference visual presets.

    #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.

    #AI Enhancement

    The ai/ package adds AI-driven documentation tooling:

    • generate_function_doc creates structured docs from API symbols with complexity and usage frequency analysis.
    • assess_page_quality scores completeness, readability, example coverage, and structure (heading hierarchy, title quality, code language detection).
    • aggregate_site_quality generates site-level quality reports with distribution and common suggestions.
    • summarize_page generates content summaries with keyword extraction, content type detection, and audience estimation.
    • detect_cross_references finds page-to-page relationships based on shared keywords and identifies orphan pages.
    • analyze_coverage detects undocumented API symbols and missing fields.
    • check_consistency detects heading style, hierarchy, code label, duplicate content, and length outlier inconsistencies.
    • generate_site_seo produces SEO metadata with meta descriptions, keyword density, and search boost scores.
    • generate_recommendations creates learning paths, next-step suggestions, and related page recommendations.
    • generate_symbol_tests bootstraps test stubs from API references.
    • build_chat_request_json builds OpenAI-compatible request payloads.

    CLI flags: --ai-doc, --ai-quality, --ai-summary, --ai-xref, --ai-coverage, --ai-consistency, --ai-seo, --ai-recommend, --ai-tests.

    #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.

    DocExample

    pub(all) struct DocExample {
    index : Int
    code : String
    }

    One runnable MoonBit example extracted from a fenced code block.

    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.

    I18n

    pub(all) struct I18n {
    search_label : String
    search_placeholder : String
    theme_toggle : String
    skip_link : String
    toc_title : String
    no_results : String
    lang_toggle : String
    }

    Localized UI strings for the generated documentation chrome.

    ListBlock

    pub(all) enum ListBlock {
    ListBlock(ListKind, Array[ListItem])
    }

    A rendered list (root or nested) that owns its marker style.

    ListItem

    pub(all) enum ListItem {
    ListItem(String, Bool?, ListBlock?)
    }

    A single list entry; may carry a checkbox state and a nested sublist.

    ListKind

    pub(all) enum ListKind {
    Bullet
    Number
    }

    Whether a list is bulleted or numbered.

    MarkdownBlock

    pub(all) enum MarkdownBlock {
    Heading(Int, String)
    Paragraph(String)
    List(ListBlock)
    BlockQuote(String)
    CodeBlock(String, String)
    Table(Array[String], Array[TableAlign], Array[Array[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.

    TableAlign

    pub(all) enum TableAlign {
    AlignDefault
    AlignLeft
    AlignCenter
    AlignRight
    }

    Table column alignment parsed from a GFM separator row.

    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.

    api_reference_theme

    fn api_reference_theme() -> SiteTheme

    Return a compact theme tuned for API reference-heavy sites.

    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_quality_report_json

    fn build_quality_report_json(site : DocSite) -> String

    Build a machine-readable quality report for review and CI artifacts.

    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.

    count_doc_examples

    fn count_doc_examples(markdown : String) -> Int

    Count runnable MoonBit examples in one Markdown document.

    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_doc_examples

    fn extract_doc_examples(markdown : String) -> Array[DocExample]

    Extract runnable MoonBit examples from one Markdown document.

    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.

    is_runnable_moonbit_example

    fn is_runnable_moonbit_example(language : String) -> Bool

    Report whether a fenced code block info string marks a runnable MoonBit example. Blocks tagged nocheck are skipped, matching the MoonBit documentation convention, so illustrative snippets stay illustrative.

    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.

    package_theme

    fn package_theme() -> SiteTheme

    Return a warm documentation theme for package guide sites.

    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_doc_test_file

    fn render_doc_test_file(examples : Array[DocExample], import_package : String) -> String

    Render extracted examples as MoonBit test source, one test block per example.

    MoonBit only accepts imports in moon.pkg, so import_package is emitted as a comment telling the caller what the target package must import, rather than as a declaration that would fail to compile.

    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