Skip to content

Commit 4c0ffb6

Browse files
Working on documentation
1 parent c2201c5 commit 4c0ffb6

5 files changed

Lines changed: 106 additions & 32 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enable_testing()
3131
option(RP3D_COMPILE_TESTBED "Select this if you want to build the testbed application with demos" OFF)
3232
option(RP3D_COMPILE_TESTS "Select this if you want to build the unit tests" OFF)
3333
option(RP3D_PROFILING_ENABLED "Select this if you want to compile for performanace profiling" OFF)
34+
option(RP3D_GENERATE_DOCUMENTATION "Select this if you want to generate the project documentation" OFF)
3435
option(RP3D_CODE_COVERAGE_ENABLED "Select this if you need to build for code coverage calculation" OFF)
3536
option(RP3D_DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating values" OFF)
3637

@@ -274,6 +275,11 @@ if(RP3D_COMPILE_TESTS)
274275
add_subdirectory(test/)
275276
endif()
276277

278+
# Documentation generation
279+
if(RP3D_GENERATE_DOCUMENTATION)
280+
add_subdirectory(documentation/)
281+
endif()
282+
277283
# Enable profiling if necessary
278284
if(RP3D_PROFILING_ENABLED)
279285
target_compile_definitions(reactphysics3d PUBLIC IS_RP3D_PROFILING_ENABLED)

documentation/CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
# ---------- DOXYGEN ---------- #
3+
4+
# Find the installed doxygen executable
5+
find_package(Doxygen REQUIRED)
6+
7+
# Set variables
8+
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
9+
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
10+
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in)
11+
set(DOXYFILE_OUT ${DOXYGEN_OUTPUT_DIR}/Doxyfile)
12+
13+
# Replace variables inside @@ with the current values in the Doxyfile.in and export to Doxyfile
14+
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
15+
16+
# Create the Doxygen output directory
17+
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
18+
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
19+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
20+
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
21+
COMMENT "Generating documentation with Doxygen")
22+
23+
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
24+
25+
# ---------- SPHINX ---------- #
26+
27+
find_package(Sphinx REQUIRED)
28+
29+
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source)
30+
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
31+
set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)
32+
33+
add_custom_command(OUTPUT ${SPHINX_INDEX_FILE}
34+
COMMAND
35+
${SPHINX_EXECUTABLE} -b html
36+
# Tell Breathe where to find the Doxygen output
37+
-Dbreathe_projects.ReactPhysics3D=${DOXYGEN_OUTPUT_DIR}/xml
38+
${SPHINX_SOURCE} ${SPHINX_BUILD}
39+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
40+
DEPENDS
41+
# Other docs files you want to track should go here (or in some variable)
42+
${SPHINX_SOURCE}/index.rst
43+
${DOXYGEN_INDEX_FILE}
44+
MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py
45+
COMMENT "Generating documentation with Sphinx")
46+
47+
# Sphinx target
48+
add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE})

documentation/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
This file describes how the documentation of the project is generated.
3+
4+
Reference: https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake
5+
6+
# Dependencies
7+
8+
- Doxygen
9+
- Sphinx
10+
- Breathe (bridge between Doxygen and Sphinx)
11+
- CMake
12+
13+
# How to generate the documentation
14+
15+
Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ PROJECT_LOGO = "ReactPhysics3DLogo.png"
5858
# entered, it will be relative to the location where doxygen was started. If
5959
# left blank the current directory will be used.
6060

61-
OUTPUT_DIRECTORY =
61+
OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@"
6262

6363
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
6464
# directories (in 2 levels) under the output directory of each output format and
@@ -230,12 +230,6 @@ TAB_SIZE = 4
230230

231231
ALIASES =
232232

233-
# This tag can be used to specify a number of word-keyword mappings (TCL only).
234-
# A mapping has the form "name=value". For example adding "class=itcl::class"
235-
# will allow you to use the command class in the itcl::class meaning.
236-
237-
TCL_SUBST =
238-
239233
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
240234
# only. Doxygen will then generate output that is more tailored for C. For
241235
# instance, some of the names that are used will be different. The list of all
@@ -780,7 +774,7 @@ WARN_LOGFILE =
780774
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
781775
# Note: If this tag is empty the current directory is searched.
782776

783-
INPUT = "../../src/" "../../include/reactphysics3d/"
777+
INPUT = @PROJECT_SOURCE_DIR@/"src/" @PROJECT_SOURCE_DIR@/"include/reactphysics3d/"
784778

785779
# This tag can be used to specify the character encoding of the source files
786780
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1048,13 +1042,6 @@ CLANG_OPTIONS =
10481042

10491043
ALPHABETICAL_INDEX = YES
10501044

1051-
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
1052-
# which the alphabetical index list will be split.
1053-
# Minimum value: 1, maximum value: 20, default value: 5.
1054-
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
1055-
1056-
COLS_IN_ALPHA_INDEX = 5
1057-
10581045
# In case all classes in a project start with a common prefix, all classes will
10591046
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
10601047
# can be used to specify a prefix (or a list of prefixes) that should be ignored
@@ -1070,7 +1057,7 @@ IGNORE_PREFIX =
10701057
# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
10711058
# The default value is: YES.
10721059

1073-
GENERATE_HTML = YES
1060+
GENERATE_HTML = NO
10741061

10751062
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
10761063
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1894,7 +1881,7 @@ MAN_LINKS = NO
18941881
# captures the structure of the code including all documentation.
18951882
# The default value is: NO.
18961883

1897-
GENERATE_XML = NO
1884+
GENERATE_XML = YES
18981885

18991886
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
19001887
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -2114,12 +2101,6 @@ EXTERNAL_GROUPS = YES
21142101

21152102
EXTERNAL_PAGES = YES
21162103

2117-
# The PERL_PATH should be the absolute path and name of the perl script
2118-
# interpreter (i.e. the result of 'which perl').
2119-
# The default file (with absolute path) is: /usr/bin/perl.
2120-
2121-
PERL_PATH = /usr/bin/perl
2122-
21232104
#---------------------------------------------------------------------------
21242105
# Configuration options related to the dot tool
21252106
#---------------------------------------------------------------------------
@@ -2133,15 +2114,6 @@ PERL_PATH = /usr/bin/perl
21332114

21342115
CLASS_DIAGRAMS = YES
21352116

2136-
# You can define message sequence charts within doxygen comments using the \msc
2137-
# command. Doxygen will then run the mscgen tool (see:
2138-
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
2139-
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
2140-
# the mscgen tool resides. If left empty the tool is assumed to be found in the
2141-
# default search path.
2142-
2143-
MSCGEN_PATH =
2144-
21452117
# You can include diagrams made with dia in doxygen documentation. Doxygen will
21462118
# then run dia to produce the diagram and insert it in the documentation. The
21472119
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = 'ReactPhysics3D'
10+
copyright = '2024, Daniel Chappuis'
11+
author = 'Daniel Chappuis'
12+
release = 'v0.10.0'
13+
14+
# -- General configuration ---------------------------------------------------
15+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16+
17+
extensions = ["breathe"]
18+
19+
templates_path = ['_templates']
20+
exclude_patterns = []
21+
22+
23+
24+
# -- Options for HTML output -------------------------------------------------
25+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
26+
27+
html_theme = 'sphinx_rtd_theme'
28+
html_static_path = ['_static']
29+
30+
# Breathe Configuration
31+
breathe_default_project = "ReactPhysics3D"
32+
33+
highlight_language = 'c++'

0 commit comments

Comments
 (0)