Browse Source

add XML comments to public facing library code.

master
Craig Oates 6 years ago
parent
commit
80e1c7e555
  1. 29
      DeathSocket/Domain.fs
  2. 36
      DeathSocket/GridPainter.fs
  3. 3
      DeathSocketCLI/Validation.fs
  4. 4
      TestCentre/LibraryTests.fs

29
DeathSocket/Domain.fs

@ -1,23 +1,24 @@
namespace DeathSocket namespace DeathSocket
/// The domain types used by Death Socket.
[<AutoOpen>] [<AutoOpen>]
module Domain = module Domain =
open System.Drawing open System.Drawing
open System.Drawing.Imaging
/// <summary>
/// The specification used by Death Socket when adding a grid to an image.
/// </summary>
type ImageSpec = type ImageSpec =
{ originalPath: string; { /// The original path of the image which the grid is being added to.
savePath: string; originalPath: string
colour: Brush; /// The location of the new gridded image.
penWidth: float32 savePath: string
rows: int; /// The (System.Drawing) brush used to draw the grid. This determines the colour.
columns: int } colour: Brush
/// The thickness of the line on the grid.
type StreamSpec = penWidth: float32
{ imagePath: string; /// The number of rows the grid will have.
format: ImageFormat; rows: int
colour: Brush; ///The number of columns the grid will have.
penWidth: float32
rows: int;
columns: int } columns: int }

36
DeathSocket/GridPainter.fs

@ -2,12 +2,30 @@ namespace DeathSocket
open System.IO open System.IO
/// Provides functions which help draw gridded overlays onto images.
module GridPainter = module GridPainter =
open Validation open Validation
open ImageServices open ImageServices
// Needs XML comments. /// <summary>
/// Uses the information included in spec and creates a gridded image.
/// It then asynchronously saves it.
/// Please stick to .bmp, .jpg or .png files.
/// The others (image) file types have not been tested.
/// </summary>
/// <param name="spec">
/// The specification used to generate the new gridded image
/// </param>
/// <exeption cref="System.IO.FileNotFoundException">
/// If the file the grid is being applied to cannot be found,
/// a FileNotFoundException will be thrown.
/// </exception>
/// <remarks
/// Make sure the image, which is having the overlay added to it,
/// is not in use or needed by another program/process.
/// This is because it is locked whilst in this function.
/// </remarks>
let applyGridAsync spec = let applyGridAsync spec =
async { async {
try try
@ -18,10 +36,22 @@ namespace DeathSocket
printfn "File could not be found at %s" ex.Message printfn "File could not be found at %s" ex.Message
} }
// Needs XML comments. /// <summary>
/// Determines the (Pen) points needed to draw the appropriate number of horizontal lines (I.E. rows).
/// Each item in the array includes a start and end co-ordinate (point) for each line.
/// </summary>
/// <param name="width">The width of the image.</param>
/// <param name="height">The height of the image.</param>
/// <param name="rows">The number of rows the grid should have.</param>
let determineHorizontalLines width height rows = let determineHorizontalLines width height rows =
createHorizontalLines width height rows createHorizontalLines width height rows
// Needs XML comments. /// <summary>
/// Determines the (Pen) points needed to draw the appropriate number of vertical lines (I.E. columns).
/// Each item in the array includes a start and end co-ordinate (point) for each line.
/// </summary>
/// <param name="width">The width of the image.</param>
/// <param name="height">The height of the image.</param>
/// <param name="columns">The number of columns the grid should have.</param>
let determineVerticalLines width height columns = let determineVerticalLines width height columns =
createVerticalLines width height columns createVerticalLines width height columns

3
DeathSocketCLI/Validation.fs

@ -58,5 +58,4 @@
rows = 10 rows = 10
columns = 10 } columns = 10 }
stream.Dispose () stream.Dispose ()
image.Dispose () image.Dispose ()
spec

4
TestCentre/LibraryTests.fs

@ -128,9 +128,9 @@
[<Fact>] [<Fact>]
let ``Divide By Zero Exception is thrown when 0 rows is used when determining horizontal lines`` () = let ``Divide By Zero Exception is thrown when 0 rows is used when determining horizontal lines`` () =
let result () = GridPainter.determineHorizontalLines 100 100 0 let result () = GridPainter.determineHorizontalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result() |> ignore) Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
[<Fact>] [<Fact>]
let ``Divide By Zero Exception is thrown when 0 columns is used when determining vertical lines`` () = let ``Divide By Zero Exception is thrown when 0 columns is used when determining vertical lines`` () =
let result () = GridPainter.determineVerticalLines 100 100 0 let result () = GridPainter.determineVerticalLines 100 100 0
Assert.Throws<DivideByZeroException>(fun () -> result() |> ignore) Assert.Throws<DivideByZeroException>(fun () -> result () |> ignore)
Loading…
Cancel
Save