Skip to content

Commit

Permalink
Merge commit '55b5b33e572f16b6e9c15e123caab2b0bdc3dfb7'
Browse files Browse the repository at this point in the history
  • Loading branch information
h1romas4 committed Oct 15, 2023
2 parents e100cdb + 55b5b33 commit 071672b
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/build-codespaces-container.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# build contaner for GitHub Codespaces
# build container for GitHub Codespaces
#
sudo apt-get -y update
sudo apt-get -y upgrade
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
distribution: 'temurin'
java-version: ${{ matrix.java }}

- name: Build with Gradle (Ubuntu)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
distribution: 'temurin'
java-version: ${{ matrix.java }}

- name: Build with Gradle (Ubuntu)
Expand Down
4 changes: 4 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ image::https://github.com/h1romas4/asciidoctor-gradle-template/workflows/Build/b

image:https://gitpod.io/button/open-in-gitpod.svg[Open in Gitpod, link=https://gitpod.io/#https://github.com/h1romas4/asciidoctor-gradle-template]

== Try with Codespaces

image:https://github.com/codespaces/badge.svg[Open in Codespaces, link=https://codespaces.new/h1romas4/docs/asciidoctor-gradle-template]

== License

MIT License
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ tasks.register('cleanDocs', Delete) {
* また .adoc からのリンク切れもエラー終了しない。
* ./gradlew -q checkSyncImage
*
* @see buildSrc/src/main/groovy/AsciidocTasks.groovy
* @see buildSrc/src/main/groovy/SyncImageTask.groovy
*/
tasks.register('checkSyncImage', SyncImageTask) {
group 'documentation'
Expand All @@ -106,7 +106,7 @@ tasks.register('checkSyncImage', SyncImageTask) {
*
* ./gradlew -q checkPdfInfo
*
* @see buildSrc/src/main/groovy/AsciidocTasks.groovy
* @see buildSrc/src/main/groovy/PdfInfoTask.groovy
*/
tasks.register('checkPdfInfo', PdfInfoTask) {
group 'documentation'
Expand Down
11 changes: 5 additions & 6 deletions buildSrc/src/main/groovy/PdfInfoTask.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.InputFile
Expand All @@ -24,12 +23,12 @@ abstract class PdfInfoTask extends DefaultTask {
*/
@TaskAction
def checkPdfInfo() {
BodyContentHandler handler = new BodyContentHandler()
Metadata metadata = new Metadata()
FileInputStream input = new FileInputStream(pdfFile)
ParseContext context = new ParseContext()
def handler = new BodyContentHandler()
def metadata = new Metadata()
def input = new FileInputStream(pdfFile)
def context = new ParseContext()

PDFParser pdf = new PDFParser()
def pdf = new PDFParser()
pdf.parse(input, handler, metadata, context)

metadata.names().sort().each { name ->
Expand Down
28 changes: 10 additions & 18 deletions buildSrc/src/main/groovy/SyncImageTask.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import java.io.File
import groovy.io.FileType
import org.asciidoctor.Asciidoctor
import org.asciidoctor.SafeMode
Expand All @@ -25,19 +24,13 @@ abstract class SyncImageTask extends DefaultTask {
* 起点 Asciidoc 文書(include も処理する)
*/
@Input
def index
String index

/**
* 画像として認識するファイルシステム上の拡張子
*/
@Input
def imageExt = ['png', 'jpg']

/**
* 未使用画像をファイルシステムから削除するかどうかを決定するフラグ(TODO: 未実装)
*/
@Input
boolean remove = false
ArrayList<String> imageExt = ['png', 'jpg']

/**
* Asciidoc 文書から image ブロックの画像パスをリスト取得
Expand All @@ -47,10 +40,10 @@ abstract class SyncImageTask extends DefaultTask {
* @return [] baseDir からの相対画像パスリスト
*/
static def searchImageInAdoc(baseDir, index) {
def asciidoctor = Asciidoctor.Factory.create();
def asciidoctor = Asciidoctor.Factory.create()
// include パスを辿るために SafeMode.SAFE と baseDir を設定
def options = Options.builder().safe(SafeMode.SAFE).baseDir(baseDir).build()
def document = asciidoctor.load(new File("${baseDir}/${index}").getText(), options);
def document = asciidoctor.load(new File("${baseDir}/${index}").getText(), options)

document.findBy(["context": ":image"]).collect {
"${it.attributes.imagesdir}/${it.attributes.target}"
Expand All @@ -64,7 +57,7 @@ abstract class SyncImageTask extends DefaultTask {
* @param extension 検索拡張子文字列リスト
* @return [] baseDir からの相対パスリスト
*/
static def searchExtInDir(File baseDir, extension) {
static def searchExtInDir(baseDir, extension) {
def list = []
def basePath = "${baseDir}" + File.separator
def ext = extension.collect {
Expand All @@ -83,11 +76,11 @@ abstract class SyncImageTask extends DefaultTask {
/**
* リスト形式の文字列を表示用に縦に出力
*
* @param lists 文字列リスト
* @param list 文字列リスト
* @param prefix 前置文字列
*/
static def printls(lists, prefix = "") {
lists.each {
static def printls(list, prefix = "") {
list.each {
println "${prefix}${it}"
}
}
Expand All @@ -97,8 +90,8 @@ abstract class SyncImageTask extends DefaultTask {
*
* @param lists 文字列リスト
*/
static def normalizePath(lists) {
lists.collect {
static def normalizePath(list) {
list.collect {
it.replace(File.separator, "/")
}
}
Expand All @@ -124,4 +117,3 @@ abstract class SyncImageTask extends DefaultTask {
}
}
}

3 changes: 2 additions & 1 deletion src/docs/asciidoc/Chapter00/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ Asciidoc::
Diagram::
* PlantUML - Multi(MIT/Apache/BSD/EPL/GPLv3/LGPL) - https://github.com/plantuml/plantuml
* ditaa - LGPL-3.0 license - https://github.com/stathissideris/ditaa
Build Tool::
Java Development Kit & Build Tool::
* Eclipse Temurin - Multi(Apache License 2.0/GPLv2+CE/GPLv2+Assembly) - https://adoptium.net/about/
* SDKMAN - Apache License 2.0 - https://sdkman.io/
* Gradle - Apache License 2.0 - https://gradle.org/
Text Editor::
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/Chapter01/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OpenJDK Runtime Environment Temurin-11.0.20.1+1 (build 11.0.20.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.20.1+1 (build 11.0.20.1+1, mixed mode)
----

NOTE: 本文書では Java 11 を用いて解説します。また、ビルド時に僅かに内部処理のワーニングが出力されますが Java 17 でも期待通り動作することを確認しています。Java 21 に関しては周辺ツール対応待ちのステータスです
NOTE: 本文書では Java 11 を用いて解説します。また、ビルド時にいくつか内部処理のワーニングが出力されますが Java 17/21 の各 LTS バージョンでも期待通り動作することを確認しています

.Graphviz の導入
****
Expand Down
Loading

0 comments on commit 071672b

Please sign in to comment.