Skip to content

Slice 2: Component Registry + metadata pilot (component #26) #3

Description

@qwerkilo

Parent

#1 — context2html Framework

What to build

Add YAML front matter to component #26 (components/26-ECharts 交互式图表集.md) as the pilot, then build context2html/registry.py that can parse it.

Component metadata format (YAML front matter in the .md file):

---
id: 26
name: ECharts 交互式图表集
dependencies: [echarts.min.js, echarts-gl.min.js]
compat_types: [report, article, doc, tutorial, note]
degrade_to: "05"
requires_3d: false
---

Registry API:

  • ComponentRegistry.list_components(content_type=None) → list of ComponentInfo (id, name, compat_types)
  • ComponentRegistry.get_component(id)Component object (metadata + html + css + js)
  • ComponentRegistry.resolve_dependencies(component_ids) → deduplicated list of lib file names

Component fields: id, metadata (ComponentMeta), html, css, js.

ComponentMeta fields: name, dependencies, compat_types, degrade_to, requires_3d.

The existing scripts/extract-component.py continues to work unmodified — the code-block extraction logic stays the same; the front matter is parsed alongside it.

Acceptance criteria

  • python -c "from context2html.registry import ComponentRegistry; reg = ComponentRegistry(); c = reg.get_component(26)" returns a Component with correct id, name, and dependencies
  • reg.list_components(content_type="doc") includes #26
  • reg.resolve_dependencies([26]) returns ["echarts.min.js", "echarts-gl.min.js"]
  • Tests use real component file as fixture (not synthetic)
  • All 376 existing tests still pass

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions