internal/

directory
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT

README

internal/

Private packages of the Paper module. Two conventions in here are deliberate and worth knowing before contributing.

Vendored test infrastructure — why not testify?

The root module must stay free of third-party test dependencies so that consumers of github.com/avdoseferovic/paper never inherit them through go.mod. That is the entire reason these four packages exist:

Package Replaces
internal/assert testify/assert (non-fatal assertions)
internal/require testify/require (fatal assertions)
internal/mocktest testify/mock (runtime for generated mocks)
internal/goleak go.uber.org/goleak (goroutine leak detection)

Do not introduce testify (or any other test framework) into the root module. Generated mocks in internal/mocks/ are rewritten from testify to internal/mocktest by make mocks (see internal/cmd/mockfix).

Test helpers

internal/test is the canonical golden-structure test helper (PaperTest.Equals against test/paper/*.json snapshots). The public pkg/test package is a thin re-export of it for library consumers.

The embedded PDF engine

internal/pdf is a gofpdf-derived PDF writer owned by this repository. It is intentionally self-contained; application code must depend on Paper's public packages, never on internal/pdf directly.

Directories

Path Synopsis
Package assert provides lightweight test assertions used by the root module.
Package assert provides lightweight test assertions used by the root module.
Package cache stores image bytes that have already been read from disk, so a document that reuses the same image does not read it again.
Package cache stores image bytes that have already been read from disk, so a document that reuses the same image does not read it again.
cmd
mockfix command
Command mockfix rewrites generated mocks in internal/mocks so they import the vendored mock runtime (internal/mocktest) instead of testify.
Command mockfix rewrites generated mocks in internal/mocks so they import the vendored mock runtime (internal/mocktest) instead of testify.
Package code generates barcode images: linear (Code 128), QR, and Data Matrix.
Package code generates barcode images: linear (Code 128), QR, and Data Matrix.
Package cssparse provides the small, bounded CSS rule/declaration parser shared by Paper's HTML and SVG renderers.
Package cssparse provides the small, bounded CSS rule/declaration parser shared by Paper's HTML and SVG renderers.
Package dependency holds the guard test that keeps the root module free of third-party imports.
Package dependency holds the guard test that keeps the root module free of third-party imports.
Package fixture provides pre-filled entities and props for tests, so test cases only have to state the fields they actually care about.
Package fixture provides pre-filled entities and props for tests, so test cases only have to state the fields they actually care about.
Package goleak provides a small goroutine leak check for this repository's tests.
Package goleak provides a small goroutine leak check for this repository's tests.
Package htmllimits holds the size limits applied when rendering HTML, such as maximum image and stylesheet sizes.
Package htmllimits holds the size limits applied when rendering HTML, such as maximum image and stylesheet sizes.
Package imagecodec converts images into a form the PDF writer can embed, decoding the source bytes and re-encoding them when the original format is not directly supported.
Package imagecodec converts images into a form the PDF writer can embed, decoding the source bytes and re-encoding them when the original format is not directly supported.
Package layout turns column weights into whole grid units and applies cell margins.
Package layout turns column weights into whole grid units and applies cell margins.
Package listnum formats the CSS numbering systems shared by list markers (<ol>) and CSS counters (counter(), counters()).
Package listnum formats the CSS numbering systems shared by list markers (<ol>) and CSS counters (counter(), counters()).
Package math resizes inner dimensions to fit inside outer ones while keeping the original aspect ratio.
Package math resizes inner dimensions to fit inside outer ones while keeping the original aspect ratio.
Package merror holds the default text style used to draw error messages onto a generated page.
Package merror holds the default text style used to draw error messages onto a generated page.
Package mock provides the small mock API subset used by generated internal test mocks.
Package mock provides the small mock API subset used by generated internal test mocks.
Package pdf contains Paper's internal PDF runtime.
Package pdf contains Paper's internal PDF runtime.
Package pdfscan holds a minimal byte scanner for the subset of PDF syntax that paper's reader, form filler and signer need in order to walk object dictionaries in place, without building a full object model.
Package pdfscan holds a minimal byte scanner for the subset of PDF syntax that paper's reader, form filler and signer need in order to walk object dictionaries in place, without building a full object model.
Package pngcodec encodes PNG images with pooled encoder state.
Package pngcodec encodes PNG images with pooled encoder state.
Package providers contains repository-wide provider guard tests.
Package providers contains repository-wide provider guard tests.
paper
Package paper implements the drawing provider that the document builder calls into.
Package paper implements the drawing provider that the document builder calls into.
paper/cellwriter
Package cellwriter draws the background and border of a single cell.
Package cellwriter draws the background and border of a single cell.
Package require provides fail-fast test assertions used by the root module.
Package require provides fail-fast test assertions used by the root module.
Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.
Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.
Package test compares a generated document tree against a stored JSON snapshot, and reports the first field that differs.
Package test compares a generated document tree against a stored JSON snapshot, and reports the first field that differs.
Package time measures how long a closure takes to run and reports it as a metrics.Time value.
Package time measures how long a closure takes to run and reports it as a metrics.Time value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL