From dff5b2753e742992b1f68c3e3ad3bfb9dde174bf Mon Sep 17 00:00:00 2001 From: Cosmin Ciocan Date: Fri, 12 Jan 2024 15:53:17 +0100 Subject: [PATCH] Remove help from parser arguments and instead provide links in the parser description to documentation to avoid duplicate text --- nvcc4jupyter/parsers.py | 91 ++++++++--------------------------------- 1 file changed, 18 insertions(+), 73 deletions(-) diff --git a/nvcc4jupyter/parsers.py b/nvcc4jupyter/parsers.py index 62a1c15..201aaf5 100644 --- a/nvcc4jupyter/parsers.py +++ b/nvcc4jupyter/parsers.py @@ -5,53 +5,25 @@ def get_parser_cuda() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( description=( "%%cuda magic that compiles and runs CUDA C++ code in this cell." + " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda" + " for usage details." ) ) - parser.add_argument( - "-t", - "--timeit", - action="store_true", - help=( - 'If set, returns the output of the "timeit" built-in ipython magic' - " instead of stdout." - ), - ) - parser.add_argument( - "-p", - "--profile", - action="store_true", - help=( - "If set, runs the nvidia nsight compute profiler. Has no effect if" - " used with --timeit." - ), - ) - parser.add_argument( - "-a", - "--profiler-args", - type=str, - default="", - help=( - "Extra options that can be passed to the nvidia nsight compute" - " profiler. Must be the last option given to the argument parser" - " so you can pass arguments with dashes." - ), - ) + parser.add_argument("-t", "--timeit", action="store_true") + parser.add_argument("-p", "--profile", action="store_true") + parser.add_argument("-a", "--profiler-args", type=str, default="") return parser def get_parser_cuda_group_run() -> argparse.ArgumentParser: parser = get_parser_cuda() parser.description = ( - "%%cuda_group_run magic that compiles and runs source files in a" - " given group." - ) - parser.add_argument( - "-g", - "--group", - type=str, - required=True, - help="The group whose files should be compiled and executed.", + "%%cuda_group_run magic that compiles and runs source files in a given" + " group. See" + " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-run" + " for usage details." ) + parser.add_argument("-g", "--group", type=str, required=True) return parser @@ -60,49 +32,22 @@ def get_parser_cuda_group_save() -> argparse.ArgumentParser: description=( "%%cuda_group_save magic that saves CUDA C++ code in this cell for" " later compilation and execution with possibly more source files." + " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-save" + " for usage details." ) ) - parser.add_argument( - "-n", - "--name", - type=str, - required=True, - help=( - 'The name of the saved source file. Must have either the ".cu" or' - ' ".h" extension. In order to import a header file saved with this' - " magic you can simply add '#include \"\"'." - ), - ) - parser.add_argument( - "-g", - "--group", - type=str, - required=True, - help=( - "The group to which to add the saved source file. Groups are" - " source files that get compiled together and do not interact with" - " other groups. This allows you to have multiple unrelated CUDA" - " programs within the same jupyter notebook. Adding files to a" - ' group named "shared" will make them available to all other' - " source file groups. One use case for this is sharing error" - " handling code." - ), - ) + parser.add_argument("-n", "--name", type=str, required=True) + parser.add_argument("-g", "--group", type=str, required=True) return parser def get_parser_cuda_group_delete() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( description=( - "%%cuda_group_reset magic that deletes all files in a group." + "%%cuda_group_delete magic that deletes all files in a group. See" + " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-delete" + " for usage details." ) ) - parser.add_argument( - "-g", - "--group", - type=str, - required=True, - help="The group whose files should be deleted.", - ) + parser.add_argument("-g", "--group", type=str, required=True) return parser -