Skip to content

Commit 41566e2

Browse files
gmarullfabiobaltieri
authored andcommitted
doc: add support for linkcheck
This patch adds support for the `linkcheck` Sphinx builder, so that we can easily check for broken links in the documentation. It can be run like this: ninja linkcheck Or, using the Makefile shim: make linkcheck All Zephyr Github issues links are ignored, since we have lots of these URLs and they quickly hit GH rate limit. They have small chance to be incorrect, so we should be ok. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent f9ccac2 commit 41566e2

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

doc/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set(DOCS_DOCTREE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doctrees)
4949
set(DOCS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
5050
set(DOCS_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/src)
5151
set(DOCS_HTML_DIR ${CMAKE_CURRENT_BINARY_DIR}/html)
52+
set(DOCS_LINKCHECK_DIR ${CMAKE_CURRENT_BINARY_DIR}/linkcheck)
5253
set(DOCS_LATEX_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)
5354

5455
if(WIN32)
@@ -208,6 +209,33 @@ if(LATEX_PDFLATEX_FOUND AND LATEXMK)
208209
add_dependencies(pdf latex)
209210
endif()
210211

212+
#-------------------------------------------------------------------------------
213+
# linkcheck
214+
215+
add_doc_target(
216+
linkcheck
217+
COMMAND ${CMAKE_COMMAND} -E env ${SPHINX_ENV}
218+
${SPHINXBUILD}
219+
-b linkcheck
220+
-c ${DOCS_CFG_DIR}
221+
-d ${DOCS_DOCTREE_DIR}
222+
-w ${DOCS_BUILD_DIR}/linkcheck.log
223+
-t ${DOC_TAG}
224+
${SPHINXOPTS}
225+
${DOCS_SRC_DIR}
226+
${DOCS_LINKCHECK_DIR}
227+
USES_TERMINAL
228+
COMMENT "Running Sphinx link check..."
229+
)
230+
231+
set_target_properties(
232+
linkcheck linkcheck-nodeps
233+
PROPERTIES
234+
ADDITIONAL_CLEAN_FILES "${DOCS_SRC_DIR};${DOCS_LINKCHECK_DIR};${DOCS_DOCTREE_DIR}"
235+
)
236+
237+
add_dependencies(linkcheck devicetree)
238+
211239
#-------------------------------------------------------------------------------
212240
# others
213241

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DT_TURBO_MODE ?= 0
1616
html-fast:
1717
${MAKE} html DT_TURBO_MODE=1
1818

19-
html latex pdf doxygen: configure
19+
html latex pdf linkcheck doxygen: configure
2020
cmake --build ${BUILDDIR} --target $@
2121

2222
configure:

doc/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@
201201
("index-tex", "zephyr.tex", "Zephyr Project Documentation", author, "manual"),
202202
]
203203

204+
# -- Options for linkcheck ------------------------------------------------
205+
206+
linkcheck_ignore = [
207+
r"https://github.com/zephyrproject-rtos/zephyr/issues/.*"
208+
]
209+
204210
# -- Options for zephyr.doxyrunner plugin ---------------------------------
205211

206212
doxyrunner_doxygen = os.environ.get("DOXYGEN_EXECUTABLE", "doxygen")

0 commit comments

Comments
 (0)