Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocamlformat #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ uninstall:
distrib:
dune-release tag
dune-release

format:
ocamlformat kicadsch/src/*.ml[i] --inplace
ocamlformat plotkicadsch/src/*.ml[i] --inplace
7 changes: 7 additions & 0 deletions kicadsch/src/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
profile = default
version = 0.20.1
break-cases = nested
margin = 77
parse-docstrings = true
wrap-comments = true
line-endings = lf
140 changes: 76 additions & 64 deletions kicadsch/src/kicadSch_sigs.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(**
Kicad modules Signatures *)
(** Kicad modules Signatures *)

(** orientation of a text *)
type orientation = Orient_H | Orient_V (** *)
Expand All @@ -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
Expand All @@ -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
7 changes: 7 additions & 0 deletions plotkicadsch/src/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
profile = default
version = 0.20.1
break-cases = nested
margin = 77
parse-docstrings = true
wrap-comments = true
line-endings = lf
25 changes: 9 additions & 16 deletions plotkicadsch/src/boundingBox.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 21 additions & 12 deletions plotkicadsch/src/kicadDiff.mli
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions plotkicadsch/src/sysAbst.mli
Original file line number Diff line number Diff line change
@@ -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