Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
7e2c8d3
Create stub proc macro crate for deepwell.
emmiegit Jul 23, 2026
2aa55b0
Add stub in proc macro subcrate.
emmiegit Jul 23, 2026
a3f1cf1
First compiling version of macro crate.
emmiegit Jul 25, 2026
28300fa
Create make_ident() helper.
emmiegit Jul 25, 2026
f57d71d
Add dest / from parsing.
emmiegit Jul 25, 2026
f2ca29c
Add data type to macro.
emmiegit Jul 25, 2026
97004a2
Fix loop condition.
emmiegit Jul 25, 2026
85263de
Ensure required field and build output.
emmiegit Jul 25, 2026
25309eb
Run rustfmt.
emmiegit Jul 25, 2026
dd6f13a
Add lines between each argument.
emmiegit Jul 25, 2026
4f0829f
Error if field is set multiple times.
emmiegit Jul 25, 2026
1cad13c
Add process_type for handling () -> null.
emmiegit Jul 25, 2026
bfc022e
Add data_type and method arguments.
emmiegit Jul 26, 2026
829fc40
Remove root TODO.
emmiegit Jul 26, 2026
4147596
Bump macro crate version to 0.0.2
emmiegit Jul 26, 2026
e01897f
Add define_struct argument to macro.
emmiegit Jul 26, 2026
9924ddd
Suppress some warnings.
emmiegit Jul 26, 2026
2b50ac5
Bump macro crate version to 0.0.3
emmiegit Jul 26, 2026
0155c8c
Set up testing.
emmiegit Jul 26, 2026
b41aec5
Intake commas after each key and value.
emmiegit Jul 26, 2026
6fec51d
Perform lookahead in GenerateMethod::parse().
emmiegit Jul 26, 2026
589b2c4
Set up first unit test for settings parsing.
emmiegit Jul 26, 2026
011ec4f
Add another unit test case.
emmiegit Jul 26, 2026
4f58fcf
Bump macro crate version to 0.0.4
emmiegit Jul 26, 2026
db48c46
Add remaining parse unit test cases.
emmiegit Jul 26, 2026
f9cab9b
Remove generation unit test.
emmiegit Jul 26, 2026
74572ff
Bump macro crate version to 0.0.5
emmiegit Jul 26, 2026
255a1c5
Add new assert_type() helper function.
emmiegit Jul 26, 2026
db87738
Remove GenerateMethod, replace with boolean.
emmiegit Jul 26, 2026
ea3f695
Store names as String, not Ident.
emmiegit Jul 26, 2026
1bac0fc
Bump macro crate version to 0.0.6
emmiegit Jul 26, 2026
dd5780b
Add initial expansion code.
emmiegit Jul 26, 2026
395f6d1
Bump macro crate version to v0.0.7
emmiegit Jul 26, 2026
97d8047
Move get methods to separate function.
emmiegit Jul 26, 2026
b9fba4e
Move create and remove sections to helper functions.
emmiegit Jul 26, 2026
1af698a
Get generation parts in main function.
emmiegit Jul 26, 2026
40e9a3d
Remove metadata field in definition if null.
emmiegit Jul 26, 2026
8b57275
Generate code at top level.
emmiegit Jul 26, 2026
d92aeb8
Bump macro crate version to 0.0.8
emmiegit Jul 26, 2026
c85ad21
Remove define_struct argument.
emmiegit Jul 26, 2026
36dd7eb
Add visibility / naming for remove method.
emmiegit Jul 26, 2026
977410c
Remove integration test stub for macro crate.
emmiegit Jul 26, 2026
1e51e15
Bump macro crate version to 0.0.9
emmiegit Jul 26, 2026
9c647d8
Allow disabling struct/method generation entirely.
emmiegit Jul 26, 2026
5314985
Bump macro macro crate version to 0.0.10
emmiegit Jul 26, 2026
7ea0bb4
Rename enum cases.
emmiegit Jul 26, 2026
eba82e7
Use assert_type() for data_type too.
emmiegit Jul 26, 2026
4dbf8ed
Rename GenerateMethod enum cases.
emmiegit Jul 26, 2026
59a4465
Use ? for unwrapping Option from vis_and_suffix().
emmiegit Jul 26, 2026
c92f625
Address remaining clippy lint.
emmiegit Jul 26, 2026
073a7fa
Bump macro crate version to 0.0.11
emmiegit Jul 26, 2026
5a7b406
Add new procedural macro crate.
emmiegit Jul 26, 2026
da68494
Generate get structs.
emmiegit Jul 26, 2026
bb57dc1
Bump macro crate version to 0.0.12
emmiegit Jul 26, 2026
cea9d06
Add RelationType enum as type representation.
emmiegit Jul 26, 2026
79fc8ca
Bump macro crate version to 0.0.13
emmiegit Jul 26, 2026
37850b3
Rename RelationType -> RelationObjectType.
emmiegit Jul 26, 2026
46c26ed
Fix RelationType output.
emmiegit Jul 27, 2026
bb324fd
Bump macro crate version to 0.1.0
emmiegit Jul 27, 2026
545d2ec
Properly add type path to token output.
emmiegit Jul 27, 2026
fec5573
Bump macro crate version to 0.1.1
emmiegit Jul 27, 2026
5c9c36e
Fix types for dest / from in 'Get' struct.
emmiegit Jul 27, 2026
916467f
Ensure generation of RelationObjectType as tokens is the variant path.
emmiegit Jul 27, 2026
90ca9c1
Bump crate version to 0.1.2
emmiegit Jul 27, 2026
aebbaec
Pass in empty data to create() method.
emmiegit Jul 27, 2026
2eaf6e8
Add missing argument to get() method.
emmiegit Jul 27, 2026
b7e88c0
Bump macro crate version to 0.1.3
emmiegit Jul 27, 2026
6397ab6
Add basic README to explain proc macro crate.
emmiegit Jul 27, 2026
a3a8ad2
Bump macro crate version to 0.1.4
emmiegit Jul 27, 2026
b4dac19
Replace first relation generation (PageStar) with new proc macro.
emmiegit Jul 27, 2026
34ad091
Replace PageWatch relation with new macro.
emmiegit Jul 27, 2026
72fa13f
Add "inner" struct with borrowed data.
emmiegit Jul 28, 2026
c830566
Replace SiteBan relation with new macro.
emmiegit Jul 28, 2026
f63aa04
Replace SiteMember relation with new macro.
emmiegit Jul 28, 2026
58a80de
Add manual remove method to SiteMember relation.
emmiegit Jul 28, 2026
e07e49f
Add AuditEvent variants for site membership.
emmiegit Jul 28, 2026
0f388fb
Add audit logging for site membership relation events.
emmiegit Jul 28, 2026
8406d0a
Make enriched create / remove struct use consistent.
emmiegit Jul 28, 2026
9f9e0f8
Remove remove_site_ban_with_audit() method with new macro.
emmiegit Jul 28, 2026
39d153e
Add reason to site membership revokes.
emmiegit Jul 28, 2026
0fa2f8d
Bump macro crate version to 0.1.5
emmiegit Jul 28, 2026
63284c4
Create constant for SYSTEM_IP_ADDRESS.
emmiegit Jul 28, 2026
12d34f7
Replace SiteUser relation with new macro.
emmiegit Jul 28, 2026
738b4c2
Replace UserBlock relation with new macro.
emmiegit Jul 28, 2026
9c79dc2
Replace UserFollow relation with new macro.
emmiegit Jul 28, 2026
1f60ba4
Convert UserBotOwner relation to new macro.
emmiegit Jul 28, 2026
31a4d26
Add rustdocs for proc macro.
emmiegit Jul 28, 2026
efd7aba
Link this PR in the proc macro README.
emmiegit Jul 28, 2026
1444e1d
Add proc macro testing to CI.
emmiegit Jul 28, 2026
7b170ff
Forbid unsafe code in proc macro.
emmiegit Jul 28, 2026
353386e
Bump macro crate version to 1.0.0
emmiegit Jul 28, 2026
815c530
Remove old relation codegen macro.
emmiegit Jul 28, 2026
747febf
Fix integration tests.
emmiegit Jul 28, 2026
9f0d05f
Move latest_audit_event() to new helper module.
emmiegit Jul 30, 2026
d57b1b2
Handle unused helper function warnings.
emmiegit Jul 30, 2026
fbf5fb4
Add assertions for site_member.join event.
emmiegit Jul 30, 2026
e8240d7
Add assertions for site_member.remove event.
emmiegit Jul 30, 2026
c62ec93
Add PrivateWithStruct variant to proc macro.
emmiegit Jul 30, 2026
eabb6e7
Add GenerateMethodSettings to enable Private vs PrivateWithStruct.
emmiegit Jul 30, 2026
40a8bde
Update tests with new variants.
emmiegit Jul 30, 2026
81cd352
Change to identifier-based GenerateMethod values.
emmiegit Jul 30, 2026
d54d238
Bump macro crate version to 1.1.0
emmiegit Jul 30, 2026
af88cd4
Convert to new GenerateMethod specifiers.
emmiegit Jul 30, 2026
c2be791
Bump deepwell version to v2026.7.27
emmiegit Jul 28, 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
5 changes: 4 additions & 1 deletion .github/workflows/deepwell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ jobs:
env:
DEEPWELL_RUNTIME_ACTION: run-seeder

- name: Test
- name: Unit Tests (deepwell-relation-impl-derive)
run: cd deepwell/relation-impl-derive && cargo test

- name: Integration Tests
run: cd deepwell && cargo test --all-features -- --nocapture --test-threads 1

- name: Generate Coverage
Expand Down
12 changes: 11 additions & 1 deletion deepwell/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion deepwell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["wikijump", "api", "backend", "wiki"]
categories = ["asynchronous", "database", "web-programming::http-server"]
exclude = [".gitignore", ".editorconfig"]

version = "2026.7.22"
version = "2026.7.27"
authors = ["Emmie Smith <emmie.maeda@gmail.com>"]
edition = "2024"

Expand Down Expand Up @@ -71,6 +71,9 @@ wikidot-normalize = "0.12"
wikidot-path = "0.6"
arrayvec = "0.7.6"

# Local crates
deepwell-relation-impl-derive = { path = "relation-impl-derive" }

[dev-dependencies]
maplit = "1"
pretty_assertions = "1"
Expand Down
47 changes: 47 additions & 0 deletions deepwell/relation-impl-derive/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions deepwell/relation-impl-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "deepwell-relation-impl-derive"
description = "Procedural macro to generate boilerplate for relation methods"
repository = "https://github.com/scpwiki/wikijump/tree/develop/deepwell/relation-impl-derive"

version = "1.1.0"
authors = ["Emmie Smith <emmie.maeda@gmail.com>"]
edition = "2024"

[lib]
proc-macro = true

[dependencies]
syn = "3"
quote = "1"
proc-macro2 = "1"

[lints.rust]
unsafe_code = "forbid"
7 changes: 7 additions & 0 deletions deepwell/relation-impl-derive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# deepwell-relation-impl-derive

This helper crate exists to store the procedural macro for generating methods and structures for relations (see `RelationService`). The [old `impl_relation!` macro](https://github.com/scpwiki/wikijump/blob/0a26522e50e0a2bdc0abddfe6338e6a882d24b74/deepwell/src/services/relation/macros.rs#L23) was defined via `macro_rules!`, but as it grew more complicated and took more options, it became increasingly cumbersome to maintain.

This proc macro performs the same tasks as the old macro, but with better syntax, more options, and avoiding automatable work (e.g. converting between `PascalCase` and `snake_case`).

See #3039 for further information.
35 changes: 35 additions & 0 deletions deepwell/relation-impl-derive/src/case.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! Helper utilities in processing different naming cases.

/// Convert `PascalCase` to `snake_case`.
pub fn pascal_to_snake_case(value: &str) -> String {
let mut output = String::new();
for (i, ch) in value.char_indices() {
if i > 0 && ch.is_uppercase() {
output.push('_');
}
Comment thread
emmiegit marked this conversation as resolved.
output.push(ch.to_ascii_lowercase());
}
output
}

#[test]
fn test_pascal_to_snake_case() {
macro_rules! test {
($pascal_case:expr, $snake_case:expr $(,)?) => {{
let actual_snake_case = pascal_to_snake_case($pascal_case);
let expected_snake_case = $snake_case;
assert_eq!(
actual_snake_case, expected_snake_case,
"actual snake_case conversion doesn't match expected",
);
}};
}

test!("", "");
test!("Foo", "foo");
test!("FooBar", "foo_bar");
test!(
"AVeryLongNameWithManyParts",
"a_very_long_name_with_many_parts",
);
}
Loading
Loading