-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2601 from owncloud/migrate-docs-makefile-to-cli-s…
…cript Replace the Documentation Makefile with a Shell Script
- Loading branch information
Showing
11 changed files
with
213 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -o noclobber | ||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
ACTION= | ||
FONTS_DIRECTORY="fonts" | ||
MANUAL_NAME="Android Client manual" | ||
EXPORT_FILENAME_PREFIX="ownCloud_Android_App_Manual" | ||
RELEASE_DATE=$(date +'%B %d, %Y') | ||
STYLE="owncloud" | ||
STYLES_DIRECTORY="resources/themes" | ||
LANGUAGE= | ||
|
||
ERR_UNSUPPORTED_LANGUAGE=20 | ||
ERR_UNSUPPORTED_MANUAL=21 | ||
ERR_UNSUPPORTED_ACTION=22 | ||
ERR_LINTER_NOT_AVAILABLE=23 | ||
ERR_NO_LANGUAGE_SPECIFIED=24 | ||
|
||
if [[ -z "${VERSION:-}" ]]; then | ||
if [[ -n "${DRONE_TAG:-}" ]]; then | ||
VERSION=${DRONE_TAG/v//} | ||
else | ||
[[ -n "${DRONE_BRANCH:-}" ]] && VERSION=${DRONE_BRANCH/v//} || VERSION=master | ||
fi | ||
fi | ||
|
||
function usage() | ||
{ | ||
echo "Usage: bin/cli [-c] [-h] [-m] [-l <go|xml|json|php|kotlin|yaml>]" | ||
} | ||
|
||
function clean_build_dir() | ||
{ | ||
echo "Cleaning build directory..." | ||
rm -rvf "build/" | ||
echo "...build directory cleaned." | ||
} | ||
|
||
function validate_code_files() | ||
{ | ||
case $LANGUAGE in | ||
go) | ||
if command -v golint &>/dev/null; then | ||
echo "Validating go source files" && \ | ||
find ./modules/*_manual/examples -type f -name "*.go" \ | ||
-exec sh -c 'echo Linting {} && golint {} && echo' \; | ||
else | ||
echo "Golint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
json) | ||
if command -v jsonlint &>/dev/null; then | ||
find ./modules/*_manual/examples -type f -name "*.json" \ | ||
-exec sh -c 'echo Linting {} && jsonlint -qp {} && echo' \; | ||
else | ||
echo "jsonlint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
kotlin) | ||
if command -v ktlint &>/dev/null; then | ||
ktlint --reporter=plain "./modules/*_manual/**/*.kt" || true; | ||
else | ||
echo "ktlint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
php) | ||
if command -v php &>/dev/null; then | ||
find ./modules/*_manual/examples -type f -name "*.php" \ | ||
! -path "**/vendor/*" \ | ||
-exec php -l {} \; | ||
else | ||
echo "Golint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
xml) | ||
if command -v xmllint &>/dev/null; then | ||
find ./modules/*_manual/examples -type f -name "*.xml" \ | ||
-exec xmllint --noout {} \; | ||
else | ||
echo "xmllint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
yaml) | ||
if command -v yamllint &>/dev/null; then | ||
find ./modules/*_manual/examples -type f -name "*.yml" \ | ||
-exec sh -c 'echo Linting {} && yamllint -f parsable {} && echo' \; | ||
else | ||
echo "yamllint is not available." | ||
echo "Exiting." | ||
exit $ERR_LINTER_NOT_AVAILABLE | ||
fi | ||
;; | ||
|
||
*) | ||
echo "That language is not, currently, supported" | ||
exit $ERR_UNSUPPORTED_LANGUAGE | ||
;; | ||
esac | ||
} | ||
|
||
function convert_antora_nav_to_asciidoc_list() | ||
{ | ||
local filename="$1" | ||
|
||
while read line; do | ||
if [[ ${line} =~ \]$ ]]; then | ||
level_offset=$(echo "$line" | awk -F"*" '{print NF-1}') | ||
revised_line=$(echo "$line" | sed 's/xref:/include::{module_base_path}/' | sed 's/\[.*\]//g' | sed -r 's/^\*{1,} //') | ||
echo "${revised_line}[leveloffset=+${level_offset}]" | ||
fi | ||
done < "${filename}" | ||
} | ||
|
||
function build_pdf_manual() | ||
{ | ||
local revision="$1" | ||
local build_directory="$(pwd)/build/server/${revision}/ROOT/" | ||
local book_file="books/${EXPORT_FILENAME_PREFIX}.adoc" | ||
local nav_file="modules/ROOT/nav.adoc" | ||
local pdf_filename="$(pwd)/build/server/${revision}/ROOT/${EXPORT_FILENAME_PREFIX}.pdf" | ||
|
||
echo "Generating PDF version '${revision}' of the ${MANUAL_NAME}, dated: ${RELEASE_DATE}" | ||
|
||
mkdir -p "$build_directory" | ||
|
||
asciidoctor-pdf --quiet -d book \ | ||
-a pdf-stylesdir="${STYLES_DIRECTORY}/" \ | ||
-a pdf-fontsdir="${FONTS_DIRECTORY}" \ | ||
-a pdf-style="${STYLE}" \ | ||
-a examplesdir="$(pwd)/modules/ROOT/examples/" \ | ||
-a imagesdir="$(pwd)/modules/ROOT/assets/images/" \ | ||
-a module_base_path="modules/ROOT/pages/" \ | ||
-a partialsdir="$(pwd)/modules/ROOT/pages/_partials/" \ | ||
-a revnumber="${revision}" \ | ||
-a revdate="${RELEASE_DATE}" \ | ||
--base-dir "$(pwd)" \ | ||
--out-file "${pdf_filename}" \ | ||
- < <(cat $book_file <(convert_antora_nav_to_asciidoc_list "$nav_file")) | ||
|
||
echo "The ${MANUAL_NAME} has been converted to PDF format." | ||
echo "It is available at: ${pdf_filename}." | ||
} | ||
|
||
while getopts ":hcmdl:" o; do | ||
case "${o}" in | ||
m) | ||
ACTION="BUILD_MANUALS" | ||
;; | ||
l) | ||
ACTION="VALIDATE" | ||
LANGUAGE=${OPTARG} | ||
;; | ||
c) | ||
ACTION="CLEAN" | ||
;; | ||
h|*) | ||
ACTION="HELP" | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
case "$ACTION" in | ||
BUILD_MANUALS) | ||
build_pdf_manual "$VERSION" | ||
;; | ||
CLEAN) | ||
clean_build_dir | ||
;; | ||
VALIDATE) | ||
if [[ -z $LANGUAGE ]]; then | ||
echo "No language was specified to be validated." | ||
echo "Use the -l option to specify one." | ||
echo "exiting." | ||
exit $ERR_NO_LANGUAGE_SPECIFIED | ||
fi | ||
validate_code_files | ||
;; | ||
HELP | *) | ||
usage | ||
exit $ERR_UNSUPPORTED_ACTION | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,3 @@ The ownCloud Team <[email protected]> | |
:toclevels: 1 | ||
:icons: font | ||
:icon-set: octicon | ||
|
||
include::modules/ROOT/pages/index.adoc[leveloffset=+1] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters