diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da646f7..6e4fc20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -280,9 +280,8 @@ pages: MESON_ARGS: "-Ddocumentation=true" script: - .gitlab-ci/meson-build.sh - - ./doc/hugo/generate-protocol-docs.sh -v --scanner "$PWD/proto/ei-scanner" --protocol "$PWD/proto/protocol.xml" --index-page "$PWD/README.md" --template-dir "$PWD/doc/hugo" --output-dir "$PWD/_hugo" - - cd _hugo/ei && hugo && cd ../.. - - mv _hugo/ei/public/ public/ + - rm -rf public/ + - mv "$MESON_BUILDDIR"/doc/protocol/ei/public/ public/ - mkdir -p public/api - mv "$MESON_BUILDDIR"/doc/html/ public/api diff --git a/.gitlab-ci/ci.template b/.gitlab-ci/ci.template index 0e23398..5ae0db8 100644 --- a/.gitlab-ci/ci.template +++ b/.gitlab-ci/ci.template @@ -307,9 +307,8 @@ pages: MESON_ARGS: "-Ddocumentation=true" script: - .gitlab-ci/meson-build.sh - - ./doc/hugo/generate-protocol-docs.sh -v --scanner "$PWD/proto/ei-scanner" --protocol "$PWD/proto/protocol.xml" --index-page "$PWD/README.md" --template-dir "$PWD/doc/hugo" --output-dir "$PWD/_hugo" - - cd _hugo/ei && hugo && cd ../.. - - mv _hugo/ei/public/ public/ + - rm -rf public/ + - mv "$MESON_BUILDDIR"/doc/protocol/ei/public/ public/ - mkdir -p public/api - mv "$MESON_BUILDDIR"/doc/html/ public/api diff --git a/doc/meson.build b/doc/meson.build index dc2bb41..6e16eff 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1 +1,2 @@ subdir('api') +subdir('protocol') diff --git a/doc/hugo/chapter.md.tmpl b/doc/protocol/chapter.md.tmpl similarity index 100% rename from doc/hugo/chapter.md.tmpl rename to doc/protocol/chapter.md.tmpl diff --git a/doc/hugo/config.toml b/doc/protocol/config.toml similarity index 52% rename from doc/hugo/config.toml rename to doc/protocol/config.toml index c5a8693..1955efb 100644 --- a/doc/hugo/config.toml +++ b/doc/protocol/config.toml @@ -1,4 +1,5 @@ -baseURL = 'https://libinput.pages.freedesktop.org/libei/' +# baseURL = 'https://libinput.pages.freedesktop.org/libei/' languageCode = 'en-us' title = 'ei protocol documentation' theme = 'hugo-theme-relearn' +relativeURLs = true diff --git a/doc/hugo/generate-protocol-docs.sh b/doc/protocol/generate-protocol-docs.sh similarity index 82% rename from doc/hugo/generate-protocol-docs.sh rename to doc/protocol/generate-protocol-docs.sh index 3be4402..755c477 100755 --- a/doc/hugo/generate-protocol-docs.sh +++ b/doc/protocol/generate-protocol-docs.sh @@ -2,13 +2,10 @@ # set -e +REPO_BASE_DIR="$PWD" -SCANNER="$PWD/ei-scanner" -PROTOFILE="$PWD/protocol.xml" -TEMPLATEDIR="$PWD" OUTDIR="$PWD" SITENAME="ei" -INDEXPAGE="" while [[ $# -gt 0 ]]; do case "$1" in @@ -36,6 +33,10 @@ while [[ $# -gt 0 ]]; do INDEXPAGE="$2" shift 2; ;; + --git-repo) + REPO_BASE_DIR="$2" + shift 2; + ;; **) echo "Unknown argument: $1" exit 1 @@ -43,6 +44,22 @@ while [[ $# -gt 0 ]]; do esac done +if [[ -z "$SCANNER" ]]; then + SCANNER="$REPO_BASE_DIR/proto/ei-scanner" +fi + +if [[ -z "$PROTOFILE" ]]; then + PROTOFILE="$REPO_BASE_DIR/proto/protocol.xml" +fi + +if [[ -z "$TEMPLATEDIR" ]]; then + TEMPLATEDIR="$REPO_BASE_DIR/doc/protocol/" +fi + +if [[ -z "$INDEXPAGE" ]]; then + INDEXPAGE="$REPO_BASE_DIR/README.md" +fi + SITEDIR="$OUTDIR/$SITENAME" if [[ -e "$SITEDIR" ]]; then echo "$SITEDIR already exists, updating" @@ -84,4 +101,6 @@ done < <($SCANNER --component=ei "$PROTOFILE" - < /dev/null || exit 1 diff --git a/doc/hugo/interface.md.tmpl b/doc/protocol/interface.md.tmpl similarity index 100% rename from doc/hugo/interface.md.tmpl rename to doc/protocol/interface.md.tmpl diff --git a/doc/protocol/meson.build b/doc/protocol/meson.build new file mode 100644 index 0000000..d0e58e5 --- /dev/null +++ b/doc/protocol/meson.build @@ -0,0 +1,24 @@ +if not get_option('documentation') + subdir_done() +endif + +hugo = find_program('hugo', required : false) +if not hugo.found() + error('Program "hugo" not found or not executable. Try building with -Ddocumentation=false') +endif + +hugo_script = find_program('generate-protocol-docs.sh') + +src_hugo = files( + 'config.toml', + 'chapter.md.tmpl', + 'interface.md.tmpl', +) + +custom_target('hugo', + input : src_hugo + [protocol_xml], + output : [ 'doc' ], + command : [ hugo_script, '--git-repo', meson.project_source_root(), '--output-dir', meson.current_build_dir() ], + install : false, + build_by_default : true, +)