Skip to content

Commit

Permalink
doc: centralize versioning
Browse files Browse the repository at this point in the history
Now that we have Doxygen docsets, it is important to centralize
versioning into a single place, also re-using information from version
files or variables if available to avoid duplicates.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
  • Loading branch information
gmarull committed Sep 30, 2024
1 parent f7cdbda commit 672fe15
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 22 deletions.
36 changes: 21 additions & 15 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR})
# Args:
# - name: Docset name.
# - sources: Sources.
# - version: Docset version.
# - STANDALONE: Use if docset is Doxygen-only, i.e., without Sphinx.
#
# Configured targets (if STANDALONE):
Expand All @@ -71,10 +72,11 @@ file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR})
# - ${name}-doxygen: Run Doxygen build.
# - ${name}-doxygen-clean: Clean build artifacts.
#
function(add_doxygen_docset name sources)
function(add_doxygen_docset name sources version)
cmake_parse_arguments(DOXYGEN "STANDALONE" "" "" ${ARGN})
set(DOCSET_BUILD_DIR ${CMAKE_BINARY_DIR}/html)
set(DOCSET_SOURCE_BASE ${sources})
set(DOCSET_VERSION ${version})

if(NOT DOXYGEN_STANDALONE)
set(SUFFIX "-doxygen")
Expand All @@ -101,6 +103,7 @@ endfunction()
#
# Args:
# - name: Docset name.
# - version: Docset version.
# - DODGY: Enable/disable "dodgy" mode. If enabled "-W" (warnings as errors)
# option will be disabled. It can be useful for external docsets that are
# likely to generate build warnings.
Expand All @@ -122,7 +125,7 @@ endfunction()
# - ${name}-linkcheck: Run Sphinx "linkcheck" target.
# - ${name}-clean: Clean build artifacts.
#
function(add_docset name)
function(add_docset name version)
cmake_parse_arguments(DOCSET "DODGY" "" "" ${ARGN})

set(DOCSET_CFG_DIR ${CMAKE_CURRENT_LIST_DIR}/${name})
Expand All @@ -132,7 +135,7 @@ function(add_docset name)
set(DOCSET_HTML_DIR ${CMAKE_BINARY_DIR}/html/${name})
set(DOCSET_MAKE_DIRS ${DOCSET_BUILD_DIR};${DOCSET_SRC_DIR};${DOCSET_HTML_DIR})
set(DOCSET_CLEAN_DIRS ${DOCSET_BUILD_DIR};${DOCSET_HTML_DIR})
set(DOCSET_ENV DOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE})
set(DOCSET_ENV DOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE};DOCSET_VERSION=${version})

if(${DOCSET_DODGY})
list(REMOVE_ITEM SPHINXOPTS "-W" "--keep-going")
Expand Down Expand Up @@ -292,55 +295,58 @@ add_custom_target(
COMMENT "Generating Devicetree bindings documentation..."
)

add_docset(zephyr)
add_doxygen_docset(zephyr ${ZEPHYR_BASE})
add_docset(zephyr ${Zephyr_VERSION})
add_doxygen_docset(zephyr ${ZEPHYR_BASE} ${Zephyr_VERSION})
add_dependencies(zephyr zephyr-devicetree)
add_dependencies(zephyr-all zephyr-devicetree)

#-------------------------------------------------------------------------------
# docset: nrf

add_docset(nrf)
add_doxygen_docset(nrf ${NRF_BASE})
file(READ "${NRF_BASE}/VERSION" NRF_VERSION)
string(STRIP ${NRF_VERSION} NRF_VERSION)

add_docset(nrf ${NRF_VERSION})
add_doxygen_docset(nrf ${NRF_BASE} ${NRF_VERSION})

#-------------------------------------------------------------------------------
# docset: mcuboot

add_docset(mcuboot)
add_docset(mcuboot "2.0.99")

#-------------------------------------------------------------------------------
# docset: nrfx

add_doxygen_docset(nrfx ${ZEPHYR_HAL_NORDIC_MODULE_DIR} STANDALONE)
add_doxygen_docset(nrfx ${ZEPHYR_HAL_NORDIC_MODULE_DIR} "" STANDALONE)

#-------------------------------------------------------------------------------
# docset: tfm

add_docset(tfm DODGY)
add_docset(tfm "2.0.0" DODGY)

#-------------------------------------------------------------------------------
# docset: matter

add_docset(matter DODGY)
add_docset(matter "1.3.0" DODGY)

#-------------------------------------------------------------------------------
# docset: nrfxlib

add_docset(nrfxlib DODGY)
add_doxygen_docset(nrfxlib ${ZEPHYR_NRFXLIB_MODULE_DIR})
add_docset(nrfxlib ${NRF_VERSION} DODGY)
add_doxygen_docset(nrfxlib ${ZEPHYR_NRFXLIB_MODULE_DIR} ${NRF_VERSION})

#-------------------------------------------------------------------------------
# docset: internal

if (EXISTS "${ZEPHYR_DOC_INTERNAL_MODULE_DIR}" )
message(STATUS "Internal documentation included")
add_docset(internal)
add_docset(internal "")
endif()

#-------------------------------------------------------------------------------
# docset: kconfig

add_docset(kconfig)
add_docset(kconfig "")

#-------------------------------------------------------------------------------
# Global targets
Expand Down
3 changes: 2 additions & 1 deletion doc/matter/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

import os
from pathlib import Path
import sys

Expand All @@ -23,7 +24,7 @@
project = "Matter SDK"
copyright = "2020-2024, Matter Contributors"
author = "Matter Contributors"
version = "1.3.0"
version = os.environ.get("DOCSET_VERSION")

sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
Expand Down
3 changes: 2 additions & 1 deletion doc/mcuboot/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# MCUboot documentation build configuration file

import os
from pathlib import Path
import sys

Expand All @@ -24,7 +25,7 @@

project = "MCUboot"
copyright = "2019-2024, Nordic Semiconductor"
version = release = "2.0.99"
version = release = os.environ.get("DOCSET_VERSION")

sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
Expand Down
3 changes: 2 additions & 1 deletion doc/nrf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
project = "nRF Connect SDK"
copyright = "2019-2024, Nordic Semiconductor"
author = "Nordic Semiconductor"
version = release = "2.7.99"
version = release = os.environ.get("DOCSET_VERSION")

sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
Expand Down Expand Up @@ -129,6 +129,7 @@
"NRF_BASE": str(NRF_BASE),
"DOCSET_SOURCE_BASE": str(NRF_BASE),
"DOCSET_BUILD_DIR": str(doxyrunner_outdir),
"DOCSET_VERSION": version,
}

# create mbedtls config header (needed for Doxygen)
Expand Down
2 changes: 1 addition & 1 deletion doc/nrf/nrf.doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = "nRF Connect SDK API"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1.0
PROJECT_NUMBER = @DOCSET_VERSION@

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
3 changes: 2 additions & 1 deletion doc/nrfxlib/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
project = "nrfxlib"
copyright = "2019-2024, Nordic Semiconductor"
author = "Nordic Semiconductor"
version = release = "2.7.99"
version = release = os.environ.get("DOCSET_VERSION")

sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
Expand Down Expand Up @@ -84,6 +84,7 @@
"NRF_BASE": str(NRF_BASE),
"DOCSET_SOURCE_BASE": str(NRFXLIB_BASE),
"DOCSET_BUILD_DIR": str(doxyrunner_outdir),
"DOCSET_VERSION": version,
}

# -- Options for doxybridge plugin ---------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/nrfxlib/nrfxlib.doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = "nrfxlib API"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1.0
PROJECT_NUMBER = @DOCSET_VERSION@

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
3 changes: 2 additions & 1 deletion doc/tfm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# TFM documentation build configuration file

import os
from pathlib import Path
import sys

Expand All @@ -25,7 +26,7 @@
project = "Trusted Firmware-M"
copyright = "2017-2021, ARM CE-OSS"
author = "ARM CE-OSS"
version = "2.0.0"
version = os.environ.get("DOCSET_VERSION")

sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions"))
Expand Down
1 change: 1 addition & 0 deletions doc/zephyr/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"NRF_BASE": str(NRF_BASE),
"DOCSET_SOURCE_BASE": str(ZEPHYR_BASE),
"DOCSET_BUILD_DIR": str(doxyrunner_outdir),
"DOCSET_VERSION": version,
}

# -- Options for zephyr.warnings_filter ----------------------------------------
Expand Down

0 comments on commit 672fe15

Please sign in to comment.