describe-d 0.11.2
Library that provides structures for code introspection
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
describe.d
describe.d is a library that provides a structured interface to introspect
DLang source code.
Usage
Introspection
The library provides the describe template which returns a structure with
the introspection result:
import described;
/// Introspecting modules
assert(describe!(std.array).name == "module array");
assert(describe!(std.array).fullyQualifiedName == "std.array");
assert(describe!(std.array).functions.length == 1);
assert(describe!(std.array).templates.length == 31);
/// Introspecting aggregates
struct MyStruct {
void callMe() {
}
}
assert(describe!MyStruct.name == "MyStruct");
assert(describe!MyStruct.methods.length == 1);
assert(describe!MyStruct.methods[0].name == "callMe");
assert(describe!MyStruct.methods[0].returns.name.should.equal("void"));
/// Introspecting methods
assert(describe!(MyStruct.callMe).name == "MyStruct");
assert(describe!(MyStruct.callMe).returns.name.should.equal("void"));
Given an introspected Type like a class or struct, it can be converted to the
D type using fromType:
alias T = fromType!(describe!RandomClass.type);
static assert(is(T == RandomClass));
Filtering
The library provides the where module which allows you to filter various describe results.
Asserts
The library provides the has module which allows you to check states of the various describe results.
License
This project is licensed under the MIT license - see the LICENSE file for details.
- 0.11.2 released 2 months ago
- gedaiu/describe-d
- MIT
- Copyright © 2020, Szabo Bogdan
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 15 versions0.11.2 2025-Aug-29 0.11.1 2023-Jun-02 0.11.0 2022-Dec-03 0.10.0 2021-Apr-03 0.9.0 2021-Apr-03 - Download Stats:
-
-
0 downloads today
-
3 downloads this week
-
6 downloads this month
-
5366 downloads total
-
- Score:
- 0.5
- Short URL:
- describe-d.dub.pm