Skip to content

feat: unified HTML-to-markdown migration tool for legacy API docs#654

Draft
shczhen wants to merge 1 commit into
mainfrom
worktree-html-to-md-migration
Draft

feat: unified HTML-to-markdown migration tool for legacy API docs#654
shczhen wants to merge 1 commit into
mainfrom
worktree-html-to-md-migration

Conversation

@shczhen

@shczhen shczhen commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a generic migration script that converts DITA-OT (Oxygen XML) generated HTML API reference docs into pure markdown files for the docs portal.

Why

The legacy documentation site has HTML API references generated by DITA-OT across 20+ products and 16+ platforms. Previously, each product required a custom migration script. This unified tool eliminates that duplication.

How it works

node scripts/html-to-md-migration.mjs \
  --source <html-dir> \
  --output <md-dir> \
  --product <name> \
  --platform <name>

The script:

  1. Parses the TOC/sidebar from index.html
  2. Reads all HTML files in the API/ subdirectory
  3. Renders each page as pure markdown with frontmatter
  4. Resolves internal links to portal routes
  5. Writes meta.json for sidebar structure

Supported content types

HTML prefix Type
class_ Class/struct with properties
enum_ Enum type definitions
api_ Method/API with params and returns
callback_ Callback definitions
toc_ / rtc_ Overview and mixed pages

Output format

Pure markdown — no custom MDX components. Uses:

  • Standard headings, tables, code blocks
  • :::info[Note] / :::warning / :::error for admonitions
  • <a id="..."> for stable anchors

Testing

  • 3 Vitest tests pass (help text, dry run, full migration)
  • Validated field-by-field against source HTML (title, shortdesc, properties, notes, links)
  • Fixed a bug where notes containing <ul> were not wrapped in admonition syntax

Files

File Description
scripts/html-to-md-migration.mjs Main migration script
scripts/html-to-md-migration.test.ts Vitest tests
scripts/html-to-md-migration.README.md Usage documentation

Add a generic script that converts DITA-OT generated HTML API reference
documentation into pure markdown files compatible with the docs portal.

The tool handles multiple products and platforms without requiring
per-product custom scripts. It supports:

- Class/struct pages with properties
- Enum type definitions
- Method/API pages with parameters and return values
- Callback definitions
- Nested article structures and TOC pages
- Internal link resolution to portal routes
- Admonition/note rendering (info, warning, error)
- Code blocks with language hints

Includes Vitest tests and README documentation.
@Jiayi-Ye02

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Follow-up issue filed for the current scope gap in this migration script: #673.

That issue tracks clarifying and extending the HTML migration tooling beyond DITA-OT API/*.html exports, specifically for TypeDoc, Doxygen/Javadoc, iOS doc-generator, and Dartdoc/Flutter HTML outputs.

OpenAPI/REST YAML sources are intentionally out of scope because those have already been handled through the OpenAPI migration path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants