ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Doc​Blockr_Python

by adambullmer ST3

Sublime Text DocBlockr for python. Simplifies writing docstring comments in Python.

Details

Installs

  • Total 35K
  • Win 22K
  • OS X 6K
  • Linux 6K
Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4
Windows 17 11 15 13 17 13 19 23 17 18 19 16 7 12 16 18 17 13 9 14 14 14 13 17 10 10 15 18 17 23 20 13 12 9 23 13 7 18 11 11 8 15 8 18 9 19
OS X 3 3 3 7 4 6 5 8 4 7 1 4 4 8 5 5 4 3 5 1 1 7 6 5 5 1 1 7 4 8 1 5 1 3 3 3 1 6 4 1 1 7 5 2 7 7
Linux 3 4 5 4 9 3 6 2 13 6 3 1 3 5 5 3 3 5 2 1 3 6 9 3 2 5 5 3 6 4 5 26 2 3 7 4 1 4 4 1 4 4 3 3 5 4

Readme

Source
raw.​githubusercontent.​com

DocBlockr for Python

codecov

Based off the DocBlockr project, This extension provides the similar funtionality but for python docstrings. The default formatter for this plugin is designed around PEP-257 compliance but with more verbosity: Added variable types, listing class extensions, and listing decorators. The main goal of this project is to help developer provide better documentation by giving easy and consistent formatting.

Installation

Package Control Now you can install it with package control!

  1. Open your command pallete and type Package Control: Install Package.
  2. Find this project DocBlockr Python and press Enter.

Manually Download the release and put it in your installed packages directory yourself

  1. Go to the Latest Release and download the docblockr_python.sublime-package file.
  2. Move this file to your Installed Packages directory. (Preferences > Browse Packages... and go up one directory to see Installed Packages)
  3. If you are updating your existing install, a restart of Sublime Text will be in order.

Usage

There isn't a command pallete command to start this plugin, it is triggerg by hitting enter or tab after opening a docstring (""") at the module, class, or function level. If you wanted to simply put a new line after opening a docstring and not trigger the formatter, just hold ctrl and press enter.

Default and User Settings

You can configure which docstring format to use by updating your user settings for this package. (Preferences > Package Settings > DocBlockr Python > Settings (User)) For a full list of settings with documentation on what they affect, look at the Settings (Default) file.

Project Settings

You can also override your user settings on a per project basis by editing your project file. Any setting will be available for overriding here.

{
    "DocblockrPython": {
        "formatter": "sphinx"
    },
    "folders": [
      // ...
    ]
}

Supported Docstring Styles

Extendability

If you don't like the formatting styles above, or want to make your own style to fit your use case, you can write your own formatter. All you will need to do is extend the Base formatter class and write your formatter functions. If you're not sure about it, you can take a look at any of the other formatters in the formatters source dir and see how they did it.

from DocBlockr_Python.formatters.base import Base


class MyFormatter(Base):
    # This will be used as your settings file value,
    # and how the formatter is registered in the registry
    name = 'my'

Note: The console should yell at you if you didn't write all the abstract methods. Be sure to read the docs on the Base formatter to make sure you understand all the caveats of each formatter function.

Local Development

Below are the instructions to work on this repo locally.

  1. Clone the repo.
  2. Uninstall the plugin from sublime text.
  3. Symlink the github repo into your sublime text packages directory.
    • Debian example: “bash ln -s $HOME/.config/sublime-text-3/Packages/Docblockr_Python
1. There are no runtime dependencies
1. Pay attention to the sublime console ```ctrl + ` ```


Testing Changes
---------------

In addition to the setup instructions above, testing will require additinoal setup.

**System Requirements:**
- [pyenv](https://github.com/pyenv/pyenv)
- [pipenv](https://pipenv.readthedocs.io/en/latest/)

**Setup:**
1. Install depedencies through pipenv `pipenv install --dev`
1. Run unit tests `pipenv run tox`
    - [py.test](https://docs.pytest.org/en/latest/) unit tests
    - [flake8](http://flake8.pycqa.org/en/latest/) linting
    - [pydocstyle](http://www.pydocstyle.org/en/2.1.1/) (formerly PEP257) docstring checker


Known Issues
------------
- Only detects closed docstring if it is on a line of the same indentation, and has no text in front of it. Single Line docstrings are converted to block
- The tests run in python `3.4.3`, however sublime's python version is `3.3.6`. This is due to the difficulty of getting a working version of 3.3.6 in a dev environment, and the differences should be minimal.


Roadmap
-------
Things I want to do wtih this project. Not necessarily an exhaustive or prioritized list.

- Unit Tests!
    - Needs a test harness of some sort for sublime internals.
- CI, probably circleci
- Coverage reporting
- More completions!
- Javadoc style formatter
- Keyboard Shortcuts
- Reparsing Docstring (switch templating style)
- Command Pallete Commands for changing syntax
- Dynamic completions based on chosen syntax
- Integration back with the original DocBlockr
- Better Syntax Highlighting within docstrings (in particular for other styles)
- Examples of each style to completion
- Documentation (isn't it ironic?)