describeModule

Describe a module and containing members

describeModule
(
bool withUnitTests = false
)
()
if (
__traits(isModule, T)
)

Examples

It should describe a module with all functions, aggregates, templates, and global vars

import introspection.test.moduleDef;

auto result = describeModule!(introspection.test.moduleDef, true);

result.name.should.equal("module moduleDef");
result.fullyQualifiedName.should.equal("introspection.test.moduleDef");

/// check functions
result.functions.length.should.equal(2);
result.functions[0].name.should.equal("testFunction");
result.functions[1].name.should.equal("privateFunction");

/// check aggregates
result.aggregates.length.should.equal(4);
result.aggregates[0].name.should.equal("TestStructure");
result.aggregates[1].name.should.equal("TestClass");
result.aggregates[2].name.should.equal("TestInterface");
result.aggregates[3].name.should.equal("TestUnion");

/// check templates
result.templates.length.should.equal(2);
result.templates[0].name.should.equal("TestTpl");
result.templates[1].name.should.equal("templatedFunction");

/// check globals
result.globals.length.should.equal(1);
result.globals[0].name.should.equal("globalVar");

/// check manifest constants
result.manifestConstants.length.should.equal(1);
result.manifestConstants[0].name.should.equal("someManifestConstant");

/// check unittests
result.unitTests.length.should.equal(2);

///
result.location.file.should.equal("source/introspection/test/moduleDef.d");
result.location.line.should.equal(0);
result.location.column.should.equal(0);

It should be able to describe the std.array module

import std.array;

auto result = describeModule!(std.array);

result.name.should.equal("module array");
result.fullyQualifiedName.should.equal("std.array");

result.functions.length.should.equal(1);
result.functions[0].name.should.equal("_d_newarrayU");

result.templates.length.should.equal(31);

It should be able to describe the std.stdio module

auto result = describeModule!(std.stdio);

result.name.should.equal("module stdio");
result.fullyQualifiedName.should.equal("std.stdio");

result.functions.length.should.equal(22);
result.functions[0].name.should.equal("flockfile");

result.templates.length.should.equal(15);

Meta