CodeGenerator::extern_path(nsid_prefix, root) makes refs under a prefix use another crate's
types, such as jacquard-api's, and skips emitting those lexicons. It works like prost-build's
Config::extern_path.
CodeGenerator::with_mode(&corpus, "crate", CodegenMode::Pretty)
.extern_path("com.atproto", "jacquard_api")
LexiconCorpus::insertadds a doc, such asStrongRef::lexicon_doc(), without its JSON.- When several prefixes match, the longest wins. Matches are by whole segment only.
- Extern namespaces are left out of the emitted modules and the Cargo feature deps.
- An extern ref that is not in the corpus is
CodegenError::MissingExternRef, not a silentDatafield. - A prefix that covers no lexicon in the corpus, such as a typo, is
CodegenError::UnusedExternPath.
Why? #
It helps to not have to copy and maintain a copy of a lexicon, such as the StrongRef, by source file(json) in the user's repo and instead depend on a well maintained version, through a (compatibly generated) crate, exporting both the type definitions and the generated code.
Tests: unit tests for prefix matching, the unused-prefix and missing-ref errors, and feature deps.
jacquard-codegen-tests generates a fixture against jacquard-api's StrongRef (own-module path) and
label.defs#label (*.defs path, in an array) and compile-checks the types.
NOTE: we have double and triple checked the changes in this PR, as required by AGENTS.md