Skip to content

Commit

Permalink
Merge pull request #53 from OleksandrKvl/OleksandrKvl/multi-versions-…
Browse files Browse the repository at this point in the history
…documentation
  • Loading branch information
OleksandrKvl authored May 7, 2024
2 parents f5c849a + be1a8f6 commit 9969753
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 2,881 deletions.
151 changes: 110 additions & 41 deletions .github/workflows/doxygen-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,123 @@
name: Doxygen
name: Documentation workflow

permissions:
contents: write

env:
BUILD_DIR: ${{github.workspace}}/build
SELECTOR_FILE_NAME: version_selector.html
SELECTOR_ID: versionSelector
GIT_USER_NAME: 'Oleksandr Koval'
GIT_USER_EMAIL: 'OleksandrKvl@users.noreply.github.com'

on:
# to update docs/git-main
push:
branches:
- main
pull_request:
branches:
- main
# to publish docs/<release-version>
release:
types: [released]

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
publish-docs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Install deps
run: |
sudo apt install -y cmake
sudo apt install -y wget
wget -nv https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz
tar -xzf doxygen-1.10.0.linux.bin.tar.gz
echo "$(pwd)/doxygen-1.10.0/bin" >> $GITHUB_PATH
- name: CMake configuration
run: |
cmake -B ${{github.workspace}}/build \
-D CMAKE_C_COMPILER=/usr/bin/gcc-11 \
-D CMAKE_CXX_COMPILER=/usr/bin/g++-11 \
-D SBEPP_BUILD_SBEPPC=OFF \
-D SBEPP_BUILD_DOCS=ON
- name: CMake build
run: |
cmake --build ${{github.workspace}}/build \
--target doc
- name: Moving Files
run: |
mv ${{github.workspace}}/build/doc/html ./doc/html
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/html
- uses: actions/checkout@v4

- name: Install deps
shell: bash
run: |
sudo apt install -y cmake
sudo apt install -y wget
wget -nv https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz
tar -xzf doxygen-1.10.0.linux.bin.tar.gz
echo "$(pwd)/doxygen-1.10.0/bin" >> $GITHUB_PATH
- name: CMake configure
run: cmake -B $BUILD_DIR

- name: CMake build
run: cmake --build $BUILD_DIR --target doc

- name: Get docs version
id: get-docs-version
run: |
subdir=$(basename $(find $BUILD_DIR/doc/docs -mindepth 1 -maxdepth 1 -type d | head -n 1))
echo "version=$subdir" >> $GITHUB_OUTPUT
- name: Update redirect HTML
if: github.event_name == 'release'
run: |
mkdir $BUILD_DIR/doc/docs/redirect
cat << EOF > $BUILD_DIR/doc/docs/redirect/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=${{ steps.get-docs-version.outputs.version }}/index.html">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="${{ steps.get-docs-version.outputs.version }}/index.html">click here</a>.</p>
</body>
</html>
EOF
- name: Deploy release docs
if: github.event_name == 'release'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.BUILD_DIR }}/doc/docs/${{ steps.get-docs-version.outputs.version }}
destination_dir: ${{ steps.get-docs-version.outputs.version }}

- name: Deploy redirect page
if: github.event_name == 'release'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.BUILD_DIR }}/doc/docs/redirect
keep_files: true

- name: Deploy git-main docs
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.BUILD_DIR }}/doc/docs/${{ steps.get-docs-version.outputs.version }}
destination_dir: git-main

# Update version_selector.html
- name: Pull gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Discover versions
run: |
# Enumerate directories and store them in a variable
dirs=$(find . -mindepth 1 -maxdepth 1 -type d | sort -rV)
# Create HTML
echo '<select id="$SELECTOR_ID">' > $SELECTOR_FILE_NAME
for dir in $dirs; do
if [[ "$(basename "$dir")" != .* ]]; then
version=$(basename "$dir")
echo " <option value=\"$version\">$version</option>" >> $SELECTOR_FILE_NAME
fi
done
echo '</select>' >> $SELECTOR_FILE_NAME

