From 6c98d7107c6bc3fc1a3c4c3366badf800f6866d7 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 26 Apr 2021 17:11:53 -0600 Subject: [PATCH] Docs --- src/spectator/anything.cr | 11 ++++++++--- src/spectator/context.cr | 7 +++++++ src/spectator/source.cr | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/spectator/anything.cr b/src/spectator/anything.cr index 511a024..2991e87 100644 --- a/src/spectator/anything.cr +++ b/src/spectator/anything.cr @@ -1,14 +1,19 @@ module Spectator + # Equals and matches everything. + # All comparison methods will always return true. struct Anything - def ==(other) + # Returns true for equality. + def ==(_other) true end - def ===(other) + # Returns true for case equality. + def ===(_other) true end - def =~(other) + # Returns true for matching. + def =~(_other) true end end diff --git a/src/spectator/context.cr b/src/spectator/context.cr index 2860ae3..475f49c 100644 --- a/src/spectator/context.cr +++ b/src/spectator/context.cr @@ -4,10 +4,17 @@ # This type is intentionally outside the `Spectator` module. # The reason for this is to prevent name collision when using the DSL to define a spec. abstract class SpectatorContext + # Produces a dummy string to represent the context as a string. + # This prevents the default behavior, which normally stringifies instance variables. + # Due to the sheer amount of types Spectator can create + # and that the Crystal compiler instantiates a `#to_s` and/or `#inspect` for each of those types, + # an explosion in method instances can be created. + # The compile time is drastically reduced by using a dummy string instead. def to_s(io) io << "Context" end + # :ditto: def inspect(io) io << "Context<" io << self.class diff --git a/src/spectator/source.cr b/src/spectator/source.cr index e69f5ff..fa28cea 100644 --- a/src/spectator/source.cr +++ b/src/spectator/source.cr @@ -1,7 +1,7 @@ require "json" module Spectator - # Define the file and line number something originated from. + # Defines the file and line numbers something originated from. struct Source # Absolute file path. getter file : String