Skip to content

Commit eafbade

Browse files
committed
Generate a PDF for each non-snapshot version
1 parent 41947ee commit eafbade

12 files changed

Lines changed: 215 additions & 1 deletion

File tree

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
node-version-file: .tool-versions
3737
cache: npm
3838
cache-dependency-path: package-lock.json
39+
- name: Install Ruby
40+
uses: ruby/setup-ruby@ed55d55e820a01da7d3e4863a8c51a61d73c3228 # v1.274.0
41+
with:
42+
bundler-cache: true
3943
- name: Install JDKs
4044
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
4145
with:
@@ -67,7 +71,6 @@ jobs:
6771
if: env.DEPLOY == 'true'
6872
run: |
6973
rsync --recursive --delete --checksum --archive --safe-links --human-readable --prune-empty-dirs --stats \
70-
--exclude='*.pdf' \
7174
--exclude='_/font/roboto-*' \
7275
build/site/* \
7376
docs-repo

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
nodejs 24.12.0
2+
ruby 3.4.5

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'asciidoctor-pdf'
4+
gem 'rouge'

Gemfile.lock

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
Ascii85 (2.0.1)
5+
addressable (2.8.8)
6+
public_suffix (>= 2.0.2, < 8.0)
7+
afm (1.0.0)
8+
asciidoctor (2.0.26)
9+
asciidoctor-pdf (2.3.24)
10+
asciidoctor (~> 2.0)
11+
concurrent-ruby (~> 1.3)
12+
matrix (~> 0.4)
13+
prawn (~> 2.4.0)
14+
prawn-icon (~> 3.0.0)
15+
prawn-svg (~> 0.34.0)
16+
prawn-table (~> 0.2.0)
17+
prawn-templates (~> 0.1.0)
18+
treetop (~> 1.6.0)
19+
ttfunk (~> 1.7.0)
20+
concurrent-ruby (1.3.6)
21+
css_parser (1.21.1)
22+
addressable
23+
hashery (2.1.2)
24+
matrix (0.4.3)
25+
pdf-core (0.9.0)
26+
pdf-reader (2.15.0)
27+
Ascii85 (>= 1.0, < 3.0, != 2.0.0)
28+
afm (>= 0.2.1, < 2)
29+
hashery (~> 2.0)
30+
ruby-rc4
31+
ttfunk
32+
polyglot (0.3.5)
33+
prawn (2.4.0)
34+
pdf-core (~> 0.9.0)
35+
ttfunk (~> 1.7)
36+
prawn-icon (3.0.0)
37+
prawn (>= 1.1.0, < 3.0.0)
38+
prawn-svg (0.34.2)
39+
css_parser (~> 1.6)
40+
matrix (~> 0.4.2)
41+
prawn (>= 0.11.1, < 3)
42+
rexml (~> 3.2)
43+
prawn-table (0.2.2)
44+
prawn (>= 1.3.0, < 3.0.0)
45+
prawn-templates (0.1.2)
46+
pdf-reader (~> 2.0)
47+
prawn (~> 2.2)
48+
public_suffix (7.0.0)
49+
rexml (3.4.4)
50+
rouge (4.6.1)
51+
ruby-rc4 (0.1.5)
52+
treetop (1.6.18)
53+
polyglot (~> 0.3)
54+
ttfunk (1.7.0)
55+
56+
PLATFORMS
57+
ruby
58+
x86_64-linux
59+
60+
DEPENDENCIES
61+
asciidoctor-pdf
62+
rouge
63+
64+
BUNDLED WITH
65+
2.7.1

antora-assembler.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
component_version_filter:
2+
names: '**'
3+
asciidoc:
4+
attributes:
5+
source-highlighter: rouge
6+
toc: ''
7+
build:
8+
stderr: ignore

antora-playbook.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
antora:
22
extensions:
33
- '@antora/collector-extension'
4+
- '@antora/pdf-extension'
45
- require: '@antora/lunr-extension'
56
index_latest_only: true
67
index_by_heading: true
78
- require: '@springio/antora-extensions/root-component-extension'
89
root_component_name: junit
910
- require: '@springio/antora-extensions/root-attachments-extension'
11+
- require: './root-exports-extension.js'
12+
root_component_name: junit
13+
file_name: junit-user-guide
1014
site:
1115
title: JUnit User Guide
1216
url: https://docs.junit.org

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"dependencies": {
1010
"@antora/collector-extension": "1.0.2",
1111
"@antora/lunr-extension": "1.0.0-alpha.12",
12+
"@antora/pdf-extension": "^1.0.0-beta.15",
1213
"@springio/antora-extensions": "1.14.7",
1314
"highlight.js": "11.11.1"
1415
}

root-exports-extension.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict'
2+
3+
module.exports.register = function ({ config }) {
4+
const { rootComponentName, fileName = rootComponentName } = config
5+
this.on('navigationBuilt', ({ contentCatalog }) => {
6+
const { versions } = contentCatalog.getComponent(rootComponentName)
7+
versions.forEach(version => {
8+
const file = contentCatalog.resolveResource(`${version.version}@${rootComponentName}:ROOT:index.pdf`, {}, 'export', ['export'])
9+
if (file) {
10+
if (version.prerelease === '-SNAPSHOT') {
11+
contentCatalog.removeFile(file)
12+
} else {
13+
removeRootComponentNameFromFile(file, fileName)
14+
}
15+
}
16+
})
17+
})
18+
}
19+
20+
function removeRootComponentNameFromFile(file, fileName) {
21+
if (file.out) {
22+
file.out.dirname = removeFirstSegment(file.out.dirname)
23+
file.out.basename = file.out.basename.replace('index', fileName)
24+
file.out.path = removeFirstSegment(file.out.path).replace('index', fileName)
25+
file.out.moduleRootPath = '.'
26+
file.out.rootPath = '..'
27+
}
28+
if (file.pub) {
29+
if (file.pub.rootPath) {
30+
file.pub.rootPath = '..'
31+
}
32+
if (file.pub.moduleRootPath) {
33+
file.pub.moduleRootPath = '.'
34+
}
35+
file.pub.url = removeFirstSegment(file.pub.url).replace('index', fileName)
36+
}
37+
}
38+
39+
function removeFirstSegment(path) {
40+
if (path) {
41+
if (path.startsWith('/')) {
42+
return ('/' + path.split('/').slice(2).join('/')) || '.'
43+
} else {
44+
return (path.split('/').slice(1).join('/')) || '.'
45+
}
46+
}
47+
return path
48+
}

supplemental-ui/css/site-extra.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,13 @@ pre {
7979
padding: 1rem 1rem .75rem;
8080
margin: 1.5rem 0;
8181
}
82+
83+
.pdf-link {
84+
display: none;
85+
padding-right: .7rem
86+
}
87+
@media screen and (min-width:1024px) {
88+
.pdf-link {
89+
display:block
90+
}
91+
}

0 commit comments

Comments
 (0)