help method

String? help(
  1. dynamic object, {
  2. String? module,
})

Get the documentation of a declaration in a certain namespace.

Implementation

String? help(dynamic object, {String? module}) {
  try {
    StringBuffer buffer = StringBuffer();
    final encap = encapsulate(object);
    if (object is HTDeclaration) {
      if (object.documentation != null) {
        buffer.write(object.documentation);
      }
    }
    if (encap == null) {
      buffer.write(globalNamespace.help());
    } else if (encap is HTTypeObject) {
      buffer.writeln('type ${object.id}');
      buffer.write(lexicon.stringify(object));
    } else if (encap is HTNamespace) {
      buffer.write(encap.help());
    } else if (encap is HTFunction) {
      buffer.write(encap.help());
    } else if (encap is HTClass) {
      buffer.write(encap.help());
    } else if (encap is HTInstance) {
      buffer.write(encap.help());
    } else if (encap is HTStruct) {
      buffer.write(encap.help());
    } else if (encap is HTExternalInstance) {
      buffer.write(encap.help());
    } else {
      buffer.writeln('found no help information on object: $object');
    }
    return buffer.toString();
  } catch (error, stackTrace) {
    if (config.processError) {
      processError(error, stackTrace);
      return null;
    } else {
      rethrow;
    }
  }
}