diff --git a/.github/checklist.yml b/.github/checklist.yml index 54cd3d33306..37a6e172173 100644 --- a/.github/checklist.yml +++ b/.github/checklist.yml @@ -4,6 +4,6 @@ paths: "assets/stylesheets/**": - Consider providing screenshots in a PR comment to show the difference visually "docs/*.asciidoc": - - Consider generating documentation locally to verify it is rendered correctly using `tools/generate-htmldoc` + - Consider generating documentation locally to verify it is rendered correctly using `tools/generate-docs` "external/**": - Consider doing this change in the upstream repository directly, see external/os-autoinst-common/README.md diff --git a/.gitignore b/.gitignore index c59a79a0b2d..404bf823398 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ node_modules package-lock.json .tidyall.d/ openqa-documentation.html +docs/build/ +docs/vendor/ diff --git a/Makefile b/Makefile index d2aef3b023f..9a2b6fea284 100644 --- a/Makefile +++ b/Makefile @@ -350,3 +350,11 @@ test-helm-install: .PHONY: update-deps update-deps: tools/update-deps --specfile dist/rpm/openQA.spec + +.PHONY: generate-docs +generate-docs: + tools/generate-docs + +.PHONY: serve-docs +serve-docs: generate-docs + (cd docs/build/; python3 -m http.server) diff --git a/docs/Gemfile b/docs/Gemfile new file mode 100644 index 00000000000..a10be88da40 --- /dev/null +++ b/docs/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'asciidoctor' +gem 'pygments.rb' diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock new file mode 100644 index 00000000000..26ce9ab6040 --- /dev/null +++ b/docs/Gemfile.lock @@ -0,0 +1,15 @@ +GEM + remote: https://rubygems.org/ + specs: + asciidoctor (2.0.20) + pygments.rb (2.4.1) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + asciidoctor + pygments.rb + +BUNDLED WITH + 2.4.10 diff --git a/tools/generate-docs b/tools/generate-docs new file mode 100755 index 00000000000..bd78d4c4115 --- /dev/null +++ b/tools/generate-docs @@ -0,0 +1,23 @@ +#!/bin/bash -e + +# Navigate to the docs directory +cd "$(dirname "${BASH_SOURCE[0]}")/../docs" +mkdir -p ./build/ + +if [[ ! -e ./build/images ]]; then + ln -s ../images build/images +fi + +asciidoctor_bin=$(command -v asciidoctor) || true + +if [[ -z "$asciidoctor_bin" ]]; then + echo "asciidoc not found in PATH." + echo "Fallback to Rubygem's Asciidoc" + export BUNDLE_PATH=./vendor/ + # Make sure dependencies exist + bundle install + asciidoctor_bin="bundle exec asciidoctor" +fi + +# Run asciidoc +$asciidoctor_bin -o build/index.html ./index.asciidoc -d book diff --git a/tools/generate-htmldoc b/tools/generate-htmldoc deleted file mode 100755 index 79a98eb2173..00000000000 --- a/tools/generate-htmldoc +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -e - -cre=${cre:-"podman"} -$cre run -it --rm -v"$PWD"/:/openqa --workdir /openqa --env GEM_HOME=/home/squamata/.gem registry.opensuse.org/devel/openqa/ci/containers/base:latest tools/generate-htmldoc-in-container diff --git a/tools/generate-htmldoc-in-container b/tools/generate-htmldoc-in-container deleted file mode 100755 index 8dade344406..00000000000 --- a/tools/generate-htmldoc-in-container +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -e - -gem install asciidoctor pygments.rb - -asciidoctor_bin=$(command -v asciidoctor) || true -[[ -n "$asciidoctor_bin" ]] || \ - for asciidoctor_bin in "${GEM_HOME}"/bin/asciidoctor.ruby*; do :; done -set -x -"$asciidoctor_bin" -o openqa-documentation.html docs/index.asciidoc -d book