Skip to content

refactor: add impl_documentation_noop! macro for empty DocumentationModule#1082

Open
tmchow wants to merge 2 commits intoamber-lang:stagingfrom
tmchow:osc/973-documentation-noop-macro
Open

refactor: add impl_documentation_noop! macro for empty DocumentationModule#1082
tmchow wants to merge 2 commits intoamber-lang:stagingfrom
tmchow:osc/973-documentation-noop-macro

Conversation

@tmchow
Copy link
Copy Markdown
Contributor

@tmchow tmchow commented Apr 1, 2026

Summary

I added impl_documentation_noop! macro to replace boilerplate empty DocumentationModule implementations across 72 modules.Net reduction of about 290 lines!

Changes

  • src/docs/module.rs: New impl_documentation_noop! macro using $crate:: paths for proper macro hygiene
  • 72 module files: Replace manual impl DocumentationModule for X { fn document(...) { "".to_string() } } blocks with crate::impl_documentation_noop!(X);
  • Removed unused use crate::docs::module::DocumentationModule; imports from files that no longer reference the trait directly

Modules with real documentation content (declaration.rs, stmt.rs, block.rs, comment.rs, comment_doc.rs) are untouched.

Testing

  • cargo test: 652 passed, 0 failed
  • cargo clippy: no warnings
  • cargo fmt --check: clean

Fixes #973

This contribution was developed with AI assistance (Codex).

Summary by CodeRabbit

Refactor

  • Refactor
    • Introduced a new macro for generating documentation module implementations. Consolidated over 70 manual documentation trait implementations across diverse module categories—including builtins, expressions, functions, loops, and variables—into standardized macro invocations. Reduces code duplication while preserving all existing documentation behavior.

…odule

Replace boilerplate empty DocumentationModule implementations across 72
modules with a macro call. Reduces repetitive code by ~290 lines while
preserving behavior. Modules with real documentation content are unchanged.

Fixes amber-lang#973
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Added a new impl_documentation_noop! macro generating DocumentationModule trait implementations with empty string returns. Replaced 72 explicit trait implementations across various modules with macro invocations, consolidating repetitive no-op documentation code.

Changes

Cohort / File(s) Summary
Macro Definition
src/docs/module.rs
Added new exported impl_documentation_noop! macro that generates empty-documentation DocumentationModule trait implementations for specified types.
Builtin Modules
src/modules/builtin/{cd, clear, cp, disown, echo, exit, len, lines, lock, ls, mv, nameof, pid, pwd, rm, shellname, shellversion, sleep, wait}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations across 19 builtin command modules.
Command Modules
src/modules/command/{cmd, modifier}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for command and modifier types.
Condition Modules
src/modules/condition/{ifchain, ifcond}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for conditional expression types.
Expression Access & Binary Operators
src/modules/expression/{access, binop/add, binop/and, binop/div, binop/eq, binop/ge, binop/gt, binop/le, binop/lt, binop/modulo, binop/mul, binop/neq, binop/or, binop/range, binop/sub}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for access and 15 binary operator expression types.
Expression Literals & Other
src/modules/expression/{literal/array, literal/bool, literal/integer, literal/null, literal/number, literal/status, literal/text, parentheses, ternop/ternary, typeop/cast, typeop/is, unop/neg, unop/not}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for 13 literal, parentheses, ternary, type-check, and unary operator expression types.
Function Modules
src/modules/function/{fail, invocation, ret}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for function-related module types.
Import Modules
src/modules/imports/import.rs
Replaced explicit empty DocumentationModule implementation with macro invocation for import module.
Loop Modules
src/modules/loops/{break_stmt, continue_stmt, infinite_loop, iter_loop, while_loop}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for 5 loop-related module types.
Main Module
src/modules/main.rs
Replaced explicit empty DocumentationModule implementation with macro invocation for main entry point module.
Shorthand Operators
src/modules/shorthand/{add, div, modulo, mul, sub}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for 5 compound assignment operator types.
Test Module
src/modules/test.rs
Replaced explicit empty DocumentationModule implementation with macro invocation for test module.
Variable Modules
src/modules/variable/{get, init, init_destruct, set, set_destruct}.rs
Replaced explicit empty DocumentationModule implementations with macro invocations for 5 variable operation module types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

This is a straightforward, homogeneous refactoring with 73 files following the identical pattern: removing 5 lines of boilerplate and adding 1 line of macro invocation. The macro definition is straightforward, and consistency can be verified efficiently through pattern recognition across all files.

Suggested reviewers

  • Ph0enixKM
  • Tirito6626

Poem

🐰✨ A macro hops to save the day,
Empty docs in a cleaner way!
Seventy-two no-ops now unite,
One small macro makes it right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: introducing a new macro impl_documentation_noop! to replace repetitive empty DocumentationModule implementations across the codebase.
Linked Issues check ✅ Passed The PR addresses issue #973 by identifying and consolidating repeated empty DocumentationModule implementations into a reusable macro, reducing boilerplate and preparing infrastructure for future documentation improvements.
Out of Scope Changes check ✅ Passed All changes are directly scoped to replacing empty DocumentationModule implementations with the new macro; no unrelated modifications to parsing, type-checking, translation, or other core functionality were introduced.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mte90 Mte90 requested a review from Ph0enixKM April 2, 2026 07:40
@Mte90
Copy link
Copy Markdown
Member

Mte90 commented Apr 2, 2026

cool because we discussed that for the next minor :-D

@Mte90 Mte90 requested review from KrosFire and Tirito6626 April 2, 2026 07:41
@tmchow
Copy link
Copy Markdown
Contributor Author

tmchow commented Apr 4, 2026

Thanks for the approval. @Mte90 glad this aligns with what you had in mind for the next minor.

@Mte90
Copy link
Copy Markdown
Member

Mte90 commented Apr 29, 2026

There are some conflicts to fix before we can merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Empty DocumentationModule

3 participants