From b4895411c1c056cb68606cd881d010b69eac7e0e Mon Sep 17 00:00:00 2001 From: Foucher Alexandre Date: Mon, 22 Jan 2024 18:12:01 +0100 Subject: [PATCH] initial commit --- cpp-example/.gitignore | 6 ++++ cpp-example/CMakeLists.txt | 12 +++++++ cpp-example/docs/.gitignore | 1 + cpp-example/docs/Doxyfile.in | 10 ++++++ cpp-example/docs/Makefile | 22 ++++++++++++ cpp-example/docs/conf.py | 12 +++++++ cpp-example/docs/cpp-reference/driver.h.rst | 9 +++++ cpp-example/docs/cpp-reference/index.rst | 13 ++++++++ cpp-example/docs/index.rst | 21 ++++++++++++ cpp-example/docs/make.bat | 37 +++++++++++++++++++++ cpp-example/include/driver.h | 12 +++++++ cpp-example/readme.md | 19 +++++++++++ cpp-example/src/driver.cpp | 6 ++++ cpp-example/src/main.cpp | 9 +++++ 14 files changed, 189 insertions(+) create mode 100644 cpp-example/.gitignore create mode 100644 cpp-example/CMakeLists.txt create mode 100644 cpp-example/docs/.gitignore create mode 100644 cpp-example/docs/Doxyfile.in create mode 100644 cpp-example/docs/Makefile create mode 100644 cpp-example/docs/conf.py create mode 100644 cpp-example/docs/cpp-reference/driver.h.rst create mode 100644 cpp-example/docs/cpp-reference/index.rst create mode 100644 cpp-example/docs/index.rst create mode 100755 cpp-example/docs/make.bat create mode 100644 cpp-example/include/driver.h create mode 100644 cpp-example/readme.md create mode 100644 cpp-example/src/driver.cpp create mode 100644 cpp-example/src/main.cpp diff --git a/cpp-example/.gitignore b/cpp-example/.gitignore new file mode 100644 index 0000000..ef80f16 --- /dev/null +++ b/cpp-example/.gitignore @@ -0,0 +1,6 @@ +CMakeFiles/ +*.cmake +CMakeCache.txt +/Makefile + +/my_project \ No newline at end of file diff --git a/cpp-example/CMakeLists.txt b/cpp-example/CMakeLists.txt new file mode 100644 index 0000000..72bba98 --- /dev/null +++ b/cpp-example/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.0.0) +project(my_project VERSION 0.1.0 LANGUAGES C CXX) + +add_compile_options(-std=c++17) + +file(GLOB_RECURSE SRC_FILES + ${PROJECT_SOURCE_DIR}/src/*.cpp + ${PROJECT_SOURCE_DIR}/include/*.h +) + +include_directories(${PROJECT_SOURCE_DIR}/include()) +add_executable(my_project ${SRC_FILES}) \ No newline at end of file diff --git a/cpp-example/docs/.gitignore b/cpp-example/docs/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/cpp-example/docs/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/cpp-example/docs/Doxyfile.in b/cpp-example/docs/Doxyfile.in new file mode 100644 index 0000000..e6d6f27 --- /dev/null +++ b/cpp-example/docs/Doxyfile.in @@ -0,0 +1,10 @@ +# Doxyfile 1.8.17 + +PROJECT_NAME = "my_project" +INPUT = ../include +INPUT_ENCODING = UTF-8 +RECURSIVE = YES +GENERATE_XML = YES +XML_OUTPUT = build/doxyxml +GENERATE_LATEX = NO +GENERATE_HTML = NO \ No newline at end of file diff --git a/cpp-example/docs/Makefile b/cpp-example/docs/Makefile new file mode 100644 index 0000000..9ba79d3 --- /dev/null +++ b/cpp-example/docs/Makefile @@ -0,0 +1,22 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +# help: +# @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @mkdir -p build + @doxygen ./Doxyfile.in + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/cpp-example/docs/conf.py b/cpp-example/docs/conf.py new file mode 100644 index 0000000..1cee903 --- /dev/null +++ b/cpp-example/docs/conf.py @@ -0,0 +1,12 @@ +from cgitb import html + +extensions = ["breathe"] + +html_theme = "shibuya" + +html_theme_options = { + "globaltoc_expand_depth": 1, +} + +breathe_projects = {"my_project": "build/doxyxml/"} +breathe_default_project = "my_project" \ No newline at end of file diff --git a/cpp-example/docs/cpp-reference/driver.h.rst b/cpp-example/docs/cpp-reference/driver.h.rst new file mode 100644 index 0000000..1c2001d --- /dev/null +++ b/cpp-example/docs/cpp-reference/driver.h.rst @@ -0,0 +1,9 @@ +driver.h +======== + +.. + doxygenfile:: driver.h + +.. doxygenfunction:: add + :project: my_project + :sections: parameters diff --git a/cpp-example/docs/cpp-reference/index.rst b/cpp-example/docs/cpp-reference/index.rst new file mode 100644 index 0000000..7fe855c --- /dev/null +++ b/cpp-example/docs/cpp-reference/index.rst @@ -0,0 +1,13 @@ +Reference +========= + +ROS est un méta-système d'exploitation à code source ouvert pour votre robot. Il fournit les services que vous attendez d'un système d'exploitation, notamment l'abstraction matérielle, le contrôle des périphériques de bas niveau, la mise en œuvre des fonctionnalités les plus courantes, le passage de messages entre les processus et la gestion des paquets. + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + driver.h + +Lancement +--------- \ No newline at end of file diff --git a/cpp-example/docs/index.rst b/cpp-example/docs/index.rst new file mode 100644 index 0000000..7e3d0d3 --- /dev/null +++ b/cpp-example/docs/index.rst @@ -0,0 +1,21 @@ +.. test documentation master file, created by + sphinx-quickstart on Fri Jan 19 17:24:42 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to test's documentation! +================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + cpp-reference/index + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/cpp-example/docs/make.bat b/cpp-example/docs/make.bat new file mode 100755 index 0000000..c556664 --- /dev/null +++ b/cpp-example/docs/make.bat @@ -0,0 +1,37 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +mkdir build 2>nul +doxygen ./Doxyfile.in +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/cpp-example/include/driver.h b/cpp-example/include/driver.h new file mode 100644 index 0000000..d5b17de --- /dev/null +++ b/cpp-example/include/driver.h @@ -0,0 +1,12 @@ +/** + * @file driver.h + */ + +/** @brief function short description + * + * function longer description if need + * @param[in] x description of parameter1 + * @param[in] y description of parameter2 + * @return return_name return description + */ +int add(int x, int y); \ No newline at end of file diff --git a/cpp-example/readme.md b/cpp-example/readme.md new file mode 100644 index 0000000..f920af1 --- /dev/null +++ b/cpp-example/readme.md @@ -0,0 +1,19 @@ +
+ +# Sphinx documentation for C / C++ + +
+ +## :wrench: Dependencies installation + +```sh +pip3 install sphinx breathe +sudo apt-get install doxygen +``` + +## :rocket: Compile documentation + +```sh +cd docs +make html +``` \ No newline at end of file diff --git a/cpp-example/src/driver.cpp b/cpp-example/src/driver.cpp new file mode 100644 index 0000000..8fdf02b --- /dev/null +++ b/cpp-example/src/driver.cpp @@ -0,0 +1,6 @@ +#include "driver.h" + +int add(int x, int y) +{ + return x + y; +} \ No newline at end of file diff --git a/cpp-example/src/main.cpp b/cpp-example/src/main.cpp new file mode 100644 index 0000000..435aa6c --- /dev/null +++ b/cpp-example/src/main.cpp @@ -0,0 +1,9 @@ +#include + +#include "driver.h" + +int main(int argc, char* argv[]) +{ + std::cout << "Hello, world!"; + return 0; +} \ No newline at end of file