Skip to content

Commit

Permalink
Fix Python commands & documentation generation
Browse files Browse the repository at this point in the history
- Fix importlib call in cmake-generated Python executables for stand-alone Python files; this regressed in cleanup commit 291a747.
- Update docs/generate_user_docs.sh to reflect new handling of Python commands.
- Auto-update of some Python command help pages.
  • Loading branch information
Lestropie committed Jun 21, 2024
1 parent f87bc0e commit 8822ce8
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmake/MakePythonExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/__init__.py")
endif()
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}.py")
string(APPEND BINPATH_CONTENTS
"module = importlib.import_module('${CMDNAME}')\n"
"module = importlib.import_module('.${CMDNAME}', 'mrtrix3.commands')\n"
"_execute(module.usage, module.execute)\n"
)
else()
Expand Down
6 changes: 3 additions & 3 deletions docs/generate_user_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function prepend {
# Generating documentation for all commands

mrtrix_root=$( cd "$(dirname "${BASH_SOURCE}")"/../ ; pwd -P )
export PATH=$build_dir/bin:${mrtrix_root}/python/bin:"$PATH"
export PATH=$build_dir/bin:$PATH
dirpath=${mrtrix_root}'/docs/reference/commands'
export LC_ALL=C

Expand Down Expand Up @@ -82,8 +82,8 @@ cmdlist=""
for n in `find "${mrtrix_root}"/cmd/ -name "*.cpp"`; do
cmdlist=$cmdlist$'\n'`basename $n`
done
for n in `find "${mrtrix_root}"/python/bin/ -type f -print0 | xargs -0 grep -l "import mrtrix3"`; do
cmdlist=$cmdlist$'\n'`basename $n`
for n in `ls "${mrtrix_root}"/python/mrtrix3/commands/ --ignore=__init__.py* --ignore=CMakeLists.txt`; do
cmdlist=$cmdlist$'\n'`basename $n .py`
done

for n in `echo "$cmdlist" | sort`; do
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/5ttgen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage

5ttgen algorithm [ options ] ...

- *algorithm*: Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: freesurfer, fsl, gif, hsvs
- *algorithm*: Select the algorithm to be used; additional details and options become available once an algorithm is nominated. Options are: freesurfer, fsl, gif, hsvs

Description
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwi2mask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage

dwi2mask algorithm [ options ] ...

- *algorithm*: Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: 3dautomask, ants, b02template, consensus, fslbet, hdbet, legacy, mean, mtnorm, synthstrip, trace
- *algorithm*: Select the algorithm to be used; additional details and options become available once an algorithm is nominated. Options are: 3dautomask, ants, b02template, consensus, fslbet, hdbet, legacy, mean, mtnorm, synthstrip, trace

Description
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwi2response.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage

dwi2response algorithm [ options ] ...

- *algorithm*: Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: dhollander, fa, manual, msmt_5tt, tax, tournier
- *algorithm*: Select the algorithm to be used; additional details and options become available once an algorithm is nominated. Options are: dhollander, fa, manual, msmt_5tt, tax, tournier

Description
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwibiascorrect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage

dwibiascorrect algorithm [ options ] ...

- *algorithm*: Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: ants, fsl, mtnorm
- *algorithm*: Select the algorithm to be used; additional details and options become available once an algorithm is nominated. Options are: ants, fsl, mtnorm

Description
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwinormalise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage

dwinormalise algorithm [ options ] ...

- *algorithm*: Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: group, manual, mtnorm
- *algorithm*: Select the algorithm to be used; additional details and options become available once an algorithm is nominated. Options are: group, manual, mtnorm

Description
-----------
Expand Down

0 comments on commit 8822ce8

Please sign in to comment.