Skip to content

feat(test): automate AFM_CLASSES discovery #74

@P4suta

Description

@P4suta

Background

afm pins the renderer's CSS-class contract in
crates/afm-markdown-test-support/src/lib.rs as the AFM_CLASSES
constant, maintained by hand. The file documents why (lib.rs:62-86):
aozora-render embeds the aozora-* class names as string literals
inside writer.write_str(...) — there is no pub const to import — so
each new upstream class has to be appended here (and to the two mdbook
themes) when tests/css_class_contract.rs fails after an aozora-* pin
bump.

The same file (lib.rs:82-86) sketches the intended fix as a future ADR:

A dedicated automation pass (build.rs that fetches the sibling source
tree, regex-extracts class="aozora-…" literals, and emits an
AFM_CLASSES const into OUT_DIR) is sketched as a future ADR — it
would eliminate the manual append step at the cost of a network /
filesystem dependency in the test build.

What to do

Eliminate the manual-append step. Two paths, in preference order:

  1. Preferred — consume an upstream constant. If aozora-render
    exposes its emitted class names as a pub const (tracked in
    feat(render): expose emitted CSS class names as a public constant aozora#91), AFM_CLASSES becomes a direct re-export with no
    scraping and no build.rs. This is the cheap, robust outcome and makes
    this issue mostly a follow-the-upstream task.
  2. Fallback — local automation. If upstream does not expose it, write
    the build.rs sketched above (fetch sibling source via cargo
    metadata, regex-extract class="aozora-…", emit into OUT_DIR), and
    record the network/filesystem-dependency trade-off in an ADR.

Either way, also keep crates/afm-book/theme/afm-{horizontal,vertical}.css
in sync — consider deriving/checking the themes' class coverage from the
same source of truth.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferredIntentionally postponed / not-yet-done; backlogenhancementNew feature or requestrustPull requests that update rust code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions