Skip to content

Commit ee373dd

Browse files
Copilotchrisrueger
andcommitted
Improve macro docs with copilot
- all .md files and java snippets replaced with summaries, examples and use cases. - examples in the macro docs are verified via a test case MacroTestsForDocsExamples.java - fix bytes macro and test and make it just work for a single value. - use InjectTemporaryDirectory Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> Add test case references to macro documentation files Macro: add ${bytes} example for a list of bytes Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> reviewed batch of macros Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> macro apply: review and add test Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> Add tests for 67 additional macros to MacroTestsForDocsExamples Add test case reference footers to 67 newly tested macro documentation files review and improve tests for macros Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> review and implement tests for ${p_* macros Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> Co-Authored-By: chrisrueger <188422+chrisrueger@users.noreply.github.com>
1 parent 7a159ee commit ee373dd

File tree

130 files changed

+10305
-1881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+10305
-1881
lines changed

.github/copilot-instructions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ Bridge between Eclipse extension registry and OSGi Declarative Services:
180180
- Documentation in `docs/` directory
181181
- Jekyll-based site at https://bnd.bndtools.org
182182
- Instructions documented in `docs/_instructions/`
183-
- Changes/releases documented in wiki
183+
- Macros documented in `docs/_macros/` and tested in `biz.aQute.bndlib.tests/test/MacroTestsForDocsExamples.java` (also see `biz.aQute.bndlib.tests/test/test/MACRO_TESTING_README.md` for instructions keeping examples in sync with `MacroTestsForDocsExamples.java`)
184+
- bnd CLI commands documented in `docs/_commands/`
185+
- bnd and OSGi MANIFEST headers documented in `docs/_heads/`
186+
- Changes/releases documented in wiki (https://github.com/bndtools/bnd/wiki)
187+
- Release Process documented in https://github.com/bndtools/bnd/wiki/Release-Process
184188

185189
## Contribution Workflow
186190

DEV_README.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,97 @@ tar -xzf "$JDK_FILE" --strip-components=1 -C "$JDK_EXTRACT_DIR"
551551
rm "$JDK_FILE" # Clean up downloaded archive
552552

553553
echo "All JDKs downloaded and extracted!"
554-
```
554+
```
555+
556+
557+
## Macro Documentation Testing
558+
559+
### Overview
560+
561+
The test `/biz.aQute.bndlib.tests/test/test/MacroTestsForDocsExamples.java` is a comprehensive test suite for validating macro documentation examples in `docs/_macros/*.md` files.
562+
563+
### Purpose
564+
565+
The goal of test suite is that:
566+
1. All macro examples in documentation actually work
567+
2. Expected outputs match actual macro behavior
568+
3. Syntax errors in documentation are caught
569+
4. Users can rely on documentation examples
570+
571+
572+
### Test Structure
573+
574+
Each test follows this pattern:
575+
576+
```java
577+
// ===== filename.md =====
578+
@Test
579+
public void testMacroName() throws IOException {
580+
try (Processor p = new Processor()) {
581+
String result = p.getReplacer().process("${macro;args}");
582+
assertThat(result).isEqualTo("expected");
583+
}
584+
}
585+
```
586+
587+
The comment indicates which documentation file the test validates.
588+
589+
### Running Tests
590+
591+
```bash
592+
# Run all macro documentation tests
593+
./gradlew :biz.aQute.bndlib.tests:test --tests "test.MacroTestsForDocsExamples"
594+
595+
# Run specific test
596+
./gradlew :biz.aQute.bndlib.tests:test --tests "test.MacroTestsForDocsExamples.testAverage_SimpleList"
597+
598+
# Run with more detail
599+
./gradlew :biz.aQute.bndlib.tests:test --tests "test.MacroTestsForDocsExamples" --info
600+
```
601+
602+
### Macro Behavior Reference
603+
604+
#### Common Patterns:
605+
606+
**Boolean-like Returns**:
607+
- `startswith`, `endswith`: Return original string (truthy) or empty (falsy), not "true"/"false"
608+
- `def`: Returns property value, not boolean
609+
- `is`: Returns "true" or "false"
610+
611+
**Numeric Returns**:
612+
- `average`, `sum`: Strip `.0` from whole numbers (3 not 3.0)
613+
- `rand`: Returns integer
614+
- `random`: Returns string identifier (different macro!)
615+
616+
**List Operations**:
617+
- Most combine multiple list arguments first
618+
- Zero-based indexing
619+
- Negative indices count from end
620+
621+
**File Operations**:
622+
- Often require absolute paths
623+
- Platform-specific behavior (Windows vs Unix)
624+
- Path separator differences
625+
626+
### Contributing Macro Documentation and Examples
627+
628+
If you create a new macro then add a new file in `docs/_macros/*.md` with the filename being the name of the macro.
629+
630+
When adding examples to documentation (`docs/_macros/*.md` files):
631+
1. Add corresponding test to this file
632+
2. Run test to verify example works
633+
3. Include comment indicating which .md file
634+
4. Test both success and failure cases where applicable
635+
636+
## See Also
637+
638+
- `MacroTest.java` - Original comprehensive macro tests
639+
- `docs/_macros/` - Macro documentation files
640+
- `biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java` - Macro implementations
641+
642+
Macros are in the following classes, recognized by methods starting with an underscore:
643+
644+
- `biz.aQute.bndlib/src/aQute/bnd/build/Project.java`
645+
- `biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java`
646+
- `biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java`
647+
- `biz.aQute.bndlib/src/aQute/bnd/build/Workspace.java`

0 commit comments

Comments
 (0)