Files
zeekay 084b847d33 rebrand: complete white-label — all packages @hanzo/docs-* (one brand)
Finish the fumadocs→Hanzo Docs rebrand: rename the remaining fuma-named
workspace packages and every reference so the framework is uniformly
@hanzo/docs-*. One brand, no Fuma in package names or product surface.

Package renames (name field + all refs: deps, imports, CSS @import,
configs, .changeset, next/vite build config):
  fumadocs-core        → @hanzo/docs-core
  fumadocs-mdx         → @hanzo/docs-mdx
  fumadocs-ui          → @hanzo/docs-ui          (packages/radix-ui)
  fumadocs-openapi     → @hanzo/docs-openapi
  fumadocs-preview     → @hanzo/docs-preview
  @fumadocs/base-ui    → @hanzo/docs-base-ui
  @fumadocs/basehub    → @hanzo/docs-basehub
  @fumadocs/language   → @hanzo/docs-language
  @fumadocs/local-md   → @hanzo/docs-local-md
  @fumadocs/sanity     → @hanzo/docs-sanity
  @fumadocs/shadcn     → @hanzo/docs-shadcn
  @fumadocs/vite       → @hanzo/docs-vite
  @fumari/stf          → @hanzo/docs-stf
  create-fumadocs-app  → @hanzo/create-docs
  create-fumadocs-versions → @hanzo/docs-create-versions

Stale @fumadocs/{cli,story,tailwind,mdx-remote,...} references collapsed to
their existing @hanzo/docs-* canonical packages (no dup created).

De-branded product strings: Fumadocs/Fuma prose → Hanzo Docs/Hanzo; site
branding, CLI output, doc copy, AI-assistant name, metadata. URLs
fumadocs.dev → docs.hanzo.ai, repo fuma-nama/fumadocs → hanzoai/docs.
Filesystem renames: packages/python/fumapy → hanzodocs_py, preview config,
what-is-fumadocs.mdx → what-is-hanzo-docs.mdx, api/fumadocs-ui route.

KEPT (real external npm deps / attribution — NOT renamed):
  fuma-cli, fuma-content, @fumari/json-schema-ts (published upstream pkgs),
  typesense-/trieve-fumadocs-adapter (3rd-party search adapters),
  LICENSE "Copyright (c) 2023 Fuma" (OSS attribution, all 7 LICENSE files
  untouched), CHANGELOG.md history (accurate release records, left as-is).

Build: node 24, pnpm install clean; all 4 target apps next build GREEN
(spec, gui-docs, zen-docs, base-docs) + full package closure (18/18 turbo).
Gate: zero @hanzo-package fumadocs-/@fumadocs/ references remain.
2026-06-24 23:21:42 -07:00

134 lines
3.9 KiB
TypeScript

import { expect, test } from 'vitest';
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { renderToStaticMarkup } from 'react-dom/server';
import { executorNative } from '@/js/executor-native';
import { CompileResult, createMarkdownCompiler } from '@/md/compiler';
import { fromAst, fromJS } from '@/md/renderer';
import type { TOCItemType } from '@hanzo/docs-core/toc';
const cwd = path.dirname(fileURLToPath(import.meta.url));
const fixturesDir = path.join(cwd, 'fixtures');
async function readFixture(name: string) {
const filePath = path.join(fixturesDir, name);
const content = await fs.readFile(filePath, 'utf8');
return { filePath, content };
}
function serializeToc(toc: TOCItemType[] | undefined) {
if (!toc?.length) return [];
return toc.map((item) => ({
url: item.url,
depth: item.depth,
_step: item._step,
titleHtml: renderToStaticMarkup(item.title),
}));
}
function getRenderer(result: CompileResult) {
if (result.type === 'ast')
return fromAst({
filePath: result.file.path,
tree: result.tree,
rehypeToc: result.file.data.rehypeToc,
structuredData: result.file.data.structuredData,
});
return fromJS({
filePath: result.file.path,
code: result.code,
structuredData: result.file.data.structuredData,
});
}
function getRendererNative(result: CompileResult) {
if (result.type === 'ast')
return fromAst({
filePath: result.file.path,
tree: result.tree,
rehypeToc: result.file.data.rehypeToc,
structuredData: result.file.data.structuredData,
executor: executorNative,
});
return fromJS({
filePath: result.file.path,
code: result.code,
baseUrl: pathToFileURL(result.file.path).href,
structuredData: result.file.data.structuredData,
});
}
const cases = [
{ name: 'simple', file: 'simple.md' },
{ name: 'rich', file: 'rich.md' },
{ name: 'expressions', file: 'expressions.mdx' },
{ name: 'jsx', file: 'jsx.mdx' },
] as const;
for (const { name, file } of cases) {
test(`compiler: ${name}`, async () => {
const { filePath, content } = await readFixture(file);
const compiler = createMarkdownCompiler();
const out = await compiler.compile({ path: filePath, value: content });
const payload =
out.type === 'ast'
? {
tree: out.tree,
data: out.file.data,
}
: {
code: out.code,
data: out.file.data,
};
await expect(JSON.stringify(payload, null, 2)).toMatchFileSnapshot(
path.join(fixturesDir, `${name}.compiler.json`),
);
});
test(`renderer: ${name}`, async () => {
const { filePath, content } = await readFixture(file);
const compiler = createMarkdownCompiler();
const compiled = await compiler.compile({
path: filePath,
value: content,
});
const renderer = getRenderer(compiled);
const { body, toc } = await renderer.render();
const payload = {
structuredData: renderer.structuredData,
bodyHtml: renderToStaticMarkup(body),
toc: serializeToc(toc),
};
await expect(JSON.stringify(payload, null, 2)).toMatchFileSnapshot(
path.join(fixturesDir, `${name}.renderer.json`),
);
});
test(`renderer (native): ${name}`, async () => {
const { filePath, content } = await readFixture(file);
const compiler = createMarkdownCompiler();
const compiled = await compiler.compile({
path: filePath,
value: content,
});
const renderer = getRendererNative(compiled);
const { body, toc } = await renderer.render();
const payload = {
structuredData: renderer.structuredData,
bodyHtml: renderToStaticMarkup(body),
toc: serializeToc(toc),
};
await expect(JSON.stringify(payload, null, 2)).toMatchFileSnapshot(
path.join(fixturesDir, `${name}.renderer.native.json`),
);
});
}