-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from benoitdenkinger/doc_update
HAL C++ implementation and documentation update
- Loading branch information
Showing
55 changed files
with
28,787 additions
and
11,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
cmake_minimum_required(VERSION 3.25) | ||
|
||
project(PeakRDL-halcpp-Documentation | ||
VERSION 0.4.0 | ||
) | ||
|
||
# This is needed to create the python venv for CMinx | ||
include("deps/deps.cmake") | ||
|
||
find_program( | ||
SPHINX_APIDOC | ||
NAMES sphinx-apidoc | ||
HINTS ${Python3_VIRTUAL_ENV}/bin | ||
REQUIRED | ||
) | ||
# This prints a message saying the executables are found | ||
include(FindPackageHandleStandardArgs) | ||
# find_package_handle_standard_args(Sphinx-build DEFAULT_MSG SPHINX_BUILD) | ||
find_package_handle_standard_args(Sphinx-apidoc DEFAULT_MSG SPHINX_APIDOC) | ||
|
||
|
||
# Create the API documentation target | ||
set(API_DOC_INPUT_DIR "${PROJECT_SOURCE_DIR}/../src/") | ||
set(API_SPHINX_SRC_DIR "${PROJECT_BINARY_DIR}/api/sphinx_docs/") | ||
set(API_SPHINX_BUILD_DIR "${API_SPHINX_SRC_DIR}/_build/") | ||
# Default location in conf.py | ||
set(SPHINX_TMPL_DIR "${API_SPHINX_SRC_DIR}/_templates/") | ||
|
||
# Sphinx is used to convert PeakRDL-halcpp method comments into rST format later transformed to a | ||
# static html documentation using again sphinx | ||
set(API_DOC_RST_CMD ${SPHINX_APIDOC} --full --module-first -a -H ${PROJECT_NAME} -A CERN -R ${PROJECT_VERSION} --templatedir=${SPHINX_TMPL_DIR} -o ${API_SPHINX_SRC_DIR} ${API_DOC_INPUT_DIR}) | ||
# This command trigger the rST to html conversion (internally using sphinx-build command) | ||
set(API_DOC_HTML_CMD make -C ${API_SPHINX_SRC_DIR} html) | ||
# This file creates an automatic triggering for the documentation update | ||
set(API_INDEX_HTML_FILE "${API_SPHINX_BUILD_DIR}/html/index.html") | ||
|
||
add_custom_command( | ||
OUTPUT ${API_SPHINX_SRC_DIR} | ||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${API_SPHINX_SRC_DIR}" | ||
COMMENT "Create documentation output directory." | ||
) | ||
|
||
add_custom_command( | ||
OUTPUT ${API_INDEX_HTML_FILE} | ||
COMMAND ${API_DOC_RST_CMD} | ||
COMMAND ${API_DOC_HTML_CMD} | ||
DEPENDS ${API_SPHINX_SRC_DIR} | ||
COMMENT "Generating the PeakRDL-halcpp API rST documentation." | ||
) | ||
# This will trigger the above command through the dependency | ||
add_custom_target( | ||
api_doc | ||
DEPENDS ${API_INDEX_HTML_FILE} | ||
) | ||
|
||
# Generated files based on cmake configuration/template file (.in files) | ||
# Only @MY_VAR@ format is replaced to avoid replacing structure like ${MY_VAR} which are used in other | ||
# languages or file format (e.g., in Makefiles). | ||
configure_file(${PROJECT_SOURCE_DIR}/sphinx_config/conf.py.in ${SPHINX_TMPL_DIR}/conf.py_t @ONLY) | ||
|
||
# This template is not used by sphinx-apidoc for unknwown reason so it is also copied directly to | ||
# the source file. No change is expected from sphinx-apidoc as cmake already takes care of this. | ||
configure_file(${PROJECT_SOURCE_DIR}/sphinx_config/Makefile.in ${SPHINX_TMPL_DIR}/Makefile_t @ONLY) | ||
configure_file(${PROJECT_SOURCE_DIR}/sphinx_config/Makefile.in ${API_SPHINX_SRC_DIR}/Makefile @ONLY) | ||
|
||
# Now build the docusaurus documentation using npm | ||
find_program(NPM_EXECUTABLE npm) | ||
find_package_handle_standard_args(npm DEFAULT_MSG NPM_EXECUTABLE) | ||
|
||
set(DOCUSAURUS_OUT_DIR ${PROJECT_BINARY_DIR}/docusaurus) | ||
file(MAKE_DIRECTORY ${DOCUSAURUS_OUT_DIR}) | ||
set(DOCUSAURUS_STAMP_FILE ${DOCUSAURUS_OUT_DIR}/stamp.stamp) | ||
add_custom_command( | ||
OUTPUT ${DOCUSAURUS_STAMP_FILE} | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
COMMAND touch ${DOCUSAURUS_STAMP_FILE} | ||
COMMAND ${NPM_EXECUTABLE} install docusaurus | ||
COMMAND ${NPM_EXECUTABLE} run build ${PROJECT_SOURCE_DIR} -- --out-dir ${DOCUSAURUS_OUT_DIR} | ||
COMMAND cp -r ${API_SPHINX_BUILD_DIR}/html ${DOCUSAURUS_OUT_DIR}/api_html | ||
# API static html is copied and added as a simple link (didn't find a nicer solution yet) | ||
DEPENDS api_doc | ||
COMMENT "Installing and Building Docusaurus" | ||
) | ||
add_custom_target(docusaurus_doc | ||
DEPENDS ${DOCUSAURUS_STAMP_FILE} | ||
COMMENT "Installing and Building Docusaurus" | ||
) | ||
|
||
add_custom_target(docusaurus_start | ||
DEPENDS docusaurus_doc | ||
COMMAND ${NPM_EXECUTABLE} run serve ${PROJECT_SOURCE_DIR} -- --dir ${DOCUSAURUS_OUT_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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 = source | ||
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 | ||
|
||
# Generate the html static documention with sphinx from the rST files generated with cminx and copy | ||
# them to the static folder used by docusaurus. | ||
html_api: html | ||
cp -r build/html/* ../static/api_html/ | ||
.PHONY: html_api | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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 = @DOC_OUTPUT_DIR@ | ||
BUILDDIR = @HTML_SPHINX_OUTPUT_DIR@ | ||
|
||
# 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 | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath(os.path.join('..', '..', 'src'))) | ||
print(os.path.abspath(os.path.join('..', '..', 'src'))) | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'PeakRDL-halcpp' | ||
copyright = '2024, CERN' | ||
author = 'CERN' | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = '@PROJECT_VERSION@' | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.viewcode', | ||
'sphinx.ext.napoleon', | ||
'sphinx.ext.graphviz', | ||
'sphinx.ext.inheritance_diagram', | ||
] | ||
|
||
inheritance_node_attrs = dict( | ||
color='"#6AB0DE"', | ||
fillcolor='"#E7F2FA"', | ||
style='"rounded, filled"' | ||
) | ||
|
||
inheritance_graph_attrs = dict(rankdir="TB") | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = [ | ||
# 'include', | ||
# 'templates' | ||
] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = 'sphinx_rtd_theme' | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# Options for the virtual env creation | ||
option(UPDATE_PYTHON_DEPS "Force update dependencies" OFF) | ||
option(DEPS_USE_VENV "Create a Python virtual environment and install dependencies locally" ON) | ||
option(UPDATE_DEPS "Update all of the dependencies, CPM packages and Python" OFF) | ||
# This script creates the virtual env if it is not existing | ||
include("${CMAKE_CURRENT_LIST_DIR}/venv.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sphinx==7.2.6 | ||
sphinx-rtd-theme==2.0.0 | ||
systemrdl-compiler==1.27.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
if(DEPS_USE_VENV) | ||
# Create the python virtual environment if not already done | ||
# Set an environment variable as activating a virtual env would do | ||
set(ENV{VIRTUAL_ENV} "${CMAKE_CURRENT_LIST_DIR}/_deps/venv") | ||
# The previous coommand tricks find_package() to look for a python interpreter under the | ||
# VIRUTAL_ENV path. Note that if the venv is deleted, the Python3_EXECUTABLE is still cached so it | ||
# generates an error (in this case delete the CMakeCache.txt) | ||
find_package(Python3 COMPONENTS Interpreter) | ||
# Check if the virtual env path is inside the found python3 executable | ||
string(FIND "${Python3_EXECUTABLE}" $ENV{VIRTUAL_ENV}/bin/python IN_VENV) | ||
if(NOT IN_VENV EQUAL 0) | ||
# If no venv exist, create one | ||
execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${CMAKE_CURRENT_LIST_DIR}/_deps/venv") | ||
# The virtual environment is used before any other standard paths to look-up for the interpreter | ||
set(Python3_FIND_VIRTUALENV FIRST) | ||
# Remove the python executable to search for the venv one | ||
unset(Python3_EXECUTABLE) | ||
find_package (Python3 COMPONENTS Interpreter) | ||
# For the update of the deps for a newly created venv | ||
set(__UPDATE_PYTHON_DEPS TRUE) | ||
endif() | ||
|
||
# Cache the string for simpler access (this causes the problem above, so maybe it is not the best) | ||
set(Python3_EXECUTABLE ${Python3_EXECUTABLE} CACHE STRING "Python3_EXECUTABLE") | ||
# Cache the virtual env path to use package more easily | ||
set(Python3_VIRTUAL_ENV $ENV{VIRTUAL_ENV} CACHE STRING "Python3_VIRTUAL_ENV") | ||
|
||
# If requested by the user or the script, update the deps | ||
if((NOT DEFINED UPDATE_PYTHON_DEPS) OR UPDATE_PYTHON_DEPS OR __UPDATE_PYTHON_DEPS OR UPDATE_DEPS) | ||
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade pip) | ||
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install -r ${CMAKE_CURRENT_LIST_DIR}/requirements.txt) | ||
# Disable and unset the triggering variables otherwise it will always be executed | ||
set(UPDATE_PYTHON_DEPS OFF CACHE STRING "Force update python dependencies") | ||
# Is this really needed? | ||
unset(__UPDATE_PYTHON_DEPS) | ||
endif() | ||
else() | ||
# Use the global python installation | ||
find_package (Python3 COMPONENTS Interpreter) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# API documentation | ||
|
||
*LINK TO BE ADDED* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.