diff --git a/Makefile b/Makefile index 2f127a3..ef5ce03 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,7 @@ uninstall: distrib: dune-release tag dune-release + +format: + ocamlformat kicadsch/src/*.ml[i] --inplace + ocamlformat plotkicadsch/src/*.ml[i] --inplace diff --git a/kicadsch/src/.ocamlformat b/kicadsch/src/.ocamlformat new file mode 100644 index 0000000..f0340fe --- /dev/null +++ b/kicadsch/src/.ocamlformat @@ -0,0 +1,7 @@ +profile = default +version = 0.20.1 +break-cases = nested +margin = 77 +parse-docstrings = true +wrap-comments = true +line-endings = lf diff --git a/kicadsch/src/kicadSch_sigs.mli b/kicadsch/src/kicadSch_sigs.mli index c410e02..aa87a69 100644 --- a/kicadsch/src/kicadSch_sigs.mli +++ b/kicadsch/src/kicadSch_sigs.mli @@ -1,5 +1,4 @@ -(** - Kicad modules Signatures *) +(** Kicad modules Signatures *) (** orientation of a text *) type orientation = Orient_H | Orient_V (** *) @@ -16,70 +15,69 @@ type justify = J_left | J_right | J_center | J_bottom | J_top (** *) (** Style of a text *) type style = Bold | Italic | BoldItalic | NoStyle (** *) +type kolor = [ `NoColor | `Black | `Green | `Red | `Blue | `Brown ] (** Color of the text. These are the colors appearing in Kicad schematics *) -type kolor = [`NoColor | `Black | `Green | `Red | `Blue | `Brown] -(** Transformation matrix of a relative coordinate around an absolute coordinate. - The matrix is layed out as a pair of lines of pairs *) type transfo = (int * int) * (int * int) +(** Transformation matrix of a relative coordinate around an absolute + coordinate. The matrix is layed out as a pair of lines of pairs *) -type revision = - | First of string - | Second of string - | No_Rev +type revision = First of string | Second of string | No_Rev module type Painter = sig - (** A module able to paint a canvas with several graphic primitives - and then to process the canvas into a picture file format. The - functions are supposed to be pure *) + (** A module able to paint a canvas with several graphic primitives and + then to process the canvas into a picture file format. The functions + are supposed to be pure *) - (** the canvas of the painter *) type t + (** the canvas of the painter *) val paint_text : - ?kolor:kolor - -> String.t - -> orientation - -> coord - -> size - -> justify - -> style - -> t - -> t - (** [paint ?kolor text orient coord size justification style canvas] - adds a [text] with the given [orient], [size], [justification] - and [style] at the given [coord] to [canvas]. + ?kolor:kolor -> + String.t -> + orientation -> + coord -> + size -> + justify -> + style -> + t -> + t + (** [paint ?kolor text orient coord size justification style canvas] adds a + [text] with the given [orient], [size], [justification] and [style] at + the given [coord] to [canvas]. + @return the modified canvas *) val paint_line : ?kolor:kolor -> ?width:size -> coord -> coord -> t -> t - (** [paint_line ?kolor width start end canvas] paints a line with - the given [kolor] and [width] between [start] and [stop] on - [canvas]. + (** [paint_line ?kolor width start end canvas] paints a line with the given + [kolor] and [width] between [start] and [stop] on [canvas]. + @return the modified canvas *) val paint_circle : ?kolor:kolor -> ?fill:kolor -> coord -> int -> t -> t - (** [paint_circle ?kolor center radius canvas] paints a circle - filled with the given [kolor] defined by [center] and [radius] on - [canvas]. + (** [paint_circle ?kolor center radius canvas] paints a circle filled with + the given [kolor] defined by [center] and [radius] on [canvas]. + @return the modified canvas *) val paint_rect : ?kolor:kolor -> ?fill:kolor -> coord -> coord -> t -> t - (** [paint_rect ?kolor corner1 corner2 canvas] paints a rectangle - filled with the given [kolor] defined by [corner1] and [corner2] - on [canvas]. + (** [paint_rect ?kolor corner1 corner2 canvas] paints a rectangle filled + with the given [kolor] defined by [corner1] and [corner2] on [canvas]. + @return the modified canvas *) val paint_image : coord -> float -> Buffer.t -> t -> t - (** [paint_image corner scale png canvas] paints a [png] image - filled at [corner], scaled at [scale] on [canvas]. - @return the - modified canvas *) + (** [paint_image corner scale png canvas] paints a [png] image filled at + [corner], scaled at [scale] on [canvas]. + + @return the modified canvas *) val paint_arc : ?kolor:kolor -> ?fill:kolor -> coord -> coord -> coord -> int -> t -> t (** [paint_arc ?kolor center start end radius canvas] paints an arc filled with [kolor] between [start] and [end] of [radius] around center on [canvas]. + @return the modified canvas *) val set_canevas_size : int -> int -> t -> t @@ -89,66 +87,80 @@ module type Painter = sig val get_context : unit -> t (** [get_context ()] + @return a new painting canvas *) end module type SchPainter = sig (** A module able to paint a schematic file in a painter context *) - (** the schematic context *) type schContext + (** the schematic context *) - (** the underlying context *) type painterContext + (** the underlying context *) - val initial_context : ?allow_missing_component:bool -> revision -> schContext + val initial_context : + ?allow_missing_component:bool -> revision -> schContext (** [initial_context allow_missing_component revision] + @return an new empty context *) val add_lib : string -> schContext -> schContext - (** [add_lib line context] parse the content of [line] provided to - libs to the [context]. + (** [add_lib line context] parse the content of [line] provided to libs to + the [context]. + @return the updated context *) val parse_line : String.t -> schContext -> schContext - (** [parse_line line context] parse a new [line] of schematic and - update [context]. + (** [parse_line line context] parse a new [line] of schematic and update + [context]. + @return the updated context *) val output_context : schContext -> painterContext - (** [output_context context output] write the [context] as a image - format to [output] *) + (** [output_context context output] write the [context] as a image format + to [output] *) end module type CompPainter = sig - (** The library that is able to read component libraries and - memorize the read components. Then when passed a drawing context - and a component to paint it can paint the component on demand to - the drawing context *) + (** The library that is able to read component libraries and memorize the + read components. Then when passed a drawing context and a component to + paint it can paint the component on demand to the drawing context *) - (** A component Library manager *) type t + (** A component Library manager *) - (** A drawing context *) type drawContext + (** A drawing context *) val lib : unit -> t (** [lib ()] + @return an empty new component manager *) val append_lib : string -> t -> t - (** [append_lib stream context] appends the lib contained in the - [stream] to the context. + (** [append_lib stream context] appends the lib contained in the [stream] + to the context. + @return the updated context *) val plot_comp : - t -> string -> int -> coord -> transfo -> bool -> drawContext -> drawContext * bool - (** [plot_comp lib name partnumber origin transformation - allow_missing context] find in [lib] the component with given - [name] and plot the part [partnumber] at [origin] after - [transformation] into the graphical [context] and the fact that - the component is multipart. If the component is not found, raise - an exception, unless [allow_missing] is true. - - @return the updated graphical context *) + t -> + string -> + int -> + coord -> + transfo -> + bool -> + drawContext -> + drawContext * bool + (** [plot_comp lib name partnumber origin transformation + allow_missing context] + find in [lib] the component with given [name] and plot the part + [partnumber] at [origin] after [transformation] into the graphical + [context] and the fact that the component is multipart. If the + component is not found, raise an exception, unless [allow_missing] is + true. + + @return the updated graphical context *) end diff --git a/plotkicadsch/src/.ocamlformat b/plotkicadsch/src/.ocamlformat new file mode 100644 index 0000000..f0340fe --- /dev/null +++ b/plotkicadsch/src/.ocamlformat @@ -0,0 +1,7 @@ +profile = default +version = 0.20.1 +break-cases = nested +margin = 77 +parse-docstrings = true +wrap-comments = true +line-endings = lf diff --git a/plotkicadsch/src/boundingBox.mli b/plotkicadsch/src/boundingBox.mli index 59486e5..80e3b46 100644 --- a/plotkicadsch/src/boundingBox.mli +++ b/plotkicadsch/src/boundingBox.mli @@ -2,19 +2,12 @@ open Kicadsch.Sigs type t -val create: unit -> t - -val create_from_rect: coord -> coord -> t - -val create_from_limits: coord -> coord -> t - -val add_rect: t -> t -> t - -val add_point: t -> coord -> t - -val reformat: min_size:int -> extend:int -> t -> t -val as_rect: t -> coord*coord - -val overlap_ratio: t -> t -> float - -val compare: t -> t -> int +val create : unit -> t +val create_from_rect : coord -> coord -> t +val create_from_limits : coord -> coord -> t +val add_rect : t -> t -> t +val add_point : t -> coord -> t +val reformat : min_size:int -> extend:int -> t -> t +val as_rect : t -> coord * coord +val overlap_ratio : t -> t -> float +val compare : t -> t -> int diff --git a/plotkicadsch/src/kicadDiff.mli b/plotkicadsch/src/kicadDiff.mli index f29a149..ed2ad4d 100644 --- a/plotkicadsch/src/kicadDiff.mli +++ b/plotkicadsch/src/kicadDiff.mli @@ -1,26 +1,35 @@ -(** - schematic diffing module *) +(** schematic diffing module *) (** type of diffing. If internal, specify the application for showing SVGs **) type differ = Internal of string | Image_Diff -(** type of the file system for each leg of the diff *) type t +(** type of the file system for each leg of the diff *) +val git_fs : string -> t (** [git_fs rev] builds a file system tree based on a git revision [rev] *) -val git_fs: string -> t +val true_fs : string -> t (** [true_fs root] builds a fs from the file system [root] directory *) -val true_fs: string -> t +val doc : t -> string (** [doc fs] outputs the doc string of the file system [fs] *) -val doc: t -> string +val doit : + t -> + t -> + string option -> + differ -> + bool -> + string list -> + bool -> + SvgPainter.diff_colors option -> + string option -> + bool -> + string option -> + unit (** [doit fs_from fs_to filename differ textdiff libs keep colors allow_missing relative_path] - performs the diff of [filename] from [relative_path] if present between [fs_from] and [fs_to] - using strategy [differ] and using common [libs] and [colors] - scheme. If [textdiff], then a text diff is shown when no visual + performs the diff of [filename] from [relative_path] if present between + [fs_from] and [fs_to] using strategy [differ] and using common [libs] and + [colors] scheme. If [textdiff], then a text diff is shown when no visual diff, if [keep] then the diff file isn't removed after *) -val doit: t -> t -> string option -> - differ -> bool -> string list -> bool -> - SvgPainter.diff_colors option -> string option -> bool -> string option -> unit diff --git a/plotkicadsch/src/sysAbst.mli b/plotkicadsch/src/sysAbst.mli index 7046025..2a57e4f 100644 --- a/plotkicadsch/src/sysAbst.mli +++ b/plotkicadsch/src/sysAbst.mli @@ -1,10 +1,7 @@ val pread : string -> string array -> string Lwt.t - val exec : string -> string array -> Unix.process_status Lwt.t (* the two following function are meant to be used together *) val build_tmp_svg_name : keep:bool -> string -> string list -> string - val finalize_tmp_file : string -> keep:bool -> unit Lwt.t - val default_opener : unit -> string