- name: Push selector
run: |
git config --global user.name $GIT_USER_NAME
git config --global user.email $GIT_USER_EMAIL
if [[ -n "$(git diff --exit-code $SELECTOR_FILE_NAME)" ]]; then
git add $SELECTOR_FILE_NAME
git commit -m "Update version selector"
git push origin gh-pages
else
echo "$SELECTOR_FILE_NAME has not been changed. Skipping push."
fi
54 changes: 52 additions & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
find_package(Doxygen REQUIRED)

configure_file(Doxyfile.in Doxyfile @ONLY)
set(doxygen_input
"${PROJECT_SOURCE_DIR}/sbepp"
"${PROJECT_SOURCE_DIR}/doc/overview.md"
"${PROJECT_SOURCE_DIR}/doc/installation.md"
"${PROJECT_SOURCE_DIR}/doc/sbeppc.md"
"${PROJECT_SOURCE_DIR}/doc/integration.md"
"${PROJECT_SOURCE_DIR}/doc/representation.md"
"${PROJECT_SOURCE_DIR}/doc/traits.md"
"${PROJECT_SOURCE_DIR}/doc/visit_api.md"
"${PROJECT_SOURCE_DIR}/doc/benchmarks.md"
"${PROJECT_SOURCE_DIR}/doc/examples.md"
"${PROJECT_SOURCE_DIR}/doc/stringification.md"
)

add_custom_target(doc Doxygen::doxygen Doxyfile)
set(DOXYGEN_STRIP_FROM_PATH "${PROJECT_SOURCE_DIR}/sbepp/src/sbepp")
set(DOXYGEN_HIDE_UNDOC_MEMBERS "YES")
set(DOXYGEN_HIDE_UNDOC_CLASSES "YES")
set(DOXYGEN_LAYOUT_FILE "DoxygenLayout.xml")
set(DOXYGEN_WARN_IF_UNDOCUMENTED "NO")
set(DOXYGEN_RECURSIVE "YES")
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "overview.md")
set(DOXYGEN_HTML_HEADER "header.html")
set(DOXYGEN_HTML_EXTRA_STYLESHEET "doxygen-awesome-css/doxygen-awesome.css")
set(DOXYGEN_HTML_EXTRA_FILES
"doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js"
"doxygen-awesome-css/doxygen-awesome-paragraph-link.js"
"doxygen-awesome-css/doxygen-awesome-interactive-toc.js"
"version_selector_handler.js"
)
set(DOXYGEN_HTML_COLORSTYLE "LIGHT")
set(DOXYGEN_GENERATE_TREEVIEW "YES")
set(DOXYGEN_FULL_SIDEBAR "YES")
set(DOXYGEN_MACRO_EXPANSION "YES")
set(DOXYGEN_EXPAND_ONLY_PREDEF "YES")
set(DOXYGEN_PREDEFINED
"SBEPP_DOXYGEN"
"SBEPP_CPP20_CONSTEXPR=constexpr"
"SBEPP_CPP14_CONSTEXPR=constexpr"
"SBEPP_HAS_INLINE_VARS=1"
"SBEPP_HAS_CONCEPTS=1"
"SBEPP_CPP17_INLINE_VAR=inline"
"SBEPP_CPP17_NODISCARD=[[nodiscard]]"
"SBEPP_DEPRECATED"
)
set(DOXYGEN_EXPAND_AS_DEFINED "SBEPP_BUILT_IN_IMPL")
set(DOXYGEN_WARN_AS_ERROR "FAIL_ON_WARNINGS_PRINT")
set(DOXYGEN_HTML_OUTPUT "${PROJECT_VERSION}")
set(DOXYGEN_OUTPUT_DIRECTORY "docs")

doxygen_add_docs(
doc
${doxygen_input}
)
Loading

0 comments on commit 9969753

Please sign in to comment.