This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A small Java library of Asciidoctor extensions, published to Maven Central as
com.lealceldeiro:asciidoc-extensions. It provides custom macros used when rendering
AsciiDoc (to PDF/HTML):
calc— simple arithmetic:calc:sum[...],sub,multiply,dividecalc_exp— evaluates a math expression (backed by mXparser)calc_date— date arithmetic / formattingchart— a line-chart block macro that renders an inline SVG
Full macro usage and attributes are documented in README.md; the release process is in
CONTRIBUTING.md. Prefer linking to those files over duplicating them here.
Java 25 (zulu) + Maven 3.9.9 — see .sdkmanrc (sdk env). Use the wrapper ./mvnw.
./mvnw test # unit + integration tests (surefire runs *Test AND *IntegrationTest)
./mvnw -Dgpg.skip=true install # build & install to the local ~/.m2 repoGPG gotcha: the maven-gpg-plugin sign goal is bound to the verify phase, so
test and package are clean locally, but verify / install / deploy try to sign and
fail without the signing key — pass -Dgpg.skip=true for local runs. CI imports the key
from secrets, so never bake -Dgpg.skip into the build itself.
No checkstyle/formatter plugin runs: style is governed by .editorconfig (2-space indent)
and analyzed by SonarCloud. Keep imports clean (no unused imports).
Each macro is a triplet, and adding one touches all three parts plus tests:
- A processor class (e.g.
calc/CalcMacro.java) extendingInlineMacroProcessor(orBlockProcessor, aschartdoes). - An
*ExtensionRegistryclass (e.g.CalcMacroExtensionRegistry.java) that registers the macro name with the AsciidoctorJ registry. - Both SPI service files under
src/main/resources/META-INF/services/—org.asciidoctor.extension.spi.ExtensionRegistryandorg.asciidoctor.jruby.extension.spi.ExtensionRegistry— must list the registry class. Missing either file means the macro silently fails to load. This is the easiest step to forget; the/add-macroskill walks the full checklist.
Shared building blocks (package root com.lealceldeiro.asciidoc.extensions): Macro.Key /
Macro.Value (attribute names), Operator, Util (rounding + sign→role helpers),
InvalidValue (sentinel results), Calc (interface), calclogger/ (logging).
- Macros return sentinel strings; they do not throw. Invalid input yields an
InvalidValuecode —NaN(bad number),NaO(bad operation),NaE(bad expression),NaL(bad license),NaA/NaVA(missing / too-short author),NaVM(invalid math),NaD/NaF(bad date / format). Tests assert on these strings. calc_expneeds a license. mXparser requires license confirmation, socalc_expreturnsNaA/NaVAwithout a valid documentauthor(≥ 5 chars) andNaLwithoutcalc_exp_license_type(commercial|non_commercial).- Results are
BigDecimalat scale 2, roundedHALF_EVENby default (override via therounding_modeattribute). - Testing convention: pure logic is unit-tested against
calculate(...); end-to-end rendering is covered by*IntegrationTestclasses that callAsciidoctor.convert(...)and assert on the produced HTML.
See CONTRIBUTING.md. In short: bump <version> on a chore branch → PR → merge → tag
release/x.y.z on main → git push --tags (the maven-publish workflow deploys to
Central). Config-only changes with no functional impact don't need a version bump/release.