AutoDocstring
Insert or update python docstrings; an improved docblockr for python
Details
Installs
- Total 18K
- Win 7K
- Mac 6K
- Linux 6K
Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 1 | 3 | 2 | 2 | 0 | 1 | 1 | 1 | 4 | 0 | 1 | 2 | 0 | 0 | 0 | 1 | 1 | 2 | 1 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 4 | 1 | 1 | 0 | 1 | 3 | 1 | 0 | 0 | 2 | 2 | 0 | 0 | 1 | 0 | 1 |
Mac | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
Linux | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2 | 0 | 3 | 0 | 1 | 1 | 1 | 2 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 8 | 0 | 2 | 1 | 1 | 3 | 1 | 1 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
Readme
- Source
- raw.githubusercontent.com
SublimeAutoDocstring
SublimeText plugin for inserting / updating docstrings in Python after analyzing function parameters and the like.
Features
- Inspects function definitions and inserts a stub for each parameter
- Inspects class / module attributes and inserts a stub for each
- Convert single docstrings or whole modules from one style to another with one command
- Pull parameter and return type information from Python 3 annotations
- Discovers what exceptions are raised in a function and inserts a stub for each
- Rearranges parameters to reflect their order in the function definition
- Automatically detects style: Google or Numpy
Installation
This plugin is indexed on Package Control. Once Package Control is installed, this package can be installed from the command palette using Package Control: Install Package
.
Alternatively, you can unzip this repository into your Packages
directory. This directory is easily opened using the Sublime Text > Preferences > Browse Packages...
menu on MacOS, or Preferences > Browse Packages...
on Linux / Windows.
Usage
Use these keyboard shortcuts, or the commands below from the Command Pallete.
- <
cmd
+alt
+'
> will update a docstring for the first module/class/function preceding the cursor. - <
cmd
+alt
+shift
+'
> will update docstrings for every class/method/function in the current file
Note that on linux / windows, ctrl
is used in place of cmd
.
Commands
AutoDocstring: Current
: Create or update the docstring for the next declaration that preceeds the cursorAutoDocstring: All
: Create or update docstrings for all declarations in a moduleAutoDocstring: Convert...
: Convert the docstring of the the next declaration that preceeds the cursor to a specific styleAutoDocstring: Convert All...
: Convert all existing docstrings in a module to a specific style
Settings
A shortcut to open the settings file is in menu under Preferences/Package Settings/AutoDocstring/Settings - User
. Settings can also be in a JSON hash (dictionary) called “AutoDocstring” in a project-settings file. Project settings will override package settings.
default_description
(default=“Description”): Filler text for descriptionsdefault_return_name
(default=“name”): Numpy style only. Default parameter name for return values. Set as an empty string to leave return values unnamed.default_summary
(default=“Summary”): Filler text for summarydefault_type
(default=“TYPE”): Filler text for typedefault_qstyle
(default=“”“): Type of quote to use for new docstrings.inspect_class_attributes
(default=true): add / remove class attributes to stay in sync with the codeinspect_exceptions
(default=true): add / remove exceptions to stay in sync with the code.inspect_function_parameters
(default=true): add / remove function parameters to stay in sync with the code.inspect_module_attributes
(default=true): add / remove module attributes to stay in sync with the code.optional_tag
(default="optional”): text to add to the type of keyword arguments. Supplying an empty string won't add anything special to new keyword arguments.sort_class_attributes
(default=true): Whether or not to alphabetically sort class attributes.sort_exceptions
(default=true): Whether or not to alphabetically sort exceptions.sort_module_attributes
(default=true): Whether or not to alphabetically sort module attributes.style
(default=“auto_google”): can be “google”, “numpy”, or “auto” for auto-detection based on the other docstrings in the module. A fallback can be specified with something like “auto_google” in case auto-detection fails.template_order
(default=false): If true, then reorder sections to the same order that they appear in the style's template. If false, section order of existings docstrings is preserved.use_snippet
(default=true): If true, then insert a snippet so that you can tab through newly inserted fields (Summary / Types / Desciptions).start_with_newline
(default=“”): Comma separated list of styles ('numpy', 'google') for which you want new docstrings to start with a newline. Can also be true or false to affect all styles.extra_class_newlines
default=true: According to PEP257, docstrings for classes should be surrounded by extra blank lines. Set this to false for more compact, but less PEP257 compliant class docstrings.keep_previous
(default=false): If true, then always append the existing docstring to the newly updated docstring. Could be useful for processing legacy code.