feat(docs): export database documentation as standalone HTML

This commit is contained in:
Fernando Possebon authored and GitHub committed 2026-08-08 11:04:16 +08:00
1 parent efd0c381ad
commit 63498da121
59 files changed
+4374 -237

No files matched your search

+1
View File
@@ -381,6 +381,7 @@ async fn main() {
.route("/docs/annotations/load", post(routes::docs::load_annotations))
.route("/docs/annotations/apply", post(routes::docs::apply_annotations))
.route("/docs/annotations/save", post(routes::docs::save_annotations))
.route("/docs/export", post(routes::docs::export_html))
.route("/dialect/data-types", get(routes::dialect::list_data_types))
.route("/schema-diff/prepare", post(routes::schema_diff::prepare_schema_diff))
.route("/schema-diff/generate-sync-sql", post(routes::schema_diff::generate_schema_sync_sql))
+24 -1
View File
@@ -5,7 +5,7 @@ use axum::extract::State;
use axum::Json;
use dbx_core::docs::{CollectOptions, SchemaSnapshot};
use dbx_core::models::connection::ConnectionConfig;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use crate::error::AppError;
use crate::state::WebState;
@@ -112,3 +112,26 @@ pub async fn save_annotations(
dbx_core::docs::annotations::save_annotations(&path, &request.annotations).map_err(AppError::from)?;
Ok(Json(()))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DocsExportRequest {
pub snapshot: SchemaSnapshot,
pub annotations: dbx_core::docs::annotations::AnnotationFile,
pub lang: String,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocsExportResponse {
pub content: String,
}
/// Returns the rendered HTML as a string rather than writing a file: the
/// browser has no filesystem to write to, so `http.ts` downloads this content
/// as a blob instead of the Tauri command's `std::fs::write`.
pub async fn export_html(Json(request): Json<DocsExportRequest>) -> Result<Json<DocsExportResponse>, AppError> {
let content = dbx_core::docs::to_standalone_html(&request.snapshot, &request.annotations, &request.lang)
.map_err(AppError::from)?;
Ok(Json(DocsExportResponse { content }))
}