From nobody Sat Nov 6 13:57:13 2021 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 63B811842E01 for ; Sat, 6 Nov 2021 13:57:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmf7s1yh0z3JYD; Sat, 6 Nov 2021 13:57:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1FC574732; Sat, 6 Nov 2021 13:57:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6DvDac010315; Sat, 6 Nov 2021 13:57:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6DvDJr010314; Sat, 6 Nov 2021 13:57:13 GMT (envelope-from git) Date: Sat, 6 Nov 2021 13:57:13 GMT Message-Id: <202111061357.1A6DvDJr010314@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: "Danilo G. Baio" Subject: git: 82c271aa23 - main - documentation: Add experimental support for EPUB output List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dbaio X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 82c271aa234060749b3fd104f5e5e028fb8d18df Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dbaio: URL: https://cgit.FreeBSD.org/doc/commit/?id=82c271aa234060749b3fd104f5e5e028fb8d18df commit 82c271aa234060749b3fd104f5e5e028fb8d18df Author: Danilo G. Baio AuthorDate: 2021-11-06 13:53:31 +0000 Commit: Danilo G. Baio CommitDate: 2021-11-06 13:56:04 +0000 documentation: Add experimental support for EPUB output --- documentation/Makefile | 57 ++++++++++++++++++++++++++++++++++++ documentation/tools/asciidoctor.sh | 59 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/documentation/Makefile b/documentation/Makefile index 3b1a29d9bc..96d7ffafef 100644 --- a/documentation/Makefile +++ b/documentation/Makefile @@ -14,6 +14,7 @@ # If variable DOC_HTML_ARCHIVE is set, all documents will be # archived/compressed, and only these files will be kept in the public # directory. +# epub - build EPUB versions of the articles and books (Experimental). # # The run target uses hugo's built-in webserver to make the documentation site # available for local browsing. The documentation should have been built prior @@ -116,6 +117,11 @@ requirements-pdf: @(echo ${LOCALBASE}/bin/asciidoctor-pdf not found, please run 'pkg install rubygem-asciidoctor-pdf'; exit 1) .endif +requirements-epub: +.if !exists(${LOCALBASE}/bin/asciidoctor-epub3) + @(echo ${LOCALBASE}/bin/asciidoctor-epub3 not found, please run 'pkg install rubygem-asciidoctor-epub3'; exit 1) +.endif + starting-message: .PHONY @echo --------------------------------------------------------------- @echo Building the documentation @@ -242,3 +248,54 @@ html-archive-clean-files: find ${.CURDIR}/public/ ! -name '*.pdf' ! -name '*.tar.gz' -type f -delete find ${.CURDIR}/public/ -type d -empty -delete .endif + +# +# EPUB targets +# Use DOC_LANG to choose the language, e.g., make DOC_LANG="en fr" pdf-books +# +epub: epub-articles epub-books + +epub-books: requirements-epub generate-books-toc + @echo --------------------------------------------------------------- + @echo !!! EPUB output is experimental !!! + @echo + @echo Asciidoctor EPUB3 is currently alpha software. Use accordingly. Although the + @echo bulk of AsciiDoc content is converted, there’s still work needed to fill in + @echo gaps where conversion is incomplete or unstyled. + @echo https://docs.asciidoctor.org/epub3-converter/latest/#project-status + @echo --------------------------------------------------------------- +.for _lang in ${BOOK_LANGS} + ./tools/asciidoctor.sh books ${_lang} epub +.endfor + +epub-articles: requirements-epub + @echo --------------------------------------------------------------- + @echo !!! EPUB output is experimental !!! + @echo + @echo Asciidoctor EPUB3 is currently alpha software. Use accordingly. Although the + @echo bulk of AsciiDoc content is converted, there’s still work needed to fill in + @echo gaps where conversion is incomplete or unstyled. + @echo https://docs.asciidoctor.org/epub3-converter/latest/#project-status + @echo --------------------------------------------------------------- +.for _lang in ${ARTICLE_LANGS} + ./tools/asciidoctor.sh articles ${_lang} epub +.endfor + +epub-clean: epub-articles-clean epub-books-clean + +epub-books-clean: +.for _lang in ${BOOK_LANGS} + rm -fr ${.CURDIR}/public/${_lang}/books + -rmdir ${.CURDIR}/public/${_lang} +.endfor + -rmdir ${.CURDIR}/public/ + +epub-articles-clean: +.for _lang in ${ARTICLE_LANGS} + rm -fr ${.CURDIR}/public/${_lang}/articles +.if !exists(${.CURDIR}/public/${_lang}/books) + rm -fr ${.CURDIR}/public/${_lang} +.endif +.endfor + -rmdir ${.CURDIR}/public + diff --git a/documentation/tools/asciidoctor.sh b/documentation/tools/asciidoctor.sh index 28924d0b03..a834b2e532 100755 --- a/documentation/tools/asciidoctor.sh +++ b/documentation/tools/asciidoctor.sh @@ -28,6 +28,7 @@ LOCALBASE="/usr/local" ASCIIDOCTORPDF_CMD="${LOCALBASE}/bin/asciidoctor-pdf" +ASCIIDOCTOREPUB_CMD="${LOCALBASE}/bin/asciidoctor-epub3" build_pdf() { if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then @@ -78,7 +79,52 @@ build_pdf() { } -# build_epub() +build_epub() { + if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then + exit 1 + fi + + local doc_type="$1" + local doc_lang="$2" + local doc_name="$3" + + local cur_dir_source="content/$doc_lang/$doc_type/$doc_name/" + local cur_dir_output="public/$doc_lang/$doc_type/$doc_name/" + + if [ ! -d "$cur_dir_output" ]; then + mkdir -p "$cur_dir_output" + fi + + if [ "$doc_type" = "books" ]; then + local asciidoctor_type="book" + + if [ -f "${cur_dir_source}book.adoc" ]; then + local asciidoctor_file_name="book.adoc" + else + local asciidoctor_file_name="_index.adoc" + fi + fi + + if [ "$doc_type" = "articles" ]; then + local asciidoctor_type="article" + local asciidoctor_file_name="_index.adoc" + fi + + $ASCIIDOCTOREPUB_CMD \ + -r ./shared/lib/man-macro.rb \ + -r ./shared/lib/git-macro.rb \ + -r ./shared/lib/packages-macro.rb \ + -r ./shared/lib/inter-document-references-macro.rb \ + -r ./shared/lib/sectnumoffset-treeprocessor.rb \ + -r ./shared/lib/cross-document-references-macro.rb \ + --doctype="$asciidoctor_type" \ + -a skip-front-matter \ + -a lang="$doc_lang" \ + -a isonline=1 \ + -a env-beastie=1 \ + -o "${cur_dir_output}${doc_name}_${doc_lang}_POC_.epub" \ + "${cur_dir_source}${asciidoctor_file_name}" +} archive() { @@ -156,8 +202,17 @@ main() { archive "$doc_type" "$doc_lang" "$document" done ;; + epub) + for document in $(find "content/$doc_lang/$doc_type/" -type d -mindepth 1 -maxdepth 1 | awk -F '/' '{ print $4 }' | sort -n); do + if [ "$document" = "pgpkeys" ]; then + continue + fi + echo "asciidoctor epub: $doc_type $doc_lang $document" + build_epub "$doc_type" "$doc_lang" "$document" + done + ;; *) - echo "Formats available: archive, pdf" + echo "Formats available: archive, pdf, epub" exit 1 ;; esac