Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 30e5f5a

Browse files
Add docs for CoreNEURON (#359)
Similar to NMODL, add documentation for CoreNEURON with doxygen and Sphinx.
1 parent f0acbda commit 30e5f5a

File tree

14 files changed

+2990
-15
lines changed

14 files changed

+2990
-15
lines changed

.travis.yml

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ matrix:
1717
dist: xenial
1818
env:
1919
- cmake_option="-DCORENRN_ENABLE_MPI=ON"
20+
- BUILD_DOCUMENTATION=ON
2021
- os: linux
2122
dist: xenial
2223
env:
@@ -84,6 +85,7 @@ addons:
8485
sources:
8586
- ubuntu-toolchain-r-test
8687
packages:
88+
- doxygen
8789
- bison
8890
- flex
8991
- libboost-all-dev
@@ -105,6 +107,15 @@ addons:
105107
# Set up environments
106108
#=============================================================================
107109
before_install:
110+
# quickly return if this is a docs-only PR
111+
- |
112+
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
113+
if ! git diff --name-only ${TRAVIS_COMMIT_RANGE} | grep -qvE '(\.md)$|(\.txt)$|^(docs/)' ; then
114+
echo "Skipping CI build since we have docs-only changes for ${TRAVIS_COMMIT_RANGE} :"
115+
git diff --name-only ${TRAVIS_COMMIT_RANGE}
116+
exit
117+
fi
118+
fi
108119
# brew installed flex and bison is not in $PATH
109120
# unlink python2 and use python3 as it's required for nmodl
110121
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
@@ -114,27 +125,36 @@ before_install:
114125
else
115126
pyenv global $PYTHON_VERSION;
116127
fi
117-
# install NMODL dependencies
118-
- if [[ "$USE_NMODL" == "ON" || "$USE_ISPC" == "ON" ]]; then
119-
pip3 install jinja2 pyyaml pytest "sympy<1.6";
120-
fi
121128
- if [ -n "$GCC_VERSION" ]; then
122129
export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}";
123130
$CXX --version;
124131
fi
132+
133+
install:
125134
# install ISPC compiler (only for mac or linux build for now)
126135
- if [[ "$USE_ISPC" == "ON" ]]; then
127-
ispc_version="v1.12.0";
128-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
129-
url_os="linux";
130-
ispc_version_suffix="b";
131-
else
132-
url_os="macOS";
133-
ispc_version_suffix="";
134-
fi;
135-
url="https://github.com/ispc/ispc/releases/download/${ispc_version}/ispc-${ispc_version}${ispc_version_suffix}-${url_os}.tar.gz";
136-
wget -O ispc.tar.gz $url;
137-
mkdir ispc && tar -xvzf ispc.tar.gz -C ispc --strip 1;
136+
ispc_version="v1.12.0";
137+
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
138+
url_os="linux";
139+
ispc_version_suffix="b";
140+
else
141+
url_os="macOS";
142+
ispc_version_suffix="";
143+
fi;
144+
url="https://github.com/ispc/ispc/releases/download/${ispc_version}/ispc-${ispc_version}${ispc_version_suffix}-${url_os}.tar.gz";
145+
wget -O ispc.tar.gz $url;
146+
mkdir ispc && tar -xvzf ispc.tar.gz -C ispc --strip 1;
147+
fi
148+
149+
# install NMODL dependencies
150+
- if [[ "$USE_NMODL" == "ON" || "$USE_ISPC" == "ON" ]]; then
151+
pip3 install --upgrade pip;
152+
pip3 install jinja2 pyyaml pytest "sympy<1.6";
153+
fi
154+
# install documentation dependencies
155+
- if [ "$BUILD_DOCUMENTATION" = "ON" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
156+
pip3 install --upgrade pip;
157+
pip3 install --user -r docs/docs_requirements.txt --upgrade;
138158
fi
139159
#=============================================================================
140160
# Build, test and install
@@ -154,3 +174,32 @@ script:
154174
- cmake --build .
155175
- ctest --output-on-failure
156176
- make install
177+
178+
179+
#=============================================================================
180+
# Prepare Documentation
181+
#=============================================================================
182+
after_success:
183+
- if [ "$BUILD_DOCUMENTATION" = "ON" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
184+
echo "------- Build Doxygen Documentation -------";
185+
pushd $TRAVIS_BUILD_DIR/build;
186+
make docs;
187+
echo "-------- Disable jekyll --------";
188+
pushd $TRAVIS_BUILD_DIR/build/docs;
189+
touch .nojekyll;
190+
fi
191+
192+
193+
#=============================================================================
194+
# Documentation deployment
195+
#=============================================================================
196+
deploy:
197+
provider: pages
198+
skip_cleanup: true
199+
github_token: $GITHUB_TOKEN
200+
keep_history: false
201+
local_dir: $TRAVIS_BUILD_DIR/build/docs
202+
target_branch: gh-pages
203+
on:
204+
branch: master
205+
condition: $BUILD_DOCUMENTATION = ON && $TRAVIS_OS_NAME = linux

CMake/packages/FindSphinx.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
find_program(SPHINX_EXECUTABLE
2+
NAMES sphinx-build
3+
DOC "/path/to/sphinx-build")
4+
5+
include(FindPackageHandleStandardArgs)
6+
7+
find_package_handle_standard_args(Sphinx
8+
"Failed to find sphinx-build executable"
9+
SPHINX_EXECUTABLE)

CMakeLists.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,59 @@ else()
278278
endif()
279279

280280

281+
# =============================================================================
282+
# Setup Doxygen documentation
283+
# =============================================================================
284+
find_package(Doxygen QUIET)
285+
if(DOXYGEN_FOUND)
286+
# generate Doxyfile with correct source paths
287+
configure_file(${PROJECT_SOURCE_DIR}/docs/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile)
288+
add_custom_target(
289+
doxygen
290+
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
291+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
292+
COMMENT "Generating API documentation with Doxygen"
293+
VERBATIM)
294+
endif()
295+
296+
# =============================================================================
297+
# Setup Sphinx documentation
298+
# =============================================================================
299+
find_package(Sphinx QUIET)
300+
if(SPHINX_FOUND)
301+
set(SPHINX_SOURCE ${PROJECT_SOURCE_DIR}/docs)
302+
set(SPHINX_BUILD ${PROJECT_BINARY_DIR}/docs/)
303+
304+
add_custom_target(
305+
sphinx
306+
COMMAND ${SPHINX_EXECUTABLE} -b html
307+
${SPHINX_SOURCE} ${SPHINX_BUILD}
308+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
309+
COMMENT "Generating documentation with Sphinx"
310+
)
311+
endif()
312+
313+
# =============================================================================
314+
# Build full docs
315+
# =============================================================================
316+
if(DOXYGEN_FOUND AND SPHINX_FOUND)
317+
add_custom_target(
318+
docs
319+
COMMAND make doxygen
320+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
321+
COMMAND make sphinx
322+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
323+
COMMENT "Generating full documentation"
324+
)
325+
else()
326+
add_custom_target(
327+
docs
328+
VERBATIM COMMAND echo "Please install docs requirements (see docs/README.md)!"
329+
COMMENT "Documentation generation not possible!"
330+
)
331+
endif()
332+
333+
281334
# =============================================================================
282335
# Build status
283336
# =============================================================================
@@ -291,6 +344,7 @@ if(cmake_generator_tolower MATCHES "makefile")
291344
message(STATUS "Command | Description")
292345
message(STATUS "--------------------+--------------------------------------------------------")
293346
message(STATUS "make install | Will install CoreNEURON to: ${CMAKE_INSTALL_PREFIX}")
347+
message(STATUS "make docs | Build full docs. Calls targets: doxygen, sphinx")
294348
message(STATUS "--------------------+--------------------------------------------------------")
295349
message(STATUS " Build option | Status")
296350
message(STATUS "--------------------+--------------------------------------------------------")

0 commit comments

Comments
 (0)