78
78
export VIRTUALENVWRAPPER_PROJECT_FILENAME=" .project"
79
79
fi
80
80
81
+ # Remember where we are running from.
82
+ if [ -z " $VIRTUALENVWRAPPER_SCRIPT " ]
83
+ then
84
+ export VIRTUALENVWRAPPER_SCRIPT=" $0 "
85
+ fi
86
+
81
87
# Portable shell scripting is hard, let's go shopping.
82
88
#
83
89
# People insist on aliasing commands like 'cd', either with a real
@@ -375,6 +381,7 @@ function virtualenvwrapper_mkvirtualenv_help {
375
381
# Usage: mkvirtualenv [options] ENVNAME
376
382
# (where the options are passed directly to virtualenv)
377
383
#
384
+ # :help:mkvirtualenv: Create a new virtualenv in $WORKON_HOME
378
385
function mkvirtualenv {
379
386
typeset -a in_args
380
387
typeset -a out_args
@@ -491,7 +498,7 @@ function mkvirtualenv {
491
498
virtualenvwrapper_run_hook " post_mkvirtualenv"
492
499
}
493
500
494
- # Remove an environment, in the WORKON_HOME.
501
+ # :help:rmvirtualenv: Remove a virtualenv
495
502
function rmvirtualenv {
496
503
virtualenvwrapper_verify_workon_home || return 1
497
504
if [ ${#@ } = 0 ]
@@ -558,9 +565,7 @@ function _lsvirtualenv_usage {
558
565
echo " -h -- this help message"
559
566
}
560
567
561
- # List virtual environments
562
- #
563
- # Usage: lsvirtualenv [-l]
568
+ # :help:lsvirtualenv: list virtualenvs
564
569
function lsvirtualenv {
565
570
566
571
typeset long_mode=true
@@ -608,9 +613,7 @@ function lsvirtualenv {
608
613
fi
609
614
}
610
615
611
- # Show details of a virtualenv
612
- #
613
- # Usage: showvirtualenv [env]
616
+ # :help:showvirtualenv: show details of a single virtualenv
614
617
function showvirtualenv {
615
618
typeset env_name=" $1 "
616
619
if [ -z " $env_name " ]
@@ -646,10 +649,7 @@ function virtualenvwrapper_workon_help {
646
649
echo " "
647
650
}
648
651
649
- # List or change working virtual environments
650
- #
651
- # Usage: workon [environment_name]
652
- #
652
+ # :help:workon: list or change working virtualenvs
653
653
function workon {
654
654
in_args=( " $@ " )
655
655
@@ -765,6 +765,8 @@ function virtualenvwrapper_get_site_packages_dir {
765
765
# "virtualenv_path_extensions.pth" inside the virtualenv's
766
766
# site-packages directory; if this file does not exist, it will be
767
767
# created first.
768
+ #
769
+ # :help:add2virtualenv: add directory to the import path
768
770
function add2virtualenv {
769
771
virtualenvwrapper_verify_workon_home || return 1
770
772
virtualenvwrapper_verify_active_environment || return 1
@@ -829,6 +831,7 @@ function add2virtualenv {
829
831
830
832
# Does a ``cd`` to the site-packages directory of the currently-active
831
833
# virtualenv.
834
+ # :help:cdsitepackages: change to the site-packages directory
832
835
function cdsitepackages {
833
836
virtualenvwrapper_verify_workon_home || return 1
834
837
virtualenvwrapper_verify_active_environment || return 1
@@ -837,6 +840,7 @@ function cdsitepackages {
837
840
}
838
841
839
842
# Does a ``cd`` to the root of the currently-active virtualenv.
843
+ # :help:cdvirtualenv: change to the $VIRTUAL_ENV directory
840
844
function cdvirtualenv {
841
845
virtualenvwrapper_verify_workon_home || return 1
842
846
virtualenvwrapper_verify_active_environment || return 1
@@ -845,6 +849,7 @@ function cdvirtualenv {
845
849
846
850
# Shows the content of the site-packages directory of the currently-active
847
851
# virtualenv
852
+ # :help:lssitepackages: list contents of the site-packages directory
848
853
function lssitepackages {
849
854
virtualenvwrapper_verify_workon_home || return 1
850
855
virtualenvwrapper_verify_active_environment || return 1
@@ -862,6 +867,7 @@ function lssitepackages {
862
867
863
868
# Toggles the currently-active virtualenv between having and not having
864
869
# access to the global site-packages.
870
+ # :help:toggleglobalsitepackages: turn access to global site-packages on/off
865
871
function toggleglobalsitepackages {
866
872
virtualenvwrapper_verify_workon_home || return 1
867
873
virtualenvwrapper_verify_active_environment || return 1
@@ -875,7 +881,7 @@ function toggleglobalsitepackages {
875
881
fi
876
882
}
877
883
878
- # Duplicate the named virtualenv to make a new one.
884
+ # :help:cpvirtualenv: duplicate the named virtualenv to make a new one
879
885
function cpvirtualenv {
880
886
virtualenvwrapper_verify_workon_home || return 1
881
887
virtualenvwrapper_verify_virtualenv_clone || return 1
@@ -968,6 +974,7 @@ function virtualenvwrapper_verify_project_home {
968
974
# Given a virtualenv directory and a project directory,
969
975
# set the virtualenv up to be associated with the
970
976
# project
977
+ # :help:setvirtualenvproject: associate a project directory with a virtualenv
971
978
function setvirtualenvproject {
972
979
typeset venv=" $1 "
973
980
typeset prj=" $2 "
@@ -1024,7 +1031,7 @@ function virtualenvwrapper_mkproject_help {
1024
1031
" $VIRTUALENVWRAPPER_PYTHON " -c ' from virtualenvwrapper.hook_loader import main; main()' -l project.template
1025
1032
}
1026
1033
1027
- # Create a new project directory and its associated virtualenv.
1034
+ # :help:mkproject: create a new project directory and its associated virtualenv
1028
1035
function mkproject {
1029
1036
typeset -a in_args
1030
1037
typeset -a out_args
@@ -1109,7 +1116,7 @@ function mkproject {
1109
1116
virtualenvwrapper_run_hook " project.post_mkproject"
1110
1117
}
1111
1118
1112
- # Change directory to the active project
1119
+ # :help:cdproject: change directory to the active project
1113
1120
function cdproject {
1114
1121
virtualenvwrapper_verify_workon_home || return 1
1115
1122
virtualenvwrapper_verify_active_environment || return 1
@@ -1135,6 +1142,7 @@ function cdproject {
1135
1142
#
1136
1143
# Originally part of virtualenvwrapper.tmpenv plugin
1137
1144
#
1145
+ # :help:mktmpenv: create a temporary virtualenv
1138
1146
function mktmpenv {
1139
1147
typeset tmpenvname
1140
1148
typeset RC
@@ -1175,6 +1183,7 @@ EOF
1175
1183
#
1176
1184
# Remove all installed packages from the env
1177
1185
#
1186
+ # :help:wipeenv: remove all packages installed in the current virtualenv
1178
1187
function wipeenv {
1179
1188
virtualenvwrapper_verify_workon_home || return 1
1180
1189
virtualenvwrapper_verify_active_environment || return 1
@@ -1196,6 +1205,7 @@ function wipeenv {
1196
1205
#
1197
1206
# Run a command in each virtualenv
1198
1207
#
1208
+ # :help:allvirtualenv: run a command in all virtualenvs
1199
1209
function allvirtualenv {
1200
1210
virtualenvwrapper_verify_workon_home || return 1
1201
1211
typeset d
@@ -1214,6 +1224,7 @@ function allvirtualenv {
1214
1224
done
1215
1225
}
1216
1226
1227
+ # :help:virtualenvwrapper: show this help message
1217
1228
function virtualenvwrapper {
1218
1229
cat << EOF
1219
1230
@@ -1229,43 +1240,14 @@ For more information please refer to the documentation:
1229
1240
1230
1241
Commands available:
1231
1242
1232
- add2virtualenv: Adds the specified directories to the Python
1233
- path for the currently-active virtualenv.
1234
- allvirtualenv: Run a command in all virtualenvs under
1235
- \$ WORKON_HOME
1236
- cdproject: Change the current working directory to the
1237
- one specified as the project directory for
1238
- the active virtualenv.
1239
- cdsitepackages: Change the current working directory to the
1240
- site-packages for \$ VIRTUAL_ENV.
1241
- cdvirtualenv: Change the current working directory to
1242
- \$ VIRTUAL_ENV
1243
- cpvirtualenv: Duplicate an existing virtualenv environment.
1244
- deactivate: Switch from a virtual environment to the
1245
- system-installed version of Python
1246
- lssitepackages: Shows the content of the site-packages directory
1247
- of the currently-active virtualenv
1248
- lsvirtualenv: List all virtual environments, use -h for more
1249
- info
1250
- mkproject: Create a new virtualenv in the \$ WORKON_HOME and
1251
- project directory in \$ PROJECT_HOME
1252
- mktmpenv: Create a new temporary virtualenv in the
1253
- \$ WORKON_HOME directory with a generated name
1254
- mkvirtualenv: Create a new environment, in the \$ WORKON_HOME,
1255
- use -h for more info.
1256
- rmvirtualenv: Remove an environment
1257
- setvirtualenvproject: Bind an existing virtualenv to an existing
1258
- project.
1259
- showvirtualenv: Show the details for a single virtualenv
1260
- toggleglobalsitepackages: Controls whether the active virtualenv will
1261
- access the packages in the global
1262
- Python site-packages directory.
1263
- virtualenvwrapper: Prints this help message
1264
- wipeenv: Remove all of the installed third-party
1265
- packages in the current virtualenv.
1266
- workon: List or change working virtual environments
1267
-
1268
1243
EOF
1244
+
1245
+ typeset helpmarker=" #:help:"
1246
+ cat " $VIRTUALENVWRAPPER_SCRIPT " \
1247
+ | grep " ^$helpmarker " \
1248
+ | sed -e " s/^$helpmarker / /g" \
1249
+ | sort \
1250
+ | sed -e ' s/$/\' $' \n /g'
1269
1251
}
1270
1252
1271
1253
#
0 commit comments