|
1 | 1 | DocBlockr for Python
|
2 | 2 | ====================
|
3 | 3 | Based off the [DocBlockr](https://github.com/spadgos/sublime-jsdocs) project, This extension provides the similar funtionality but for python docstrings.
|
4 |
| -This plugin is designed around [PEP-257](https://www.python.org/dev/peps/pep-0257/) compliance and takes from [Google's styleguide](https://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments). |
| 4 | +The default formatter for this plugin is designed around [PEP-257](https://www.python.org/dev/peps/pep-0257/) compliance but with more verbosity: Added variable types, listing class extensions, and listing decorators. |
5 | 5 | The main goal of this project is to help developer provide better documentation by giving easy and consistent formatting.
|
6 | 6 |
|
| 7 | + |
7 | 8 | Installation
|
8 | 9 | ------------
|
9 |
| -Manually |
10 |
| -1. Go to the [Latest Release](https://github.com/adambullmer/sublime-docblockr-python/releases/latest) and download the `DocString.Python.sublime-package` file. |
11 |
| -2. Move this file to your `Installed Packages` directory. (`Preferences > Browse Packages...` and go up one directory to see `Installed Packages`) |
| 10 | +**Manually** |
| 11 | +Until this project can get onto Package Control, the only way to install it is manually. |
| 12 | +1. Go to the [Latest Release](https://github.com/adambullmer/sublime-docblockr-python/releases/latest) and download the `docblockr_python.sublime-package` file. |
| 13 | +1. Move this file to your `Installed Packages` directory. (`Preferences > Browse Packages...` and go up one directory to see `Installed Packages`) |
| 14 | +1. If you are updating your existing install, a restart of Sublime Text will be in order. |
| 15 | + |
12 | 16 |
|
13 | 17 | Usage
|
14 | 18 | -----
|
15 |
| -There isn't a key command to start this plugin, it is triggerg by hitting **enter** or **tab** after opening a docstring (`"""`) at the `module`, `class`, or `function` level. |
| 19 | +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. |
| 20 | +If you wanted to simply put a new line after opening a docstring and not trigger the formatter, just hold `ctrl` and press enter. |
| 21 | + |
| 22 | + |
| 23 | +Settings |
| 24 | +-------- |
| 25 | +You can configure which docstring format to use by updating your user settings for this package. (`Preferences > Package Settings > DocBlockr Python > Settings (User)`) |
| 26 | +For a full list of settings with documentation on what they affect, look at the `Settings (Default)` file. |
| 27 | +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. |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "DocblockrPython": { |
| 32 | + "formatter": "sphinx" |
| 33 | + }, |
| 34 | + "folders": [ |
| 35 | + //... |
| 36 | + ] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | + |
| 41 | +Supported Docstring Styles |
| 42 | +-------------------------- |
| 43 | +- Docblockr (PEP0257 with types) |
| 44 | +- [PEP0257](https://www.python.org/dev/peps/pep-0257/) |
| 45 | +- [Google](https://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments) |
| 46 | +- [Numpy](https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt) |
| 47 | +- [Sphinx (reST)](https://pythonhosted.org/an_example_pypi_project/sphinx.html) |
| 48 | + |
| 49 | + |
| 50 | +Extendability |
| 51 | +------------- |
| 52 | +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. |
| 53 | +All you will need to do is extend the [Base formatter](https://github.com/adambullmer/sublime-docblockr-python/blob/master/formatters/base.py#L32) class and write your formatter functions. |
| 54 | +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. |
| 55 | +```py |
| 56 | +from docblockr_python.formatters.base import Base |
| 57 | + |
| 58 | + |
| 59 | +class MyFormatter(Base): |
| 60 | + # This will be used as your settings file value, |
| 61 | + # and how the formatter is registered in the registry |
| 62 | + name = 'my' |
| 63 | +``` |
| 64 | + |
| 65 | +**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 |
| 66 | +to make sure you understand all the caveats of each formatter function. |
16 | 67 |
|
17 | 68 |
|
18 | 69 | Known Issues
|
19 | 70 | ------------
|
20 | 71 | - 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
|
21 | 72 |
|
| 73 | + |
22 | 74 | Roadmap
|
23 | 75 | -------
|
24 |
| -- Process module or class variables |
25 |
| -- Process Decorators |
26 |
| -- Determine / Guess at variable and return value types |
27 |
| -- `Raises` section of documentation |
28 |
| -- `Decorators` section of documentation |
| 76 | +Things I want to do wtih this project. Not necessarily an exhaustive or prioritized list. |
| 77 | + |
29 | 78 | - Unit Tests!
|
30 | 79 | - More completions!
|
31 |
| -- Better README |
| 80 | +- Javadoc style formatter |
| 81 | +- Keyboard Shortcuts |
| 82 | +- Reparsing Docstring (switch templating style) |
| 83 | +- Command Pallete Commands for changing syntax |
| 84 | +- Dynamic completions based on chosen syntax |
| 85 | +- Integration back with the original DocBlockr |
| 86 | +- Better Syntax Highlighting within docstrings (in particular for other styles) |
| 87 | +- Examples of each style to completion |
| 88 | +- Documentation (isn't it ironic?) |
0 commit comments