Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0fd86f94 authored by hhakim's avatar hhakim
Browse files

Fix matlab non-member functions inline doc issue (visible doxygen syntax).

- Fix gen_doc/gen_matlab_inline_doc_from_doxy_blocks.sh in order to manage files with only a function (instead of class).
- Add the script gen_doc/filterout_matlab_doxy_blocks.sh to avoid the doxygen block to take over the matla inline doc in matlab... (a problem that doesn't not occur for class functions, it happens only to non-member functions).
- Other minor fixes.
parent 4c378e7c
Branches
Tags
No related merge requests found
Pipeline #833974 skipped
#!/bin/bash
# this script removes the doxygen block of code doc from a matlab script
# it is very useful because otherwise it will be used as inline documentation in matlab (with all specific syntax of doxygen, nobody wants that).
# even if an inner function code doc is existing
# A doxygen code block starts with % followed in the same line by at least five `=' characters.
# It terminates with the same form of sequence.
[[ ! -r "$1" ]] && echo "$1 is not readable/existing as a file." >&2 && exit 0 # not an error, just skipping
#sed -i '/%=\{5,\}/,/%=\{5,\}/d' $1 # macos default sed can't do this (it gives an error:sed: 1: command c expects \ followed by text
sed -e '/%=\{5,\}/,/%=\{5,\}/d' $1 > ${1}_tmp
mv "${1}_tmp" "$1"
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
function usage { function usage {
echo "USAGE: $0 <input_path.m> <output_path.m>" echo "USAGE: $0 <input_path.m> <output_path.m> [only_func]"
} }
function usage_exit { function usage_exit {
...@@ -32,6 +32,7 @@ function parse_doxy_block { ...@@ -32,6 +32,7 @@ function parse_doxy_block {
s/<[^>]*>//g; s/<[^>]*>//g;
s/&nbsp;/ /g; s/&nbsp;/ /g;
s/@retval/Returns/g; s/@retval/Returns/g;
s/@warning/Warning:/g;
s/@[^[:blank:]]* \{0,1\}//g; s/@[^[:blank:]]* \{0,1\}//g;
s/\\\./\./g s/\\\./\./g
}" }"
...@@ -43,10 +44,12 @@ function parse_doxy_block { ...@@ -43,10 +44,12 @@ function parse_doxy_block {
[[ ! -r $1 ]] && exit 0 [[ ! -r $1 ]] && exit 0
[[ -n "$2" ]] && OUTPUT_FILE="$2" || usage_exit 2 "arg 2 is empty" [[ -n "$2" ]] && OUTPUT_FILE="$2" || usage_exit 2 "arg 2 is empty"
[[ "$3" = only_func ]] && ONLY_FUNC=1
# get function names # get function names
FUNCTIONS=$(sed -ne 's/^[[:blank:]]*function[[:blank:]]\{1,\}\([^=]\{1,\}=\)\{0,1\}[[:blank:]]*\([^([:blank:]]\{1,\}\).*$/\2/p' "$INPUT_FILE") FUNCTIONS=$(sed -ne 's/^[[:blank:]]*function[[:blank:]]\{1,\}\([^=]\{1,\}=\)\{0,1\}[[:blank:]]*\([^([:blank:]]\{1,\}\).*$/\2/p' "$INPUT_FILE")
[[ -z "${FUNCTIONS}" ]] && echo "ERROR in getting the list of functions in $INPUT_FILE" && exit 3 [[ -z "${FUNCTIONS}" ]] && echo "ERROR in getting the list of functions in $INPUT_FILE" && cp "$INPUT_FILE" "$OUTPUT_FILE" && exit 0 # not taken as an error for the calling script
mkdir -p $(dirname "$OUTPUT_FILE") mkdir -p $(dirname "$OUTPUT_FILE")
...@@ -89,7 +92,7 @@ do ...@@ -89,7 +92,7 @@ do
# insert parsed block # insert parsed block
FUNC_DEF_LINE=$(sed -ne $FUNC_LINE'p' $OUTPUT_FILE) FUNC_DEF_LINE=$(sed -ne $FUNC_LINE'p' $OUTPUT_FILE)
sed -ne '1,'$FUNC_LINE'p' $OUTPUT_FILE > ${OUTPUT_FILE}_tmp sed -ne '1,'$FUNC_LINE'p' $OUTPUT_FILE > ${OUTPUT_FILE}_tmp
# parse doxy block for inline block # parse doxy block for inline block
INLINE_BLOCK=$(parse_doxy_block $FUNC "$DOXY_BLOCK" "$FUNC_DEF_LINE") INLINE_BLOCK=$(parse_doxy_block $FUNC "$DOXY_BLOCK" "$FUNC_DEF_LINE")
echo -e "$INLINE_BLOCK" >> ${OUTPUT_FILE}_tmp echo -e "$INLINE_BLOCK" >> ${OUTPUT_FILE}_tmp
sed -ne $(($FUNC_LINE+1))','$(wc -l ${OUTPUT_FILE} | awk '{print $1}')'p' $OUTPUT_FILE >> ${OUTPUT_FILE}_tmp sed -ne $(($FUNC_LINE+1))','$(wc -l ${OUTPUT_FILE} | awk '{print $1}')'p' $OUTPUT_FILE >> ${OUTPUT_FILE}_tmp
...@@ -98,6 +101,7 @@ do ...@@ -98,6 +101,7 @@ do
done done
[[ "$ONLY_FUNC" = 1 ]] && exit
# filter header for class doc # filter header for class doc
HEADER_START_END=($(sed -ne '/^[[:blank:]]*% ==*/=' $OUTPUT_FILE)) HEADER_START_END=($(sed -ne '/^[[:blank:]]*% ==*/=' $OUTPUT_FILE))
......
...@@ -21,5 +21,5 @@ ...@@ -21,5 +21,5 @@
%> - The third group of algorithms is for FGFT computing: fact.fgft_palm fact.fgft_givens fact.eigtj %> - The third group of algorithms is for FGFT computing: fact.fgft_palm fact.fgft_givens fact.eigtj
%> %>
%> %>
% ====================================================================== %======================================================================
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
%> Primarily for convenience and test purposes, a Faust can be converted into %> Primarily for convenience and test purposes, a Faust can be converted into
%> the corresponding full matrix using the function Faust.full. %> the corresponding full matrix using the function Faust.full.
%> %>
%> \warning using Faust.full is discouraged except for test purposes, as it %> @warning using Faust.full is discouraged except for test purposes, as it
%> loses the main potential interests of the FAuST structure: compressed %> loses the main potential interests of the FAuST structure: compressed
%> memory storage and faster matrix-vector multiplication compared to its %> memory storage and faster matrix-vector multiplication compared to its
%> equivalent full matrix representation. %> equivalent full matrix representation.
......
%> @package matfaust @brief <b> The FAuST Matlab Wrapper %====================================
% ====================================
%> Returns the FAuST package version. %> Returns the FAuST package version.
%===
%> %>
% ==================================== %====================================
function ver = version() function ver = version()
ver = '@CPACK_PACKAGE_VERSION@'; ver = '@CPACK_PACKAGE_VERSION@';
end end
%> @package matfaust @brief <b> The FAuST Matlab Wrapper
...@@ -58,12 +58,13 @@ foreach(MATFAUST_FILE IN LISTS FAUST_MATLAB_MATFAUST_FILE_LIST) ...@@ -58,12 +58,13 @@ foreach(MATFAUST_FILE IN LISTS FAUST_MATLAB_MATFAUST_FILE_LIST)
COMMENT "Filtering matfaust ${MATFAUST_FILE} experimental code.") COMMENT "Filtering matfaust ${MATFAUST_FILE} experimental code.")
endif() endif()
add_custom_target(FILTERING_EXP_CODE_${MATFAUST_SHORT_FILE} ALL DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE}) add_custom_target(FILTERING_EXP_CODE_${MATFAUST_SHORT_FILE} ALL DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE})
# use script generating inline doc only for real matlab classes # use script generating inline doc only for real matlab classes and functions
if(WIN32)
set(SH_CMD git-bash)
endif() # on Unix, count on bash that is in PATH
if(${MATFAUST_FILE} MATCHES "@") if(${MATFAUST_FILE} MATCHES "@")
message(STATUS "matfaust class: " ${MATFAUST_FILE}) message(STATUS "matfaust class: " ${MATFAUST_FILE})
if(WIN32)
set(SH_CMD git-bash)
endif() # on Unix, count on bash that is in PATH
add_custom_command(OUTPUT ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} add_custom_command(OUTPUT ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
COMMAND ${PROJECT_SOURCE_DIR}/gen_doc/gen_matlab_inline_doc_from_doxy_blocks.sh ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} COMMAND ${PROJECT_SOURCE_DIR}/gen_doc/gen_matlab_inline_doc_from_doxy_blocks.sh ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE}
...@@ -74,13 +75,20 @@ foreach(MATFAUST_FILE IN LISTS FAUST_MATLAB_MATFAUST_FILE_LIST) ...@@ -74,13 +75,20 @@ foreach(MATFAUST_FILE IN LISTS FAUST_MATLAB_MATFAUST_FILE_LIST)
else() else()
message(STATUS "matfaust function file: " ${MATFAUST_FILE}) message(STATUS "matfaust function file: " ${MATFAUST_FILE})
# just copy the .m # just copy the .m
#TODO: inline doc should be possible for function files too # generate inline doc for function files too
#configure_file(${FAUST_MATLAB_NAMESPACE_SRC_DIR}/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} @ONLY) #configure_file(${FAUST_MATLAB_NAMESPACE_SRC_DIR}/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} @ONLY)
# add_custom_command(OUTPUT ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
# COMMAND python
# ARGS ${PROJECT_SOURCE_DIR}/gen_doc/matlab_copy_function_file.py ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
# DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE}
# COMMENT "Generating matfaust inline doc for ${MATFAUST_FILE} (just copied because it's a function file).")
add_custom_command(OUTPUT ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} add_custom_command(OUTPUT ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
COMMAND python COMMAND ${PROJECT_SOURCE_DIR}/gen_doc/gen_matlab_inline_doc_from_doxy_blocks.sh ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} only_func
ARGS ${PROJECT_SOURCE_DIR}/gen_doc/matlab_copy_function_file.py ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}
DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE} DEPENDS ${FAUST_MATLAB_BIN_DIR}/expfiltered/${MATFAUST_FILE}
COMMENT "Generating matfaust inline doc for ${MATFAUST_FILE} (just copied because it's a function file).") COMMENT "Generating matfaust inline doc for ${MATFAUST_FILE}")
add_custom_target(FILTER_OUT_MATLAB_DOXYBLOCKS_${MATFAUST_SHORT_FILE} ALL
COMMAND ${PROJECT_SOURCE_DIR}/gen_doc/filterout_matlab_doxy_blocks.sh ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE} DEPENDS doc COMMENT "Removing doxygen blocks from function file.")
endif() endif()
add_custom_target(GEN_MATFAUST_INLINE_DOC_${MATFAUST_SHORT_FILE} ALL DEPENDS ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE}) add_custom_target(GEN_MATFAUST_INLINE_DOC_${MATFAUST_SHORT_FILE} ALL DEPENDS ${FAUST_MATLAB_NAMESPACE_BIN_DIR}/${MATFAUST_FILE})
add_dependencies(PREPARE_MATFAUST_FOR_DOXYDOC GEN_MATFAUST_INLINE_DOC_${MATFAUST_SHORT_FILE}) add_dependencies(PREPARE_MATFAUST_FOR_DOXYDOC GEN_MATFAUST_INLINE_DOC_${MATFAUST_SHORT_FILE})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment