Skip to content

Commit

Permalink
Add Windows Support for building doc (#1447)
Browse files Browse the repository at this point in the history
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Oct 5, 2023
1 parent 0aaf973 commit 499dab3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
38 changes: 38 additions & 0 deletions docs/build-htmls.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@echo off
@REM
@REM Copyright (c) 2023 Bosch.IO GmbH and others
@REM
@REM This program and the accompanying materials are made
@REM available under the terms of the Eclipse Public License 2.0
@REM which is available at https://www.eclipse.org/legal/epl-2.0/
@REM
@REM SPDX-License-Identifier: EPL-2.0
@REM

rem Checking for Redoc CLI and npm
call npx @redocly/cli --version 1> nul 2> nul

if ERRORLEVEL 1 (
echo [ERROR] Redoc CLI is not installed! Please make suer to install it before trying again.
exit 1
)

rem Execute the npx command
call npx @redocly/cli build-docs %cd%\content\rest-api\mgmt.yaml -o %cd%\content\rest-api\mgmt.html

if ERRORLEVEL 1 (
echo [ERROR] Failed to execute the Redoc CLI command form MGMT API.
exit 1
) else (
echo [INFO] Successfully executed the Redoc CLI command for MGMT API.
)

rem Execute the npx command
call npx @redocly/cli build-docs %cd%\content\rest-api\ddi.yaml -o %cd%\content\rest-api\ddi.html

if ERRORLEVEL 1 (
echo [ERROR] Failed to execute the Redoc CLI command form DDI API.
exit 1
) else (
echo [INFO] Successfully executed the Redoc CLI command for DDI API.
)
3 changes: 0 additions & 3 deletions docs/build-htmls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#!/bin/bash


CURRENT_DIR=$(pwd)

# Checking for Redoc CLI and npm
Expand All @@ -19,8 +18,6 @@ npx @redocly/cli --version > /dev/null 2>&1
if [ $? != 0 ]; then
echo "[ERROR] Redoc CLI is not installed! Please make suer to install it before trying again."
exit 1
else
echo "[INFO] Redoc CLI is already installed."
fi

# Execute the npx command
Expand Down
11 changes: 10 additions & 1 deletion docs/install-theme.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@REM

rem This script checks if 'hugo' is installed. Afterwards, the Hugo theme is downloaded.

hugo version
if ERRORLEVEL 1 (
echo [ERROR] Please install Hugo first before proceeding.
Expand All @@ -20,12 +19,22 @@ if ERRORLEVEL 1 (
echo [INFO]
echo [INFO] Install Hugo Theme
set HUGO_THEMES=themes\hugo-material-docs
set CSS_FILE=themes\hugo-material-docs\static\stylesheets\application.css

if not exist %HUGO_THEMES%\ (
git submodule add --force https://github.com/digitalcraftsman/hugo-material-docs.git %HUGO_THEMES%
echo [INFO] ... done
) else echo [INFO] ... theme already installed in: %HUGO_THEMES%

rem This script uses 'awk' to replace 1200px with 1500px in the application.css file from 'hugo'
if exist %CSS_FILE% (
then
powershell -Command "(gc %CSS_FILE%) -replace 'max-width:1200px', 'max-width:1500px' | Out-File -encoding ASCII %CSS_FILE%"
echo [INFO] CSS updated content successfully!
else
echo [WARN] CSS file not found!
fi

echo [INFO]
echo [INFO] Launch the documentation locally by running 'mvn site' (or 'hugo server' in the docs directory),
echo [INFO] and browse to 'http://localhost:{port}/hawkbit/'.
9 changes: 4 additions & 5 deletions docs/install-theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ else
echo "[INFO] ... theme already installed in: ${HUGO_THEMES}"
fi

# This script uses 'awk' to replace 1200px with 1500px in the application.css file from 'hugo'
# This script uses 'awk' to replace 1200px with 1500px in the application.css file from 'hugo'
if [ -f ${CSS_FILE} ]
then
awk '{gsub(/max-width:1200px/, "max-width:1500px"); print}' "${CSS_FILE}" > tmp && mv tmp "${CSS_FILE}"
echo "[INFO] Updated CSS content successfully!"
awk '{gsub(/max-width:1200px/, "max-width:1500px"); print}' "${CSS_FILE}" > tmp_hawkbit_doc && mv tmp_hawkbit_doc "${CSS_FILE}"
echo "[INFO] CSS updated content successfully!"
else
echo "[ERROR] CSS file not found!"
echo "[WARN] CSS file not found!"
fi


echo "[INFO] "
echo "[INFO] Launch the documentation locally by running 'mvn site' (or 'hugo server' in the docs directory),"
echo "[INFO] and browse to 'http://localhost:1313/hawkbit/'. "

0 comments on commit 499dab3

Please sign in to comment.