Skip to content

Commit

Permalink
added doxygen api documentation step to build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsikalagaturu committed Nov 26, 2024
1 parent a9239bf commit 35d7511
Show file tree
Hide file tree
Showing 10 changed files with 2,810 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Formatting and Linting
name: Build, Format, and Lint CI

on:

pull_request:
branches:
- main
Expand All @@ -11,64 +10,55 @@ on:
- main

jobs:

setup-build-lint:

runs-on: ubuntu-latest

steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y check clang-format clang-tidy cmake
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y check clang-format clang-tidy cmake
- name: Set up workspace
run: |
# Create workspace structure
mkdir -p ws/src ws/build ws/install
- run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4
with:
path: ws/src/temp
path: "ws/src/${{ env.REPOSITORY_NAME }}/"

- name: Set up build
working-directory: ws
run: |
# Extract package name from CMakeLists.txt project() definition
PACKAGE_NAME=$(grep -m1 -Po 'project\(\K[^\)]+' src/temp/CMakeLists.txt)
echo PACKAGE_NAME=$PACKAGE_NAME >> $GITHUB_ENV
# create a directory for the package in src
mkdir -p src/$PACKAGE_NAME
# Move all files and directories in src to the package-specific directory
mv src/temp/{.[!.],}* src/$PACKAGE_NAME
# Remove the temporary directory
rm -rf src/temp
# Create build directory for the package
mkdir -p build/$PACKAGE_NAME
mkdir -p build/$REPOSITORY_NAME
# Navigate to the package-specific build directory
cd build/$PACKAGE_NAME
cd build/$REPOSITORY_NAME
- name: Configure and build
working-directory: ws/build/${{ env.REPOSITORY_NAME }}
run: |
# Configure with specified flags and set install prefix to install
cmake ../../src/$PACKAGE_NAME \
cmake ../../src/$REPOSITORY_NAME \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=../../install
# -DENABLE_DOC=ON \
# Install to the specified install directory
make install
# Build the package
cmake --build .
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Install python dependencies
run: |
Expand All @@ -86,11 +76,9 @@ jobs:
working-directory: ws
run: |
# cd to the package-specific directory
cd src/$PACKAGE_NAME
cd src/$REPOSITORY_NAME
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
# Run pre-commit checks
pre-commit run --show-diff-on-failure --color=always --all-files
19 changes: 18 additions & 1 deletion .github/workflows/mkdocs_ci_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
Expand All @@ -27,6 +29,21 @@ jobs:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- name: Install dependencies
run: |
apt-get update
apt-get install -y doxygen cmake
- name: Build API docs
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_DOC=ON
cmake --build . --target docs
mv docs/html ../docs/api_html
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "doxygen-awesome-css"]
path = doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
files: \.(c|h|cc)$
args:
- -p
- ../../build/PackageName/ # Replace 'build/' with your actual compilation database path (add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt)
- ../../build/c_cpp_pkg_template/ # Replace 'build/' with your actual compilation database path (add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt)
- -extra-arg=-isystem
- -extra-arg=../../install/include # Replace 'install/include' with your actual system include path

Expand All @@ -31,7 +31,7 @@ repos:
files: \.(cpp|hpp)$
args:
- -p
- ../../build/PackageName/ # Replace 'build/' with your actual compilation database path (add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt)
- ../../build/c_cpp_pkg_template/ # Replace 'build/' with your actual compilation database path (add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt)
- -extra-arg=-isystem
- -extra-arg=../../install/include # Replace 'install/include' with your actual system include path

Expand Down
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"browse": {
"databaseFilename": "${default}",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/opt/ros/jazzy/include/**",
"/home/batsy/c_cpp_pkg_template/include/**",
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14"
}
],
"version": 4
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ros.distro": "jazzy",
"python.autoComplete.extraPaths": [
"/opt/ros/jazzy/lib/python3.12/site-packages"
],
"python.analysis.extraPaths": [
"/opt/ros/jazzy/lib/python3.12/site-packages"
]
}
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include(GNUInstallDirs)

set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

option(ENABLE_DOC "Build documentation" Off)
option(ENABLE_TESTS "Build unit tests" Off)
option(ENABLE_PACKAGE_REGISTRY "Add this package to CMake's package registry" Off)

Expand All @@ -19,6 +20,49 @@ if(ENABLE_TESTS)
add_subdirectory(test)
endif()

if(ENABLE_DOC)
# Find Doxygen package
find_package(Doxygen REQUIRED)

# Set Doxygen variables
set(DOXYGEN_GENERATE_HTML YES) # Enable HTML documentation generation
set(DOXYGEN_GENERATE_XML NO) # Disable XML output (optional, depends on your needs)
set(DOXYGEN_EXCLUDE "test/*") # Optionally exclude test folders from documentation

# Set the paths for the input sources and the output directory
set(DOXYGEN_INPUT_DIR "${CMAKE_SOURCE_DIR}/src") # Path to source code directory
set(DOXYGEN_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include") # Path to include directory
set(DOXYGEN_README "${CMAKE_SOURCE_DIR}/README.md") # Path to README.md
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/docs") # Output directory for the docs
# set(HTML_EXTRA_STYLESHEET "${CMAKE_SOURCE_DIR}/docs/styles/doxy.css") # Path to custom CSS
# file

# Ensure that the output directory exists
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})

# Provide path to Doxygen config file
set(DOXYGEN_CONFIG_FILE "${CMAKE_SOURCE_DIR}/Doxyfile.in") # Path to your Doxygen configuration
# file

# Check if Doxygen configuration file exists
if(EXISTS "${DOXYGEN_CONFIG_FILE}")
message(STATUS "Doxygen config file found: ${DOXYGEN_CONFIG_FILE}")
else()
message(FATAL_ERROR "Doxygen config file not found!")
endif()

# Modify the Doxyfile variables in the CMakeLists.txt
configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)

# Add custom target to generate docs using Doxygen
add_custom_target(
docs
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif()

# Export this package to CMake's package registry
if(ENABLE_PACKAGE_REGISTRY)
export(PACKAGE ${PROJECT_NAME})
Expand Down
Loading

0 comments on commit 35d7511

Please sign in to comment.