From 74594e80185c479dd7d4b10db0864ff580f3cb1d Mon Sep 17 00:00:00 2001 From: Jaro Date: Tue, 7 Mar 2023 21:55:17 +0100 Subject: [PATCH] Use internal library to hide non-public modules. --- balkon.cabal | 47 ++++++++++++------- {src => lib}/Data/Text/ParagraphLayout.hs | 0 lib/Data/Text/ParagraphLayout/Rect.hs | 17 +++++++ .../Text/ParagraphLayout/Internal/Fragment.hs | 2 +- .../Text/ParagraphLayout/Internal/Plain.hs | 2 +- .../ParagraphLayout/{ => Internal}/Rect.hs | 2 +- 6 files changed, 50 insertions(+), 20 deletions(-) rename {src => lib}/Data/Text/ParagraphLayout.hs (100%) create mode 100644 lib/Data/Text/ParagraphLayout/Rect.hs rename src/Data/Text/ParagraphLayout/{ => Internal}/Rect.hs (97%) diff --git a/balkon.cabal b/balkon.cabal index 2f7afa4..9e6b383 100644 --- a/balkon.cabal +++ b/balkon.cabal @@ -87,34 +87,30 @@ common language common warnings ghc-options: -Wall --- TODO: Utilise internal libraries --- (https://cabal.readthedocs.io/en/3.4/cabal-package.html#sublibs) --- to avoid exposing modules solely for tests. -library +library balkon-internal import: language, warnings - -- Directories containing source files. + -- Directories containing source files of the internal library. hs-source-dirs: src - -- Modules exported by the library. + -- Modules exported to tests and to the public part of the library. exposed-modules: - Data.Text.ParagraphLayout, Data.Text.ParagraphLayout.Internal.Break, Data.Text.ParagraphLayout.Internal.Fragment, Data.Text.ParagraphLayout.Internal.LineHeight, Data.Text.ParagraphLayout.Internal.Plain, - Data.Text.ParagraphLayout.Internal.ProtoFragment + Data.Text.ParagraphLayout.Internal.Rect, Data.Text.ParagraphLayout.Internal.ResolvedSpan, Data.Text.ParagraphLayout.Internal.Run, + Data.Text.ParagraphLayout.Internal.Script, Data.Text.ParagraphLayout.Internal.Span, Data.Text.ParagraphLayout.Internal.TextContainer, - Data.Text.ParagraphLayout.Internal.Zipper, - Data.Text.ParagraphLayout.Rect + Data.Text.ParagraphLayout.Internal.Zipper - -- Modules included in this library but not exported. - other-modules: Data.Text.ParagraphLayout.Internal.Script + -- Modules used purely internally and not in any tests. + other-modules: + Data.Text.ParagraphLayout.Internal.ProtoFragment - -- Other library packages from which modules are imported. build-depends: base ^>=4.15.1.0, harfbuzz-pure ^>=1.0.2.0, @@ -122,6 +118,22 @@ library text-icu ^>=0.8.0.2, unicode-data-scripts ^>=0.2.0.1 +library + import: language, warnings + + -- Directories containing source files. + hs-source-dirs: lib + + -- Modules exported by the library. + exposed-modules: + Data.Text.ParagraphLayout, + Data.Text.ParagraphLayout.Rect + + -- Other library packages from which modules are imported. + build-depends: + base ^>=4.15.1.0, + balkon-internal + test-suite balkon-test import: language, warnings @@ -148,16 +160,17 @@ test-suite balkon-test -- Test dependencies. build-depends: - base ^>=4.15.1.0, + base, balkon, + balkon-internal, bytestring ^>=0.11.4.0, filepath ^>=1.4.100.0, + harfbuzz-pure, hspec, hspec-discover, hspec-golden ^>=0.2.0.0, - harfbuzz-pure ^>=1.0.2.0, - text ^>=2.0.1, - text-icu ^>=0.8.0.2 + text, + text-icu build-tool-depends: hspec-discover:hspec-discover diff --git a/src/Data/Text/ParagraphLayout.hs b/lib/Data/Text/ParagraphLayout.hs similarity index 100% rename from src/Data/Text/ParagraphLayout.hs rename to lib/Data/Text/ParagraphLayout.hs diff --git a/lib/Data/Text/ParagraphLayout/Rect.hs b/lib/Data/Text/ParagraphLayout/Rect.hs new file mode 100644 index 0000000..2ba4e71 --- /dev/null +++ b/lib/Data/Text/ParagraphLayout/Rect.hs @@ -0,0 +1,17 @@ +-- | Representation of an axis-aligned rectangle on a 2D plane, with one of its +-- corners being a designated origin point. +module Data.Text.ParagraphLayout.Rect + (Rect(Rect, x_origin, y_origin, x_size, y_size) + ,height + ,union + ,width + ,x_max + ,x_min + ,x_terminus + ,y_max + ,y_min + ,y_terminus + ) +where + +import Data.Text.ParagraphLayout.Internal.Rect diff --git a/src/Data/Text/ParagraphLayout/Internal/Fragment.hs b/src/Data/Text/ParagraphLayout/Internal/Fragment.hs index ba6aec5..cc1515d 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Fragment.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Fragment.hs @@ -4,7 +4,7 @@ where import Data.Int (Int32) import Data.Text.Glyphize (GlyphInfo, GlyphPos) -import Data.Text.ParagraphLayout.Rect +import Data.Text.ParagraphLayout.Internal.Rect -- | Box fragment or fragment (CSS3), except that continuous text even within -- one line can be split into multiple fragments because of spans or changes in diff --git a/src/Data/Text/ParagraphLayout/Internal/Plain.hs b/src/Data/Text/ParagraphLayout/Internal/Plain.hs index ebe2f8b..54edec4 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Plain.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Plain.hs @@ -44,11 +44,11 @@ import Data.Text.ParagraphLayout.Internal.Break import Data.Text.ParagraphLayout.Internal.Fragment import Data.Text.ParagraphLayout.Internal.LineHeight import qualified Data.Text.ParagraphLayout.Internal.ProtoFragment as PF +import Data.Text.ParagraphLayout.Internal.Rect import qualified Data.Text.ParagraphLayout.Internal.ResolvedSpan as RS import Data.Text.ParagraphLayout.Internal.Run import Data.Text.ParagraphLayout.Internal.Span import Data.Text.ParagraphLayout.Internal.TextContainer -import Data.Text.ParagraphLayout.Rect -- | Text to be laid out as a paragraph. -- diff --git a/src/Data/Text/ParagraphLayout/Rect.hs b/src/Data/Text/ParagraphLayout/Internal/Rect.hs similarity index 97% rename from src/Data/Text/ParagraphLayout/Rect.hs rename to src/Data/Text/ParagraphLayout/Internal/Rect.hs index 5b79f40..12f9c10 100644 --- a/src/Data/Text/ParagraphLayout/Rect.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Rect.hs @@ -1,6 +1,6 @@ -- | Representation of an axis-aligned rectangle on a 2D plane, with one of its -- corners being a designated origin point. -module Data.Text.ParagraphLayout.Rect +module Data.Text.ParagraphLayout.Internal.Rect (Rect(Rect, x_origin, y_origin, x_size, y_size) ,height ,union -- 2.30.2