fix and complete unittest
update documentation: samples + custom formaters
This commit is contained in:
@@ -42,30 +42,170 @@ From master git repository:
|
||||
|
||||
### Sample code
|
||||
``` py
|
||||
from pychangelogfactory import ChangeLogFormater
|
||||
from pychangelogfactory import ChangeLogFactory
|
||||
|
||||
raw_changelog='''
|
||||
feat: add a nice feature to the project
|
||||
style: reindent the full Foo class
|
||||
security: fix a security leak on the Foo2 component
|
||||
'''
|
||||
ChangeLogFormater.FactoryProcessFullChangelog(raw_changelog)
|
||||
changelog = ChangeLogFormater.RenderFullChangelog()
|
||||
raw_changelog = (
|
||||
"feat: add a nice feature to the project\n"
|
||||
"style: reindent the full Foo class\n"
|
||||
"security: fix a security issue on the Foo2 component\n"
|
||||
"security: fix another security problem on the Foo2 component\n"
|
||||
"improve core performances by reducing complexity\n"
|
||||
"some random changes in the text content\n"
|
||||
)
|
||||
hdlr = ChangeLogFactory()
|
||||
hdlr.ProcessFullChangelog(self.raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
print(changelog)
|
||||
```
|
||||
|
||||
#### Or shorted version:
|
||||
|
||||
``` py
|
||||
hdlr = ChangeLogFactory(self.raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
```
|
||||
#### Or one-liner version:
|
||||
|
||||
``` py
|
||||
changelog = ChangeLogFactory(self.raw_changelog).RenderFullChangelog()
|
||||
```
|
||||
|
||||
### Output(Raw)
|
||||
|
||||
#### Features :sparkles::
|
||||
#### Features :sparkles: :
|
||||
> add a nice feature to the project
|
||||
#### Security :shield::
|
||||
> fix a security leak on the Foo2 component
|
||||
#### Style :art::
|
||||
#### Security :shield: :
|
||||
> security: fix a security issue on the Foo2 component
|
||||
> security: fix another security problem on the Foo2 component
|
||||
#### Performance Enhancements :rocket: :
|
||||
> improve core performances by reducing complexity
|
||||
#### Style :art: :
|
||||
> reindent the full Foo class
|
||||
|
||||
### Output (rendered)
|
||||
#### Features :sparkles: :
|
||||
> add a nice feature to the project
|
||||
#### Security :shield: :
|
||||
> security: fix a security issue on the Foo2 component
|
||||
|
||||
> security: fix another security problem on the Foo2 component
|
||||
#### Performance Enhancements :rocket: :
|
||||
> improve core performances by reducing complexity
|
||||
#### Style :art: :
|
||||
> reindent the full Foo class
|
||||
|
||||
### Options
|
||||
#### Display unknown messages types
|
||||
``` py
|
||||
from pychangelogfactory import ChangeLogFormater
|
||||
|
||||
raw_changelog = (
|
||||
"feat: add a nice feature to the project\n"
|
||||
"style: reindent the full Foo class\n"
|
||||
"security: fix a security issue on the Foo2 component\n"
|
||||
"security: fix another security problem on the Foo2 component\n"
|
||||
"improve core performances by reducing complexity\n"
|
||||
"some random changes in the text content\n"
|
||||
)
|
||||
changelog = ChangeLogFactory(self.raw_changelog).RenderFullChangelog(include_unknown=True)
|
||||
print(changelog)
|
||||
```
|
||||
### Output (rendered)
|
||||
#### Features :sparkles::
|
||||
> add a nice feature to the project
|
||||
#### Security :shield::
|
||||
> fix a security leak on the Foo2 component
|
||||
> fix a security issue on the Foo2 component
|
||||
> fix another security problem on the Foo2 component
|
||||
#### Performance Enhancements :rocket::
|
||||
> improve core performances by reducing complexity
|
||||
#### Style :art::
|
||||
> reindent the full Foo class
|
||||
> reindent the full Foo class
|
||||
#### Others :question::
|
||||
> some random changes in the text content
|
||||
|
||||
## Supported types
|
||||
|
||||
| Type/Tag | Priority | Keywords | Title |
|
||||
|-----------|----------|----------------------------------------|-------------------------------------------------------|
|
||||
| break | 20 | break | :rotating_light: Breaking changes :rotating_light: : |
|
||||
| feat | 20 | feat, new, create, add | Features :sparkles: : |
|
||||
| fix | 0 | fix, issue, problem | Fixes :wrench: : |
|
||||
| security | 20 | safe, leak | Security :shield: : |
|
||||
| chore | 10 | task, refactor, build, better, improve | Chore :building_construction: : |
|
||||
| perf | 15 | fast, perf | Performance Enhancements :rocket: : |
|
||||
| wip | 0 | temp | Work in progress changes :construction: : |
|
||||
| doc | 0 | doc, manual | Documentations :book: : |
|
||||
| style | 5 | beautify | Style :art: : |
|
||||
| refactor | 0 | | Refactorings :recycle: : |
|
||||
| ci | 0 | jenkins, git | Continuous Integration :cyclone: : |
|
||||
| test | -5 | unittest, check, testing | Testings :vertical_traffic_light: : |
|
||||
| build | 0 | compile, version | Builds :package: : |
|
||||
| revert | 0 | revert, fallback | Reverts :back: : |
|
||||
| other | -20 | | Others :question: : |
|
||||
|
||||
## Add new types
|
||||
|
||||
New formaters can be easily added by subclassing `ChangeLogFormater`:
|
||||
|
||||
### Inject custom formater locally (prefered way)
|
||||
|
||||
``` py
|
||||
from pychangelogfactory import ChangeLogFormater,ChangeLogFactory
|
||||
|
||||
class ChangeLogFormater_others(ChangeLogFormater):
|
||||
"""My formater"""
|
||||
|
||||
prefix: str = "mytag"
|
||||
title: str = "My Title :"
|
||||
keywords: list[str] = ["foo","42"]
|
||||
priority: int = 10
|
||||
|
||||
hdlr = ChangeLogFactory()
|
||||
hdlr.RegisterFormater(ChangeLogFormater_others)
|
||||
...
|
||||
```
|
||||
|
||||
### Inject custom formater module-wide
|
||||
|
||||
``` py
|
||||
from pychangelogfactory import ChangeLogFormater,ChangeLogFormaterRecordType
|
||||
|
||||
@ChangeLogFormaterRecordType
|
||||
class ChangeLogFormater_others(ChangeLogFormater):
|
||||
"""My formater"""
|
||||
|
||||
prefix: str = "mytag"
|
||||
title: str = "My Title :"
|
||||
keywords: list[str] = ["foo","42"]
|
||||
priority: int = 10
|
||||
|
||||
hdlr = ChangeLogFactory()
|
||||
...
|
||||
```
|
||||
|
||||
/// note | Scope
|
||||
This will register your new formater for all next new factories
|
||||
///
|
||||
### Test
|
||||
|
||||
``` py
|
||||
raw_changelog = ("mytag: add a nice feature to the project\n"
|
||||
"foo modification in my file\n"
|
||||
"need 42 coffee\n"
|
||||
)
|
||||
hdlr = ChangeLogFactory(raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog(include_unknown=True)
|
||||
print(changelog)
|
||||
```
|
||||
|
||||
### Output
|
||||
#### My Title :
|
||||
> add a nice feature to the project
|
||||
|
||||
> foo modification in my file
|
||||
|
||||
> need 42 coffee
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user