Skip to content

Commit

Permalink
Refactored the generation of the documentation
Browse files Browse the repository at this point in the history
It is now performed in an additional Travis stage and it uses a new CMake target that calls doxygen
  • Loading branch information
diegoferigo committed Aug 3, 2018
1 parent 4f917d8 commit e39c346
Show file tree
Hide file tree
Showing 9 changed files with 3,972 additions and 2,549 deletions.
103 changes: 0 additions & 103 deletions .ci/generateDocumentation.sh

This file was deleted.

26 changes: 0 additions & 26 deletions .ci/setup-ssh.sh

This file was deleted.

Binary file removed .ci/travis_deploy_key.enc
Binary file not shown.
76 changes: 76 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ os: linux
stages:
- test # Default stage with job matrix
- osx
- deploy

env:
global:
Expand Down Expand Up @@ -93,6 +94,49 @@ stage_osx:
- cd $TRAVIS_BUILD_DIR
- sh .ci/script.sh

# =============
# STAGE: deploy
# =============

stage_deploy:
script: &deploy_script
# Clone the gh-pages branch
- GH_PAGES_ROOTDIR=$HOME/gh-pages
- export GH_REPO_ORG=${TRAVIS_REPO_SLUG%*/*}
- export GH_REPO_NAME=${TRAVIS_REPO_SLUG#*/*}
- export GH_REPO_REF="github.com/$GH_REPO_ORG/$GH_REPO_NAME.git"
## Select the deploy folder
- DEPLOY_FOLDER=$GH_PAGES_ROOTDIR
#- if [ "$TRAVIS_BRANCH" = "master" ] ; then DEPLOY_FOLDER=$GH_PAGES_ROOTDIR ; fi
#- if [ "$TRAVIS_BRANCH" = "devel" ] ; then DEPLOY_FOLDER=$GH_PAGES_ROOTDIR/devel ; fi
# Check if the gh-pages branch exists and clone it
- cd $TRAVIS_BUILD_DIR
- git ls-remote --heads --exit-code https://$GH_REPO_REF gh-pages || travis_terminate 1
- git clone -b gh-pages https://$GH_REPO_REF $GH_PAGES_ROOTDIR
# Push only the current branch
- cd $GH_PAGES_ROOTDIR
- git config push.default simple
# Clean old documentation files
- rm -rf ${DEPLOY_FOLDER}/html
# Disable GitHub jekyll generation
- touch $GH_PAGES_ROOTDIR/.nojekyll
# Generate documentation
- cd $TRAVIS_BUILD_DIR
- mkdir build && cd build
- cmake .. -DBUILD_DOCS:BOOL=TRUE -DDOXYGEN_INSTALL_DIR=${DEPLOY_FOLDER}
- make dox || travis_terminate 1
- make install
# Deploy the folder
- cd $GH_PAGES_ROOTDIR
- git remote add origin-botlogin https://$GIT_COMMITTER_USERNAME:$DEPLOY_TOKEN@$GH_REPO_REF
- git add --all
- COMMIT_AUTHOR="$(git --no-pager show -s --format='%an <%ae>' $TRAVIS_COMMIT)"
- >-
git commit -m "Automatic docs deployment Travis#${TRAVIS_BUILD_NUMBER}" \
-m "Commit: https://github.com/$TRAVIS_REPO_SLUG/commit/$TRAVIS_COMMIT" \
--author "$COMMIT_AUTHOR"
- git push --force origin-botlogin gh-pages

# ======================
# BUILD JOBS FROM STAGES
# ======================
Expand Down Expand Up @@ -121,6 +165,38 @@ jobs:
env:
TRAVIS_CMAKE_GENERATOR="Unix Makefiles"
TRAVIS_BUILD_TYPE="Debug"
# ------------
# STAGE DEPLOY
# ------------
- &deploy_template
stage: deploy
compiler:
cache:
if: fork = false AND branch = "master" AND type != pull_request
before_install: skip
install: skip
install: skip
before_script: skip
script: *deploy_script
after_failure: skip
after_success: skip
after_script: skip
env:
GIT_COMMITTER_USERNAME=LOC2Bot
GIT_COMMITTER_NAME=LOC2Bot
[email protected]
DOXYGEN_INPUT_FOLDER=$TRAVIS_BUILD_DIR/build/doc/doxygen
MKDOCS_INPUT_FOLDER=$TRAVIS_BUILD_DIR/build/doc/mkdocs
addons:
apt:
packages:
- doxygen
- doxygen-doc
- doxygen-gui
- graphviz
- python3-pip
#- <<: *deploy_template
#if: fork = false AND branch = "devel" AND type != pull_request

# notifications:
# email:
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ project(HumanDynamicsEstimation CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(BUILD_DOCS)
add_subdirectory(doc)
return()
endif()

include(GNUInstallDirs)
include(CTest)

Expand Down
46 changes: 46 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Provide a local project and cmake_minimum_required calls
# to permit to generate the documentation without configuring
# the complete project

# This variable should contain the argument of the project call in the main CMakeLists.txt
set(ORIGINAL_PROJECT_NAME ${PROJECT_NAME})
set(ORIGINAL_PROJECT_VERSION ${PROJECT_VERSION})

project("${ORIGINAL_PROJECT_NAME} Docs")

include(GNUInstallDirs)

find_package(Doxygen QUIET)

if(DOXYGEN_FOUND)
set(DOXYGEN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}"
CACHE STRING "Build directory for Doxygen html output (absolute).")
set(DOXYGEN_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${ORIGINAL_PROJECT_NAME}"
CACHE STRING "Installation directory for Doxygen html output (relative to CMAKE_INSTALL_PREFIX).")

# This variables are used inside the Doxyfile.in template
set(DOXYGEN_PROJECT_BRIEF "Software repository for estimating human dynamics")
set(DOXYGEN_SOURCE_DIR "${CMAKE_HOME_DIRECTORY}")
set(DOXYGEN_DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(DOXYGEN_EXCLUDE_DIR "")

# Generate the doxygen configuration file used by the
# document generation. This step permits to use cmake variable
# such as @ORIGINAL_PROJECT_NAME@ in the Doxyfile.in template
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# Move other files required by doxygen in the build folder
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/customdoxygen.css ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)

# The dox target will generate the doxygen documentation in ${DOXYGEN_BUILD_DIR}
add_custom_target(dox COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMENT "Generating doxygen documentation in ${DOXYGEN_BUILD_DIR}")

# Note: the install will install the documentation if present,
# but it will not trigger a regeneration of the documentation if it is outdated
install(DIRECTORY ${DOXYGEN_BUILD_DIR}/html
DESTINATION ${DOXYGEN_INSTALL_DIR}
OPTIONAL)

endif()
Loading

0 comments on commit e39c346

Please sign in to comment.