This project is still a work in progress but here's a super rough overview of what each crate does:
codama-errors
: Defines the Result/Error items for all crates.codama-nodes
: Implements the Codama IDL in Rust.codama-syn-helpers
: Helpers that boostsyn
items by using traits.codama-stores
: A small tree structure that parses crates and files inside crates (recursively) and "owns" thesyn::File
for each traversed file.codama-koroks
: A higher-level tree structure that represents things in your Rust code (modules, structs, enums, variants, types, etc.) You can think of it like a specializedsyn
tree. We call a "thing in your Rust code", aKorok
(Japanese tree spirits). Each korok keeps track of aOption<Node>
which is the currently resolved node for this piece of Rust code. Note that the korok tree usessyn
references from stores mentioned above. So first you get a store that owns all thesyn
files, then you get a Korok tree that's essentially a parsed "view" of your stores.codama-korok-visitors
: Each Korok can be visited by Korok visitors. This allows you to traverse the entire Rust code and adjust theOption<Node>
as you wish. There is aRootKorok
that is the entry point of the tree. Whichever node is associated with thisRootKorok
will become theRootNode
of the Codama IDL. Therefore, you have visitors likeCombineTypesVisitor
andCombineModulesVisitor
that go up the tree and combine nodes together until we reach theRootKorok
.codama-korok-plugins
: A plugin is trait (KorokPlugin
) that defines arun
function that accepts a mutable Korok and anext
function to run the next plugin on the list. This means any visitor you call on the Korok before thenext
function will be executed before the other plugins, anything after thenext
function will override the other plugins (kinda like a middleware pipeline). There is a DefaultPlugin that calls a default visitor. This visitor does things like, setting base types, link nodes, program metadata, applying Codama macros and combining everything up the tree so theRootNode
is set on theRootKorok
. This is the first plugin on the list so you can run anything before or after it based on where you call thenext
function on your plugin. Note that most visitors in the default plugins won't override any existingOption<Node>
in a Korok, so it's mostly there to fill as many gaps as possible. Also note that all visitors are composable so you can always re-use a visitor used in the default plugin for your own plugin — e.g. theMapVisitor
to pass a function that applies on all koroks.codama-attributes
: Parses Codama-specific attributes into structured items so they can then be used by visitors andcodama-macros
.codama-macros
: A super small procedural macro crate that registers the Codama-specific attributes mentioned above.codama
: The final library that re-exports most of the ones above and provide a super high level API for parsing IDL from paths to your Rust code.