mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
doc: add spa to doxygen output
This requires a helper script: doxygen doesn't differ between static methods and static inline methods. EXTRACT_STATIC defines whether it parses *any* static method but we're currently using all C files as input files as well. We cannot convince doxygen to just parse static inline functions in header files so for SPA we hack around this: meson passes the spa headers to a shell script with simply copies those changed to `/* static */ inline void (foo)` and doxygen then runs on those header files. The result: we get all spa functions added to your doxygen output at the cost of a few sed calls.
This commit is contained in:
parent
07533cb708
commit
851a64d8c8
|
@ -14,6 +14,7 @@ QUIET = YES
|
|||
WARN_NO_PARAMDOC = YES
|
||||
INPUT = @inputs@
|
||||
FILE_PATTERNS = "*.h" "*.c"
|
||||
RECURSIVE = YES
|
||||
EXAMPLE_PATH = "@top_srcdir@/src/tools" \
|
||||
"@top_srcdir@/src/examples"
|
||||
|
||||
|
|
|
@ -18,6 +18,31 @@ foreach h : pipewire_sources
|
|||
inputs += meson.source_root() / 'src' / 'pipewire' / h
|
||||
endforeach
|
||||
|
||||
# SPA headers use static inline functions. Doxygen doesn't extract those
|
||||
# unless we have EXTRACT_STATIC set - but we don't want it to extract
|
||||
# everything in the rest of the tree.
|
||||
# The shell script here basically does a:
|
||||
# cp spa/* builddir/spa/ && sed -i 's/^static//' buildir/spa/**.h
|
||||
# The copied files are passed to doxygen as input and they are parsed as
|
||||
# normal functions.
|
||||
# Because this uses globbing, this target won't rebuild if the headers
|
||||
# change but meh.
|
||||
spa_header_dirs = []
|
||||
sed = find_program('sed', required: false)
|
||||
if sed.found()
|
||||
spa_srcdir = meson.source_root() / 'spa' / 'include' / 'spa'
|
||||
spa_dstdir = meson.current_build_dir() / 'spa'
|
||||
spa_strip_static = custom_target(
|
||||
'spa-strip-static',
|
||||
command: [ find_program('strip-static.sh'), spa_srcdir, spa_dstdir ],
|
||||
build_by_default: true,
|
||||
output: 'spa',
|
||||
)
|
||||
spa_header_dirs += spa_dstdir
|
||||
else
|
||||
spa_strip_static = []
|
||||
endif
|
||||
|
||||
extra_docs = [
|
||||
'overview.md',
|
||||
'design.txt',
|
||||
|
@ -46,7 +71,7 @@ cssfiles = [
|
|||
meson.source_root() / 'doc' / 'custom.css'
|
||||
]
|
||||
|
||||
doxyfile_conf.set('inputs', ' '.join(inputs))
|
||||
doxyfile_conf.set('inputs', ' '.join(inputs + [spa_dstdir]))
|
||||
doxyfile_conf.set('cssfiles', ' '.join(cssfiles))
|
||||
|
||||
doxyfile = configure_file(input: 'Doxyfile.in',
|
||||
|
@ -62,5 +87,6 @@ html_target = custom_target('pipewire-docs',
|
|||
input: [ doxyfile ] + inputs + cssfiles,
|
||||
output: [ 'html' ],
|
||||
command: [ doxygen, doxyfile ],
|
||||
depends: spa_strip_static,
|
||||
install: true,
|
||||
install_dir: docdir)
|
||||
|
|
18
doc/strip-static.sh
Executable file
18
doc/strip-static.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Replicates the source tree at $SOURCE to $DEST with any static removed
|
||||
# from the file. This allows Doxygen to parse the file and document static
|
||||
# inline functions.
|
||||
|
||||
SOURCE="$1"
|
||||
DEST="$2"
|
||||
test -n "$SOURCE" || (echo "Source argument is missing" && exit 1)
|
||||
test -n "$DEST" || (echo "Dest argument is missing" && exit 1)
|
||||
|
||||
echo "Reading from $SOURCE"
|
||||
echo "Copying to $DEST"
|
||||
|
||||
mkdir -p "$DEST"
|
||||
cp -rf "$SOURCE"/* "$DEST/"
|
||||
shopt -s globstar # proper recursive globbing
|
||||
sed -i 's|^static|/* \0 */|' "$DEST"/**/*.h
|
|
@ -1,3 +1,17 @@
|
|||
spa_sections = [
|
||||
'buffer',
|
||||
'control',
|
||||
'debug',
|
||||
'graph',
|
||||
'monitor',
|
||||
'node',
|
||||
'param',
|
||||
'pod',
|
||||
'support',
|
||||
'utils',
|
||||
]
|
||||
|
||||
spa_headers = 'spa' # used by doxygen
|
||||
install_subdir('spa',
|
||||
install_dir : get_option('includedir') / spa_name
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue