Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

from typing import Dict 

from textwrap import indent 

 

from ..labels import BRANCH_TYPES, BRANCH_TYPE_OTHER 

from .base import BaseRenderer 

 

__author__ = 'Artur Barseghyan' 

__copyright__ = '2019 Artur Barseghyan' 

__license__ = 'GPL-2.0-only OR LGPL-2.0-or-later' 

__all__ = ( 

'RestructuredTextRenderer', 

) 

 

 

class RestructuredTextRenderer(BaseRenderer): 

 

uid: str = 'rest' 

 

def append_release(self, release_label: str): 

self.changelog.append( 

"\n{}\n{}".format( 

release_label, 

"-" * len(release_label) 

) 

) 

 

def append_feature_type(self, branch_type: str): 

branch_type_label = BRANCH_TYPES.get(branch_type) 

self.changelog.append( 

"\n{}\n{}{}".format( 

branch_type_label, 

"~" * len(branch_type_label), 

'\n' if branch_type == BRANCH_TYPE_OTHER else '' 

) 

) 

 

def append_ticket_title(self, ticket_number: str, ticket_title: str): 

ticket_title_label = "{} {}".format(ticket_number, ticket_title) 

self.changelog.append( 

"\n{}\n{}".format( 

ticket_title_label, 

"^" * len(ticket_title_label) 

) 

) 

 

def append_ticket_description(self, ticket_description: str): 

self.changelog.append( 

"\n.. code-block: text\n\n{}".format( 

indent(ticket_description.strip(), " ") 

) 

) 

 

def append_commit_message(self, 

commit_data: Dict[str, str], 

branch_type: str, 

counter: int = 0): 

self.changelog.append( 

"{}- {} [{}]".format( 

( 

'\n' 

if counter == 0 and branch_type != BRANCH_TYPE_OTHER 

else '' 

), 

commit_data['title'], 

commit_data['author'] 

) 

)