Skip to content

Commit 59be4e7

Browse files
Document the developement process for Formatter
1 parent 2bd960a commit 59be4e7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ options:
2424
-v, --version Show version number and exit
2525
```
2626

27-
### Confiuguration
27+
### Configuration
2828

2929
Pydocstringformatter will also read any configuration added to the `[tool.pydocstringformatter]` section of a `pyproject.toml` file.
3030

@@ -86,8 +86,17 @@ multi-line docstring
8686

8787
## Development
8888

89+
### Linting
90+
8991
Use `pre-commit install` to install the pre-commit hook for the repository.
9092

93+
### Creating a new formatter
94+
95+
- Implement a Formatter by inheriting from ``pydocstringformatter.formatting.Formatter``
96+
- Add your new formatter to ``pydocstringformatter.formatting.FORMATTERS``
97+
- Create a clear docstring because this will be user-facing: it's what will be seen in the help.
98+
- Choose a proper name because this will be user-facing: the name will be used for option of the CLI.
99+
91100
### Testing
92101

93102
To run all the tests:

pydocstringformatter/formatting/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__all__ = ["FORMATTERS"]
1+
__all__ = ["FORMATTERS", "Formatter"]
22

33
from typing import List
44

pydocstringformatter/formatting/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ class Formatter:
66
"""Base class for docstring formatter"""
77

88
optional = False
9-
name: str
9+
10+
@property
11+
@abc.abstractmethod
12+
def name(self) -> str:
13+
"""Name of the Formatter, chose wisely, this is an API.
14+
15+
This will be used to create argparse options when added to
16+
'pydocstringformatter.formatting.FORMATTERS'.
17+
"""
1018

1119
@abc.abstractmethod
1220
def treat_token(self, tokeninfo: tokenize.TokenInfo) -> tokenize.TokenInfo:

0 commit comments

Comments
 (0)