Skip to content

Commit 4ae4152

Browse files
authored
docs(api): inline svg/emoji recipes, blank-anchor @throws, emoji publish setup (#222)
* refactor(api): name paragraph inline svg/emoji adders inlineSvgIcon/inlineEmoji ParagraphBuilder's inline adders now follow the existing inlineText / inlineImage / inlineLink convention: svgIcon -> inlineSvgIcon and emoji -> inlineEmoji (all overloads). RichText keeps its bare svgIcon / emoji names, which are internally consistent there. The API is unreleased (@SInCE 1.9.0), so there is no deprecation bridge. Also adds two InlineSvgRenderTest cases for inline-SVG paths that only single-line paragraphs reached before: an icon that wraps onto a later line (asserting that line grows to the icon via lineHeight > textLineHeight) and an icon inside a paragraph that splits across a page break (it still paints on its head page). * docs(api): add inline SVG/emoji recipes and document the blank-anchor throw - New "Inline SVG icons" and "Emoji / shortcodes" sections in the rich-text recipe, restoring the "every shipped feature has a recipe" guarantee; both recipe indexes updated. - @throws IllegalArgumentException on every link-by-anchor builder method (linkTo / inlineLinkTo / imageLinkTo / shapeLinkTo across RichText and the Paragraph / Barcode / Ellipse / Image / Line / Shape / Table builders), spelling out that a blank anchor throws while the anchor(...) setter clears. - Correct EmojiLibrary's class doc: it bundles the Noto Emoji set (SIL OFL 1.1), not a "small jdecked/twemoji starter set". * build(release): align central-publishing to 0.11.0, add publish-emoji workflow Bump central-publishing-maven-plugin 0.10.0 -> 0.11.0 in the emoji, fonts and bundle standalone poms to match the engine pom (#219); they share no parent, so the literal is swept by hand. Add publish-emoji.yml mirroring publish-fonts.yml (emoji-v* tag, -f emoji/pom.xml, -P release) so graph-compose-emoji publishes to Central independently — matching the emoji-v* prose already in emoji/pom.xml.
1 parent 89e7ff8 commit 4ae4152

16 files changed

Lines changed: 138 additions & 7 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish emoji to Maven Central
2+
3+
# Publishes the graph-compose-emoji companion artifact to Maven Central,
4+
# independently of the engine. The bundled Noto Emoji glyphs change rarely, so
5+
# they release on their OWN tag line (emoji-v*) — pushing an engine v* tag
6+
# never touches them, and re-publishing emoji does not require an engine
7+
# release. This mirrors publish-fonts.yml but targets emoji/pom.xml.
8+
#
9+
# Tagging: emoji-vX.Y.Z (e.g. emoji-v1.0.0). The emoji artifact carries its
10+
# own independent version (see emoji/pom.xml) — keep it in sync with the tag.
11+
#
12+
# Human prerequisites are identical to publish.yml (GPG key + Central token
13+
# secrets). See docs/contributing/release-process.md for the runbook.
14+
15+
on:
16+
push:
17+
tags:
18+
- 'emoji-v*'
19+
workflow_dispatch:
20+
inputs:
21+
tag:
22+
description: 'Existing emoji-v*-prefixed tag to (re-)publish'
23+
required: true
24+
type: string
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
publish-emoji:
31+
name: Publish ${{ github.ref_name }} to Maven Central
32+
runs-on: ubuntu-latest
33+
# Only ship plain semver tags (emoji-vX.Y.Z) to Central; pre-release
34+
# suffixes ship nowhere from here.
35+
if: |
36+
github.event_name == 'workflow_dispatch' ||
37+
(!contains(github.ref, '-rc') && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-snapshot'))
38+
env:
39+
JAVA_TOOL_OPTIONS: -Djava.awt.headless=true
40+
41+
steps:
42+
- name: Check out repository at tag
43+
uses: actions/checkout@v7
44+
with:
45+
ref: ${{ github.event.inputs.tag || github.ref }}
46+
47+
- name: Set up Temurin JDK 17 with Central credentials and GPG key
48+
uses: actions/setup-java@v5
49+
with:
50+
distribution: temurin
51+
java-version: '17'
52+
cache: maven
53+
server-id: central
54+
server-username: CENTRAL_USERNAME
55+
server-password: CENTRAL_TOKEN
56+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
57+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
58+
59+
- name: Publish emoji to Maven Central
60+
# Activates the emoji module's release profile (sources + javadoc +
61+
# gpg sign + central-publishing) and flips gpg.skip=false. Blocks
62+
# until Sonatype's validator confirms validation.
63+
run: ./mvnw -B -ntp -f emoji/pom.xml -P release -Dgpg.skip=false deploy
64+
env:
65+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
66+
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }}
67+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

bundle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<graphcompose.fonts.version>1.0.0</graphcompose.fonts.version>
6868

6969
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
70-
<central.publishing.plugin.version>0.10.0</central.publishing.plugin.version>
70+
<central.publishing.plugin.version>0.11.0</central.publishing.plugin.version>
7171

7272
<gpg.skip>true</gpg.skip>
7373
</properties>

docs/recipes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authoring API; public application code should not import
1919
| [Layered page design](recipes/layered-page-design.md) | Choosing between page backgrounds, rows, layer stacks, and canvases |
2020
| [Absolute placement](recipes/absolute-placement.md) | `addCanvas` + `position(x, y)` for pixel-precise certificates and badges |
2121
| [Tables](recipes/tables.md) | Row span, zebra rows, totals row, repeated header on page break |
22-
| [Rich text](recipes/rich-text.md) | `RichText` mixed-style runs, inline links/images/shapes, checkboxes |
22+
| [Rich text](recipes/rich-text.md) | `RichText` mixed-style runs, inline links/images/shapes, SVG icons, emoji shortcodes, checkboxes |
2323
| [Lists](recipes/lists.md) | `addList`, marker customisation, nested lists with per-depth markers |
2424
| [Timelines](recipes/timelines.md) | `addTimeline`: markers on a connector rail, geometry and text-style controls |
2525
| [Barcodes](recipes/barcodes.md) | QR / Code 128 / EAN / UPC and friends, tinting, quiet zone |

docs/recipes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ API, with copy-pasteable snippets verified against the current release.
88
| Recipe | Covers |
99
|---|---|
1010
| [charts.md](charts.md) | Native vector bar / line / area / pie-donut charts: data–spec–style layers, axis & grid toggles, point markers, value-label halos, legend placement, translucent area fills |
11-
| [rich-text.md](rich-text.md) | `RichText` mixed-style runs in one paragraph: bold/accent/styled segments, inline links, inline images, inline shapes and checkboxes |
11+
| [rich-text.md](rich-text.md) | `RichText` mixed-style runs in one paragraph: bold/accent/styled segments, inline links, inline images, inline SVG icons, emoji shortcodes, inline shapes and checkboxes |
1212
| [lists.md](lists.md) | `addList`: quick bulleted lists, marker customisation, nested lists with per-depth markers, spacing and styled items |
1313
| [timelines.md](timelines.md) | `addTimeline`: markers (dot / circle / numbered / square) on a connector rail, geometry and text-style controls, pagination opt-ins |
1414
| [keep-together.md](keep-together.md) | `keepTogether()` / `keepEntriesTogether()` — blocks that relocate whole instead of orphaning a heading at a page break |

docs/recipes/rich-text.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,52 @@ relative to the surrounding line (`CENTER` by default); the full
9898
overload adds a `baselineOffset` and `DocumentLinkOptions` for a
9999
clickable inline image.
100100

101+
## Inline SVG icons
102+
103+
A parsed `SvgIcon` sits on the text baseline like a word, drawn as crisp
104+
vector layers that carry their own colours — so it renders independently
105+
of the active font's glyph coverage. `size` is the glyph height in points;
106+
the width follows the icon's aspect ratio.
107+
108+
```java
109+
import com.demcha.compose.document.svg.SvgIcon;
110+
111+
SvgIcon star = SvgIcon.parse(
112+
"<svg viewBox='0 0 24 24'>"
113+
+ " <path d='M12 2l3 7h7l-5.5 4 2 7L12 16l-6.5 4 2-7L2 9h7z' fill='#f5b301'/>"
114+
+ "</svg>");
115+
116+
section.addRich(rich -> rich
117+
.plain("Rated ")
118+
.svgIcon(star, 11)
119+
.plain(" by reviewers."));
120+
```
121+
122+
On `ParagraphBuilder` the equivalent call is `inlineSvgIcon(icon, size)`;
123+
both take `alignment` / `baselineOffset` / link overloads and a clickable
124+
form via `DocumentLinkOptions`. `SvgIcon.parse(String)` reads inline SVG
125+
markup; `SvgIcon.read(Path)` loads it from a file.
126+
127+
## Emoji / shortcodes
128+
129+
`emoji(":code:")` resolves a GitHub-style shortcode to an inline colour
130+
glyph through `EmojiLibrary`. Resolution is lenient: an unknown shortcode —
131+
or no emoji set on the classpath — falls back to the literal text, the way
132+
GitHub renders an unrecognised `:code:`.
133+
134+
```java
135+
section.addRich(rich -> rich
136+
.plain("Deploy ")
137+
.emoji(":white_check_mark:", 11)
138+
.plain(" succeeded ")
139+
.emoji(":rocket:", 11));
140+
```
141+
142+
On `ParagraphBuilder` the call is `inlineEmoji(":code:", size)`. Glyphs ship
143+
in the optional, independently-versioned `graph-compose-emoji` companion
144+
artifact (Noto Emoji, SIL OFL 1.1) — add it to the classpath to resolve
145+
shortcodes; the engine itself carries no emoji art.
146+
101147
## Inline shapes and checkboxes
102148

103149
Geometric figures drawn from geometry — not font glyphs — so they render

emoji/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<maven.source.plugin.version>3.4.0</maven.source.plugin.version>
8181
<maven.javadoc.plugin.version>3.12.0</maven.javadoc.plugin.version>
8282
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
83-
<central.publishing.plugin.version>0.10.0</central.publishing.plugin.version>
83+
<central.publishing.plugin.version>0.11.0</central.publishing.plugin.version>
8484

8585
<!-- See the engine pom: opted in via -Dgpg.skip=false on the publish workflow. -->
8686
<gpg.skip>true</gpg.skip>

fonts/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<maven.source.plugin.version>3.4.0</maven.source.plugin.version>
7878
<maven.javadoc.plugin.version>3.12.0</maven.javadoc.plugin.version>
7979
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
80-
<central.publishing.plugin.version>0.10.0</central.publishing.plugin.version>
80+
<central.publishing.plugin.version>0.11.0</central.publishing.plugin.version>
8181

8282
<!-- See the engine pom: opted in via -Dgpg.skip=false on the publish workflow. -->
8383
<gpg.skip>true</gpg.skip>

src/main/java/com/demcha/compose/document/dsl/BarcodeBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public BarcodeBuilder linkTarget(DocumentLinkTarget linkTarget) {
246246
*
247247
* @param anchor target anchor name
248248
* @return this builder
249+
* @throws IllegalArgumentException if {@code anchor} is blank
249250
* @since 1.9.0
250251
*/
251252
public BarcodeBuilder linkTo(String anchor) {

src/main/java/com/demcha/compose/document/dsl/EllipseBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public EllipseBuilder linkTarget(DocumentLinkTarget linkTarget) {
158158
*
159159
* @param anchor target anchor name
160160
* @return this builder
161+
* @throws IllegalArgumentException if {@code anchor} is blank
161162
* @since 1.9.0
162163
*/
163164
public EllipseBuilder linkTo(String anchor) {

src/main/java/com/demcha/compose/document/dsl/ImageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public ImageBuilder linkTarget(DocumentLinkTarget linkTarget) {
192192
*
193193
* @param anchor target anchor name
194194
* @return this builder
195+
* @throws IllegalArgumentException if {@code anchor} is blank
195196
* @since 1.9.0
196197
*/
197198
public ImageBuilder linkTo(String anchor) {

0 commit comments

Comments
 (0)