Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
3cbf371
refactor: prepare new structures
StrikeForceZero Oct 20, 2025
d2a1ad6
refactor: rename `Composed` fields and type parameters for improved c…
StrikeForceZero Oct 20, 2025
441c1d7
refactor: rename generics mixins and add a none variant
StrikeForceZero Oct 20, 2025
bc6ec12
feat: implement `ToTokens` for `Q` with various `ItemAttribute` compo…
StrikeForceZero Oct 20, 2025
20d9f3f
feat: add macro path providers for all action macros
StrikeForceZero Oct 20, 2025
9212461
feat: implement `ToTokens` for `QQ` with action macro `ItemAttribute`…
StrikeForceZero Oct 20, 2025
256efc9
feat: add `IdentPathResolver` and extend `ItemAttribute` with it
StrikeForceZero Oct 20, 2025
31fcafd
refactor: add `PluginCap` and `GenericsCap` traits and update `ItemAt…
StrikeForceZero Oct 21, 2025
434b022
fix: `ToTokens` on generics
StrikeForceZero Oct 21, 2025
8c5dc36
refactor: simplify `ToTokens` and add tests for generics
StrikeForceZero Oct 21, 2025
6b1a0e6
fix: make sure impl ToTokens for Q matches original tokens
StrikeForceZero Oct 21, 2025
b5c7e59
fix: make sure impl ToTokens for QQ matches original tokens
StrikeForceZero Oct 21, 2025
5adb0e4
feat: implement `ToTokens` for Q and QQ with `ConfigureSystemSetArgs`…
StrikeForceZero Oct 21, 2025
6240400
fix: extend `ToTokens` for Q and QQ to support AutoName and RegisterS…
StrikeForceZero Oct 21, 2025
669f737
refactor: remove attribute tests, trait impls, with_plugin
StrikeForceZero Oct 21, 2025
30ca6e0
refactor: cleaning up several paths
StrikeForceZero Oct 21, 2025
3b03436
fix: correct `add_systems` call by adding missing `app` invocation
StrikeForceZero Oct 21, 2025
5736bcb
fix: add missing semicolons in `add_systems` and `add_plugins` calls
StrikeForceZero Oct 21, 2025
d9039b2
feat: add `prelude` modules for `generics` and `mixins`
StrikeForceZero Oct 21, 2025
67da324
refactor: replace `ToTokens` implementations with `RequiredUseQTokens…
StrikeForceZero Oct 21, 2025
bf032ef
refactor: simplify attribute handling by replacing `WithPlugin` with …
StrikeForceZero Oct 21, 2025
2719dec
fix: add `Mixin` constraint to `test_params` construction function
StrikeForceZero Oct 21, 2025
a30db97
refactor: remove `ArgsBackToTokens` implementations across rewrite at…
StrikeForceZero Oct 21, 2025
a731e33
fix: missing prelude
StrikeForceZero Oct 21, 2025
c47e5df
feat: add `prelude` module to simplify imports in `macro_api`
StrikeForceZero Oct 21, 2025
41f1159
refactor: add QQ ToTokens for each rewrite attribute
StrikeForceZero Oct 21, 2025
1cfadab
refactor: move all Q impls into their respective files
StrikeForceZero Oct 21, 2025
2efbbd2
fix: `QQ` implementation to use `ComponentArgs` in `auto_component` r…
StrikeForceZero Oct 21, 2025
b8ca090
fix: re-export `q` in `macro_api` prelude for consistency
StrikeForceZero Oct 21, 2025
2d22116
refactor: replace `QQ` with `Q` in ToTokens implementations across re…
StrikeForceZero Oct 21, 2025
1417c7e
refactor: move QQ ToTokens into their own files
StrikeForceZero Oct 23, 2025
2e61a68
refactor: simplify imports with preludes
StrikeForceZero Oct 23, 2025
82242c3
refactor: introduce type aliases for rewrite ItemAttribute
StrikeForceZero Oct 23, 2025
558a2fd
refactor: rename ItemAttribute type aliases
StrikeForceZero Oct 23, 2025
22741cb
fix: formatting and missing semicolon
StrikeForceZero Oct 24, 2025
bbc36c4
refactor: remove RewriteAttribute expand_args
StrikeForceZero Oct 24, 2025
8d27154
refactor: introduce `AllowAny` and export it in `macro_api` prelude
StrikeForceZero Oct 24, 2025
3455228
refactor: use `AllowAny` resolver in auto_bind_plugin
StrikeForceZero Oct 24, 2025
122ecf6
fix: imports in auto_plugin
StrikeForceZero Oct 24, 2025
7b03ea9
fix: prelude not exporting all relevant items
StrikeForceZero Oct 24, 2025
6c27303
fix: rename auto attribute aliases to Ia-prefixed versions
StrikeForceZero Oct 24, 2025
546a6e2
fix: prelude exports missing AutoPluginDeriveArgs
StrikeForceZero Oct 24, 2025
3dd5656
refactor(wip): restructuring Q/QQ structs and traits
StrikeForceZero Oct 24, 2025
cda4824
feat: add `impl_from_default` macro to simplify trait implementations
StrikeForceZero Oct 24, 2025
3fb42e1
refactor: remove lifetime annotations from Q/QQ types and update trai…
StrikeForceZero Oct 24, 2025
9d631f6
refactor: update `From` implementations to support additional generic…
StrikeForceZero Oct 24, 2025
4c89212
refactor: remove with_target_path
StrikeForceZero Oct 24, 2025
214ec93
refactor: extract `output` and fix tests
StrikeForceZero Oct 24, 2025
a3787e7
refactor: default context for now
StrikeForceZero Oct 24, 2025
d7d8232
fix: prelude exports
StrikeForceZero Oct 25, 2025
dc00624
refactor: remove unused `test_params` module in test utilities
StrikeForceZero Oct 25, 2025
5bf1539
feat: add potential util for writing back into token stream when dropped
StrikeForceZero Oct 25, 2025
fa00757
refactor: remove unused imports and traits across macro API and relat…
StrikeForceZero Oct 25, 2025
be55ee9
refactor: remove unused `attribute` module and related trait
StrikeForceZero Oct 25, 2025
5674475
refactor: reimplement proc_attribute_rewrite_outer
StrikeForceZero Oct 25, 2025
c8655ab
refactor: update `ItemAttribute` traits and function signatures
StrikeForceZero Oct 25, 2025
520e779
fix: bad token generation and recursion
StrikeForceZero Oct 25, 2025
66ef5e6
fix: several token issues and duplicate input emission
StrikeForceZero Oct 25, 2025
ead7ed2
fix: more token issues
StrikeForceZero Oct 25, 2025
9b81a8c
fix: add missing semicolons in token assertions and clean up token fo…
StrikeForceZero Oct 25, 2025
8813c4e
fix: bad token output for configure_system_set
StrikeForceZero Oct 25, 2025
d7dc0cc
fix: correct `to_tokens` tests to use `assert_eq!`
StrikeForceZero Oct 25, 2025
2c98f73
refactor: remove a lot of dead code and unused imports
StrikeForceZero Oct 25, 2025
30ee7fb
refactor: remove a lot of dead code and unused imports
StrikeForceZero Oct 25, 2025
2286fb6
fix: update `to_tokens` tests to use `assert_eq!`
StrikeForceZero Oct 25, 2025
9b34717
refactor: scope imports for cfg(test)
StrikeForceZero Oct 25, 2025
620c292
refactor: clean up imports in `concrete_path.rs`
StrikeForceZero Oct 25, 2025
97e6c4d
refactor: remove dead code and migrate `generics_from_path` to `synta…
StrikeForceZero Oct 25, 2025
40ad843
refactor: remove redundant `Hash` trait bounds and clean up implement…
StrikeForceZero Oct 25, 2025
128b2db
refactor: suppress warnings for dead code and add placeholder impleme…
StrikeForceZero Oct 25, 2025
510ab34
refactor: dont scrub readonly
StrikeForceZero Oct 26, 2025
7ba2d87
store
StrikeForceZero Oct 26, 2025
bd9534d
refactor: remove dead code after drop and emit guard
StrikeForceZero Oct 26, 2025
8dce9d1
chore(docs): remove na comment
StrikeForceZero Oct 26, 2025
21d0e22
refactor: simplify argument inflation logic and improve token handling
StrikeForceZero Oct 26, 2025
bf0d7c3
refactor: rename `inflate_args_with_plugin_from_input` to `inflate_ar…
StrikeForceZero Oct 26, 2025
7ca101a
refactor: remove dead code
StrikeForceZero Oct 26, 2025
2e0f8b3
refactor: add `get_ident` and `ident` methods to `ItemAttrsExt` trait
StrikeForceZero Oct 26, 2025
6fcdc8c
refactor: utilize `get_ident` method and simplify `ident` handling in…
StrikeForceZero Oct 26, 2025
b6d7430
refactor: simplify attribute handling and streamline `inflate_args_fr…
StrikeForceZero Oct 26, 2025
570965d
refactor: rename `wrap` to `wrap_as_attr`
StrikeForceZero Oct 26, 2025
cc9fa4a
refactor: handle empty `args` in `wrap_as_attr` method
StrikeForceZero Oct 26, 2025
c6d72e6
refactor: rename `Q` with `AppMutationEmitter` and update associated …
StrikeForceZero Oct 26, 2025
b9493c8
refactor: rename `QQ` to `AttrEmitter` and update references across t…
StrikeForceZero Oct 26, 2025
bb71662
refactor: rename `RewriteQ` to `AttrExpansionEmitter` and update refe…
StrikeForceZero Oct 26, 2025
1023faa
refactor: reorganize emitters into `macro_api/emitters` module and up…
StrikeForceZero Oct 26, 2025
4a855a6
refactor: move `context.rs` into `context` module
StrikeForceZero Oct 26, 2025
e46a99c
refactor: move `macro_paths.rs` into `context` module and adjust refe…
StrikeForceZero Oct 26, 2025
e40e64a
refactor: consolidate macro_api imports using prelude module
StrikeForceZero Oct 26, 2025
9c1eaa5
refactor: move `body` into AppMutationEmitter as `wrap_body`
StrikeForceZero Oct 26, 2025
56ece75
refactor: extract `proc_attribute_outer` and `proc_attribute_rewrite_…
StrikeForceZero Oct 26, 2025
cc5b021
refactor: simplify `gen_auto_attribute_outers` macro by removing pars…
StrikeForceZero Oct 26, 2025
dc0c75f
refactor: rename macros `gen_auto_attribute_outers` and `gen_auto_out…
StrikeForceZero Oct 26, 2025
4501213
refactor: remove unused `@one` macro helper from `expand/attr/mod.rs`
StrikeForceZero Oct 26, 2025
4d7aeb2
refactor: rename plugin injection functions
StrikeForceZero Oct 26, 2025
91234f7
refactor: remove unused `ToTokens` import from `expand/attr/mod.rs`
StrikeForceZero Oct 26, 2025
23ab0eb
refactor: add `item_emitter` module and consolidate `emitters` import…
StrikeForceZero Oct 27, 2025
84d1e0e
refactor: rename `scrub_item` to `item_post_process` and update relat…
StrikeForceZero Oct 27, 2025
fd46720
refactor: rename emitter types and related references
StrikeForceZero Oct 27, 2025
dba9971
refactor: consolidate `context` and `macro_paths` imports using prelu…
StrikeForceZero Oct 27, 2025
2bda5cd
refactor: prevent unreachable statement warnings in ToTokens for Conf…
StrikeForceZero Oct 27, 2025
f9f7c5c
refactor: make `AppMutationEmitter` struct public to match `proc_attr…
StrikeForceZero Oct 27, 2025
e6b738f
refactor: make `AttrExpansionEmitter` struct public to match `proc_at…
StrikeForceZero Oct 27, 2025
825717b
refactor: remove unused `into_tuple` method from `InflateArgsOutput` …
StrikeForceZero Oct 27, 2025
5dad0ce
refactor: remove `item` module and related `resolve_ident_from_struct…
StrikeForceZero Oct 27, 2025
d6323bc
chore(config): add `rustfmt.toml` for consistent formatting rules
StrikeForceZero Oct 27, 2025
9b303d4
refactor: apply rustfmt
StrikeForceZero Oct 27, 2025
7c2b2a1
chore(config): switch CI Rust toolchain to nightly for rustfmt jobs
StrikeForceZero Oct 27, 2025
d79dccd
chore(config): set `array_width` to 60 in `rustfmt.toml`
StrikeForceZero Oct 27, 2025
79436e0
refactor: apply rustfmt
StrikeForceZero Oct 27, 2025
1313467
refactor: improve error handling and literal detection in `TypeList` …
StrikeForceZero Oct 27, 2025
756d14d
refactor: use call site span for attribute highlighting
StrikeForceZero Oct 27, 2025
f18f17f
refactor: use from_meta instead of parse2 to restore meaningful error…
StrikeForceZero Oct 27, 2025
1d5cf0a
fix(tests): correct error highlighting in `bad_generics_type` test ou…
StrikeForceZero Oct 27, 2025
3fd6ed0
refactor(tests): split `bad_generics_type` tests to separate `nightly…
StrikeForceZero Oct 27, 2025
136cce3
refactor: remove deprecated modes export
StrikeForceZero Oct 27, 2025
55f0f94
refactor: move docs to root crate
StrikeForceZero Oct 27, 2025
7703d92
refactor: remove unused `#[allow(dead_code)]` attribute
StrikeForceZero Oct 27, 2025
c6a4a71
chore(docs): cleanup inline docs for proc macros
StrikeForceZero Oct 27, 2025
80e190d
chore(cargo): clean up dependencies in `bevy_auto_plugin_proc_macros`
StrikeForceZero Oct 27, 2025
b3d60a2
chore(docs): add example usage and guidelines for `AutoPlugin` in cra…
StrikeForceZero Oct 27, 2025
451cc32
chore(docs): split docs into derives, proc_attributes::{actions, rewr…
StrikeForceZero Oct 27, 2025
ace1097
chore(docs): expand crate-level docs with attribute usage examples
StrikeForceZero Oct 27, 2025
c810d84
chore(dev-deps): add meta_merge@^0.1.1
StrikeForceZero Oct 27, 2025
ade6aa8
chore(tests): restructure `e2e` tests into `actions`, `auto_plugin`, …
StrikeForceZero Oct 27, 2025
4969ea1
refactor(auto_plugin): remove deprecated `app_param` attribute and up…
StrikeForceZero Oct 27, 2025
3fa6af0
refactor(auto_insert_resource): deprecate `resource` in favor of `ini…
StrikeForceZero Oct 27, 2025
5daa8c9
refactor(attr): move `attrs_inject_plugin_param` to `auto_bind_plugin…
StrikeForceZero Oct 27, 2025
cb8b8cf
chore(docs): add `ARCHITECTURE.md` detailing flow
StrikeForceZero Oct 27, 2025
e6c4a53
chore(docs): expand `ARCHITECTURE.md`
StrikeForceZero Oct 27, 2025
6688fd5
chore(docs): update `ARCHITECTURE.md` with notes on `Composed` and po…
StrikeForceZero Oct 27, 2025
259a269
chore(docs): add TODO comment in `Context` for alias resolution in pr…
StrikeForceZero Oct 28, 2025
3e3c327
refactor(auto_plugin): simplify `resolve_app_param_name` by removing …
StrikeForceZero Oct 28, 2025
868f652
chore(docs): remove obsolete TODO comment in `tokens.rs`
StrikeForceZero Oct 28, 2025
48deba9
refactor(scrub_helpers): replace `write_*` methods with `replace_*` a…
StrikeForceZero Oct 28, 2025
479ddf2
feat(internal_test_util): add `token_stream` module with `Ts` wrapper…
StrikeForceZero Oct 28, 2025
d44efd8
feat(codegen): add `emit.rs` for managing token streams with checkpoi…
StrikeForceZero Oct 28, 2025
6f2e5fb
refactor(codegen): remove `#[must_use]` on several methods
StrikeForceZero Oct 28, 2025
0e5cfb2
refactor(auto_plugin): simplify `auto_configure_system_set` by removi…
StrikeForceZero Oct 28, 2025
105b76f
refactor(codegen): rework `EmitResult` and `Ctx` API
StrikeForceZero Oct 29, 2025
d42d827
refactor(macro_api): enhance error handling in `item_post_process` an…
StrikeForceZero Oct 29, 2025
1ff4962
feat(internal_test_util): implement custom `Debug` trait for `Ts`
StrikeForceZero Oct 29, 2025
1871577
feat(internal_test_util): add `token_string` utility function to `tok…
StrikeForceZero Oct 29, 2025
4d93e2e
feat(internal_test_util): mark `Ts` struct with `#[repr(transparent)]`
StrikeForceZero Oct 29, 2025
2a371cb
feat(codegen): add utility methods `ok`, `err`, `try_do`, and `try_un…
StrikeForceZero Oct 29, 2025
9811c17
feat(codegen): add `map_err_tokens` method to `EmitResult`
StrikeForceZero Oct 29, 2025
a3794c9
chore(parse): add TODO for refactoring `ScrubOutcome` and `EmitResult…
StrikeForceZero Oct 29, 2025
348ea66
refactor(macro_api): integrate `EmitBuilder` into `auto_configure_sys…
StrikeForceZero Oct 29, 2025
b7f7a31
refactor(codegen): update `try_phase` and related functions to improv…
StrikeForceZero Oct 30, 2025
230b4cf
refactor(macro_api): encapsulate scrubbing
StrikeForceZero Oct 30, 2025
d009b72
refactor(macro_api): breakup `auto_configure_system_set` `inflate_arg…
StrikeForceZero Oct 30, 2025
527041b
refactor(codegen): add more type aliases for `EmitResult`
StrikeForceZero Oct 30, 2025
f2d195d
refactor(syntax): move `item` from `parse` module to `analysis` modul…
StrikeForceZero Oct 30, 2025
b3c6183
feat(syntax): add `expect_single_item_any_compile_errors` for parsing…
StrikeForceZero Oct 31, 2025
0942281
refactor(macro_api): enhance `InputItem` with new conversion traits a…
StrikeForceZero Oct 31, 2025
ccb2831
refactor(codegen, macro_api): replace `EmitBuilder` with new context …
StrikeForceZero Oct 31, 2025
d6fb2bb
refactor(macro_api): simplify pattern matching in `auto_configure_sys…
StrikeForceZero Oct 31, 2025
304f2df
refactor(macro_api): move `auto_configure_system_set` to its own module
StrikeForceZero Nov 2, 2025
298fd89
refactor(macro_api): extract `inflate` module from `auto_configure_sy…
StrikeForceZero Nov 2, 2025
4711106
feat: add `auto_sub_states`, and add `auto_register_state_type` to `a…
StrikeForceZero Jan 7, 2026
19b2c77
chore: drop `rust-version` field from Cargo.toml
StrikeForceZero Jan 7, 2026
2f706d1
chore(tests): add e2e tests for rewrites: component, event, message, …
StrikeForceZero Jan 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Rust with rustfmt
- name: Setup Rust (nightly) with rustfmt
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
toolchain: nightly
components: rustfmt
override: true

- name: Run rustfmt
run: cargo +stable fmt --all -- --check
- name: Run rustfmt (nightly)
run: cargo +nightly fmt --all -- --check

clippy:
runs-on: ubuntu-latest
Expand Down
84 changes: 84 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Architecture

This document explains how the `bevy_auto_plugin` ecosystem is structured and how macro expansion flows through the crates.

## High-Level Flow

1. **User-facing macros** are re-exported from `bevy_auto_plugin` (in [`src/lib.rs`](src/lib.rs) under the `prelude`).
2. When a user applies:
- `#[derive(AutoPlugin)]` → expansion handled by
[`bevy_auto_plugin_shared/src/__private/expand/derive/auto_plugin.rs`](crates/bevy_auto_plugin_shared/src/__private/expand/derive/auto_plugin.rs)
- `#[auto_plugin]` (attribute form) → expansion handled by
[`bevy_auto_plugin_shared/src/__private/expand/attr/auto_plugin.rs`](crates/bevy_auto_plugin_shared/src/__private/expand/attr/auto_plugin.rs)
- `#[auto_*( ... )]` attributes → routed to
[`bevy_auto_plugin_shared/src/__private/expand/attr/`](crates/bevy_auto_plugin_shared/src/__private/expand/attr/)

---

## Attribute Types

`auto_*` attributes fall into two categories:

### Actions

- Mutate the input token stream **and/or** append code that registers static slices used during plugin initialization.
- Parsing types are defined in:
[`bevy_auto_plugin_shared/src/macro_api/attributes/actions`](crates/bevy_auto_plugin_shared/src/macro_api/attributes/actions)

Each action attribute is modeled as: `ItemAttribute<Composed<T, P, G>, R>`

Where:

| Generic | Meaning |
|---------|----------|
| `T` | The [`darling`](https://crates.io/crates/darling) parameter struct for the attribute |
| `P` | Plugin context: `WithPlugin` |
| `G` | Generics handling: `WithZeroGenerics`, `WithZeroOrSingleGenerics`, or `WithZeroOrManyGenerics` |
| `R` | Resolver restricting usage: `AllowAny`, `AllowFn`, or `AllowStructOrEnum` |

notes:
- `Composed` can probably be merged into `ItemAttribute` but it's currently left open if we decide to add macros that aren't attached to the usual items (unlikely).

Actions can implement traits for one or both of the following wrapper types:

#### [`AppMutationEmitter<T>`](crates/bevy_auto_plugin_shared/src/macro_api/emitters/app_mutation.rs)

- Generates tokens for static slice registration and plugin mutation.
- **May also mutate the input tokens** (rare).
Example use case: allowing helper attributes on enum variants.
See:
[`bevy_auto_plugin_shared/src/macro_api/attributes/actions/auto_configure_system_set.rs`](crates/bevy_auto_plugin_shared/src/macro_api/attributes/actions/auto_configure_system_set.rs)

#### [`AttrEmitter<T>`](crates/bevy_auto_plugin_shared/src/macro_api/emitters/attr.rs)

- Responsible for serializing a parsed parameter struct back into attribute tokens (useful for rewrite expansions).

---

### Rewrites

- Expand into one or more other attributes.
- Only modify the **item’s attributes**, not the item body.
- Uses wrapper type [`AttrExpansionEmitter<T>`](crates/bevy_auto_plugin_shared/src/macro_api/emitters/attr_expansion.rs)

---

## Supporting Infrastructure

### Custom Parsing

Located in:
[`bevy_auto_plugin_shared/src/syntax/ast`](crates/bevy_auto_plugin_shared/src/syntax/ast)
Includes custom AST fragments, parsing helpers, and type definitions used across attributes.

### Codegen Tokens

All hygienic Bevy paths are centralized in:
[`bevy_auto_plugin_shared/src/codegen/tokens.rs`](crates/bevy_auto_plugin_shared/src/codegen/tokens.rs)

- Crate alias resolution is handled via [`proc-macro-crate`](https://crates.io/crates/proc-macro-crate).

### Token Preservation

Macro expansions are designed to **preserve input tokens on errors**.
This ensures IDEs (like rust-analyzer) maintain valid syntax trees and prevent code “going red” on partially-written macro usage.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ repository = "https://github.com/StrikeForceZero/bevy_auto_plugin"
license = "MIT OR Apache-2.0"
description = "Procedural attribute macros for Bevy apps that reduce boilerplate by automatically registering components, resources, events, states, and systems in your plugin's build function."
edition = "2024"
rust-version = "1.88"
publish = true

[features]
Expand Down Expand Up @@ -79,6 +78,7 @@ log = { workspace = true }
wasm-bindgen-test = { workspace = true }
internal_test_util = { workspace = true }
internal_test_proc_macro = { workspace = true }
meta_merge = "0.1.1"

[build-dependencies]
rustc_version = "0.4"
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use rustc_version::{Channel, version_meta};
use rustc_version::{
Channel,
version_meta,
};

fn main() {
println!("cargo:rustc-check-cfg=cfg(nightly)");
Expand Down
11 changes: 1 addition & 10 deletions crates/bevy_auto_plugin_proc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,4 @@ log_plugin_build = ["bevy_auto_plugin_shared/log_plugin_build"]

[dependencies]
bevy_auto_plugin_shared = { workspace = true }
syn = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
darling = { workspace = true }

[dev-dependencies]
# needed for doc-tests
bevy = { workspace = true }
bevy_app = { workspace = true }
bevy_auto_plugin = { path = "../../.", default-features = false }
proc-macro2 = { workspace = true }
80 changes: 29 additions & 51 deletions crates/bevy_auto_plugin_proc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use bevy_auto_plugin_shared::__private::expand;
use proc_macro::TokenStream as CompilerStream;
use proc_macro2::TokenStream as MacroStream;

#[allow(dead_code)]
/// thin adapter converting between the compiler-level and proc_macro2 streams
/// Thin adapter converting between the compiler-level and proc_macro2 streams
fn handle_attribute<F: Fn(MacroStream, MacroStream) -> MacroStream>(
handler: F,
attr: CompilerStream,
Expand All @@ -12,168 +11,147 @@ fn handle_attribute<F: Fn(MacroStream, MacroStream) -> MacroStream>(
handler(attr.into(), input.into()).into()
}

/// Derives `AutoPlugin` which generates the initialization function that automatically registering types, events, and resources in the `App`.
#[doc = include_str!("../docs/proc_attributes/derive_auto_plugin.md")]
/// Derives `AutoPlugin`, which generates the initialization function that automatically registers types, events, resources, system, ..., etc. in the `App`.
#[proc_macro_derive(AutoPlugin, attributes(auto_plugin))]
pub fn derive_auto_plugin(input: CompilerStream) -> CompilerStream {
expand::derive::auto_plugin::expand_derive_auto_plugin(input.into()).into()
}

/// Attaches to a fn and injects a call to the initialization function that automatically registering types, events, and resources in the `App`.
#[doc = include_str!("../docs/proc_attributes/auto_plugin.md")]
/// Attaches to an `fn` and injects a call to the `AutoPlugin` initialization function that automatically registers types, events, resources, system, ..., etc. in the `App`.
#[allow(unused_variables, unused_mut, unreachable_code)]
#[proc_macro_attribute]
pub fn auto_plugin(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_plugin::expand_auto_plugin, attr, input)
}

/// Automatically registers a type with the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_register_type.md")]
/// Automatically registers item deriving `Reflect` in `TypeRegistry` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_register_type(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_register_type, attr, input)
}

/// Automatically adds a message type to the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_add_message.md")]
/// Automatically adds a `Message` to the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_add_message(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_add_message, attr, input)
}

/// Automatically configures a `SystemSet`.
#[doc = include_str!("../docs/proc_attributes/auto_configure_system_set.md")]
/// Automatically configures a `SystemSet` in the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_configure_system_set(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_configure_system_set, attr, input)
}

/// Automatically inserts a resource in the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_init_resource.md")]
/// Automatically initializes a `Resource` in the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_init_resource(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_init_resource, attr, input)
}

/// Automatically inserts a resource in the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_insert_resource.md")]
/// Automatically inserts a `Resource` in the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_insert_resource(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_insert_resource, attr, input)
}

/// Automatically initializes a State in the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_init_state.md")]
/// Automatically initializes a `State` in the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_init_state(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_init_state, attr, input)
}

/// Automatically initializes a SubState in the Bevy `App`.
#[doc = include_str!("../docs/proc_attributes/auto_init_sub_state.md")]
/// Automatically initializes a `SubState` in the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_init_sub_state(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_init_sub_state, attr, input)
}

/// Automatically registers a required component `Name` with a value using the concrete name of the item.
#[doc = include_str!("../docs/proc_attributes/auto_name.md")]
#[proc_macro_attribute]
pub fn auto_name(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_name, attr, input)
}

/// Automatically registers item as States for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_register_state_type.md")]
/// Automatically registers item representing `States` in `TypeRegistry` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_register_state_type(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_register_state_type, attr, input)
}

/// Automatically adds the fn as a system for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_add_system.md")]
/// Automatically adds the `fn` as a `System` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_add_system(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_add_system, attr, input)
}

/// Automatically adds the fn as a proc_attributes observer to bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_add_observer.md")]
/// Automatically adds the `fn` as a `Observer` to the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_add_observer(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_add_observer, attr, input)
}

/// Automatically adds the plugin as a sub-plugin to bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_add_system.md")]
/// Automatically adds the `Plugin` as a sub-plugin to the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_add_plugin(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_add_plugin, attr, input)
}

/// Automatically registers item as Component for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_component.md")]
/// Automatically registers item as `Component` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_component(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_component, attr, input)
}

/// Automatically registers item as Resource for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_resource.md")]
/// Automatically registers item as `Resource` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_resource(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_resource, attr, input)
}

/// Automatically registers item as Event for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_event.md")]
/// Automatically registers item as `Event` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_event(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_event, attr, input)
}

/// Automatically registers item as Message for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_message.md")]
/// Automatically registers item as `Message` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_message(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_message, attr, input)
}

/// Automatically registers item as States for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_states.md")]
/// Automatically registers item as `States` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_states(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_states, attr, input)
}

/// Automatically adds the fn as a system for bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_system.md")]
/// Automatically registers item as `SubStates` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_sub_states(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_sub_states, attr, input)
}

/// Automatically adds the `fn` as a `System` for the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_system(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_system, attr, input)
}

/// Automatically adds proc_attributes observer to bevy app. (See below for additional options)
#[doc = include_str!("../docs/proc_attributes/auto_observer.md")]
/// Automatically adds `Observer` to the Bevy `App`.
#[proc_macro_attribute]
pub fn auto_observer(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_observer, attr, input)
}

/// Automatically binds `plugin = _` to every auto_* attribute below it
#[doc = include_str!("../docs/proc_attributes/auto_run_on_build.md")]
/// Automatically runs the `fn` on build.
#[proc_macro_attribute]
pub fn auto_run_on_build(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(expand::attr::auto_run_on_build, attr, input)
}

/// Automatically binds `plugin = _` to every auto_* attribute below it
#[doc = include_str!("../docs/proc_attributes/auto_bind_plugin.md")]
#[proc_macro_attribute]
pub fn auto_bind_plugin(attr: CompilerStream, input: CompilerStream) -> CompilerStream {
handle_attribute(
expand::attr::auto_bind_plugin::auto_bind_plugin_outer,
attr,
input,
)
handle_attribute(expand::attr::auto_bind_plugin::auto_bind_plugin_outer, attr, input)
}
8 changes: 0 additions & 8 deletions crates/bevy_auto_plugin_shared/src/__private/attribute.rs

This file was deleted.

Loading