Skip to content

Commit

Permalink
chore(docs): fixing docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
elhoangvu committed May 3, 2024
1 parent bf37418 commit 91c4b88
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 61 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Building `Context` with `CommentRule.ContextCase` to define the comment style.
```python
>>> context = build_singleline_context("#")
>>> dictrule.Generator({
... "comment": "This is a single-line comment"
... "comment": "This is a single-line comment",
... }).generate(context)
# This is a single-line comment

Expand Down Expand Up @@ -177,13 +177,13 @@ This rule evaluates the value of provied variable or command.
```python
>>> git_author = "Zooxy Le"
>>> dictrule.Generator({
... "eval": "git_author"
... "eval": "git_author",
... }).generate()
Zooxy Le

>>> project_id = "123456789"
>>> dictrule.Generator({
... "eval": "project_id"
... "eval": "project_id",
... }).generate()
123456789
```
Expand All @@ -208,11 +208,11 @@ Requires providing a `Context` that includes the necessary information for the r
... Line(content="This is the line_2 content"),
... ])
>>> dictrule.Generator({
... "for": "line"
... "in": "saved_lines"
... "for": "line",
... "in": "saved_lines",
... "block: [
... "line.index",
... "line.content"
... "line.content",
... ]
... }).generate()
1
Expand All @@ -235,9 +235,9 @@ This rule formats text according to specified rules. This rule now supports the

```python
>>> dictrule.Generator({
... "format_lowercase": "UPPERCASE TITLE"
... "format_uppercase": "lowercase content"
... "format_upper_head": "camelVariable"
... "format_lowercase": "UPPERCASE TITLE",
... "format_uppercase": "lowercase content",
... "format_upper_head": "camelVariable",
... }).generated()
uppercase title
LOWERCASE CONTENT
Expand All @@ -259,9 +259,9 @@ Defines the number of spaces for text indentation by providing `IndentRule.Conte
```python
>>> context = build_number_spaces_context(4)
>>> dictrule.Generator({
... "class Menu:"
... "indent_1": "def content(self):"
... "indent_2": "return 'Empty'"
... "class Menu:",
... "indent_1": "def content(self):",
... "indent_2": "return 'Empty'",
... }).generate(context)
class Menu:
def content(self):
Expand All @@ -280,7 +280,7 @@ This rule builds generated text of a list of rules that are in a line.

```python
>>> dictrule.Generator({
... "inline": ["This", " is", " the", " text", " in", " a", " line"]
... "inline": ["This", " is", " the", " text", " in", " a", " line"],
... }).generate()
This is the text in a line
```
Expand All @@ -298,8 +298,8 @@ This rule joins generated texts for a block of rules by a specified separator.

```python
>>> dictrule.Generator({
... "join": "-"
... "block": ["This", "is", "the", "snake", "line"]
... "join": "-",
... "block": ["This", "is", "the", "snake", "line"],
... }).generate()
This-is-the-snake-line
```
Expand All @@ -326,8 +326,8 @@ This rule joins generated texts from the value of `EvalRule` by a specified sepa
... "AC Milan",
... ])
>>> dictrule.Generator({
... "join": ", "
... "eval": "football_teams"
... "join": ", ",
... "eval": "football_teams",
... }).generate(context)
Real Madrid, Barcelona, Bayern Munchen, PSG, MC, MU, AC Milan
```
Expand All @@ -344,8 +344,8 @@ This rule wraps content by quotes.

```python
>>> dictrule.Generator({
... "stringify": "This is the 1st text"
... "stringify": "This is the 2nd text"
... "stringify": "This is the 1st text",
... "stringify": "This is the 2nd text",
... }).generate()
"This is the 1st text"
"This is the 2nd text"
Expand Down
15 changes: 7 additions & 8 deletions src/dictrule/built_in_rules/comment_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ..exceptions import (
NoneValueException,
InvalidTypeException,
InvalidValueException,
)


Expand Down Expand Up @@ -99,7 +98,7 @@ def style() -> "CommentRule.Style":

@property
def prefix(self) -> str:
"""Getter for `prefix` property"""
"""Get the `prefix` property"""

return self._prefix

Expand Down Expand Up @@ -131,25 +130,25 @@ def style() -> "CommentRule.Style":

@property
def prefix(self) -> str:
"""Getter for `prefix` property"""
"""Get the `prefix` property"""

return self._prefix

@property
def open_comment(self) -> str:
"""Getter for `open_comment` property"""
"""Get the `open_comment` property"""

return self._open_comment

@property
def close_comment(self) -> str:
"""Getter for `close_comment` property"""
"""Get the `close_comment` property"""

return self._close_comment

@property
def name(self) -> str:
"""Getter for `name` property"""
"""Get the `name` property"""

return CommentRule.CONTEXT_NAME

Expand All @@ -172,13 +171,13 @@ def __init__(

@property
def singleline(self) -> SinglelineComment:
"""Getter for `singleline` property"""
"""Get the `singleline` property"""

return self._singleline

@property
def multiline(self) -> MultilineComment:
"""Getter for `multiline` property"""
"""Get the `multiline` property"""

return self._multiline

Expand Down
12 changes: 6 additions & 6 deletions src/dictrule/built_in_rules/eval_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class EvalRule(Rule):
---------
>>> git_author = "Zooxy Le"
>>> dictrule.Generator({
... "eval": "git_author"
... "eval": "git_author",
... }).generate()
Zooxy Le
>>> project_id = "123456789"
>>> dictrule.Generator({
... "eval": "project_id"
... "eval": "project_id",
... }).generate()
123456789
"""
Expand Down Expand Up @@ -117,19 +117,19 @@ class ContextCase(Context.Case):

@property
def name(self) -> str:
"""Getter for `name` property"""
"""Get the `name` property"""

return EvalRule.CONTEXT_NAME

@property
def evaluator_list(self) -> List["EvalRule.Evaluable"]:
"""Getter for `evaluator_list` property"""
"""Get the `evaluator_list` property"""

return self._evaluator_list

@property
def fallback(self) -> Optional["EvalRule.Evaluable"]:
"""Getter for `fallback` property"""
"""Get the `fallback` property"""

return self._fallback

Expand All @@ -138,7 +138,7 @@ def __init__(
evaluators: List["EvalRule.Evaluable"],
fallback: Optional["EvalRule.Evaluable"] = None,
):
"""Initialization method for `EvalRule.ContextCase`.
"""Constructor method for `EvalRule.ContextCase`.
Args:
evaluators (List["EvalRule.Evaluable"]): List of evaluators.
Expand Down
10 changes: 5 additions & 5 deletions src/dictrule/built_in_rules/for_in_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class ForInRule(Rule):
... Line(content="This is the line_2 content"),
... ])
>>> dictrule.Generator({
... "for": "line"
... "in": "saved_lines"
... "for": "line",
... "in": "saved_lines",
... "block: [
... "line.index",
... "line.content"
... "line.content",
... ]
... }).generate()
1
Expand Down Expand Up @@ -87,13 +87,13 @@ class ForInEval(EvalRule.Evaluable):

@property
def name(self) -> str:
"""Getter for `name` property"""
"""Get the `name` property"""

return self._var_name

@property
def prefix_matching(self) -> bool:
"""Getter for `prefix_matching` property"""
"""Get the `prefix_matching` property"""

return True

Expand Down
6 changes: 3 additions & 3 deletions src/dictrule/built_in_rules/format_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class FormatRule(Rule):
Examples:
---------
>>> dictrule.Generator({
... "format_lowercase": "UPPERCASE TITLE"
... "format_uppercase": "lowercase content"
... "format_upper_head": "camelVariable"
... "format_lowercase": "UPPERCASE TITLE",
... "format_uppercase": "lowercase content",
... "format_upper_head": "camelVariable",
... }).generated()
uppercase title
LOWERCASE CONTENT
Expand Down
10 changes: 5 additions & 5 deletions src/dictrule/built_in_rules/indent_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class IndentRule(Rule):
---------
>>> context = build_number_spaces_context(4)
>>> dictrule.Generator({
... "class Menu:"
... "indent_1": "def content(self):"
... "indent_2": "return 'Empty'"
... "class Menu:",
... "indent_1": "def content(self):",
... "indent_2": "return 'Empty'",
... }).generate(context)
class Menu:
def content(self):
Expand All @@ -44,7 +44,7 @@ class ContextCase(Context.Case):

@property
def name(self) -> str:
"""Getter for `name` property"""
"""Get the `name` property"""

return "indent"

Expand All @@ -62,7 +62,7 @@ def __init__(

@property
def num_spaces(self) -> int:
"""Getter for `num_spaces` property"""
"""Get the `num_spaces` property"""

return self._num_spaces

Expand Down
2 changes: 1 addition & 1 deletion src/dictrule/built_in_rules/inline_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InlineRule(Rule):
Examples:
---------
>>> dictrule.Generator({
... "inline": ["This", " is", " the", " text", " in", " a", " line"]
... "inline": ["This", " is", " the", " text", " in", " a", " line"],
... }).generate()
This is the text in a line
"""
Expand Down
4 changes: 2 additions & 2 deletions src/dictrule/built_in_rules/join_block_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class JoinBlockRule(BlockRule):
Examples:
---------
>>> dictrule.Generator({
... "join": "-"
... "block": ["This", "is", "the", "snake", "line"]
... "join": "-",
... "block": ["This", "is", "the", "snake", "line"],
... }).generate()
This-is-the-snake-line
"""
Expand Down
4 changes: 2 additions & 2 deletions src/dictrule/built_in_rules/join_eval_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class JoinEvalRule(EvalRule):
... "AC Milan",
... ])
>>> dictrule.Generator({
... "join": ", "
... "eval": "football_teams"
... "join": ", ",
... "eval": "football_teams",
... }).generate(context)
Real Madrid, Barcelona, Bayern Munchen, PSG, MC, MU, AC Milan
"""
Expand Down
4 changes: 2 additions & 2 deletions src/dictrule/built_in_rules/stringify_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class StringifyRule(Rule):
Examples:
---------
>>> dictrule.Generator({
... "stringify": "This is the 1st text"
... "stringify": "This is the 2nd text"
... "stringify": "This is the 1st text",
... "stringify": "This is the 2nd text",
... }).generate()
"This is the 1st text"
"This is the 2nd text"
Expand Down
8 changes: 4 additions & 4 deletions src/dictrule/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Case(ABC):

@property
def name(self) -> str:
"""Getter for case name, matching the defined rule
"""Get the case name, matching the defined rule
Returns:
str: A rule name
Expand All @@ -35,7 +35,7 @@ def __init__(
self,
cases: List[Case],
) -> None:
"""Initialization method of `Context` class
"""Constructor method of `Context` class
Args:
cases (List[Case]): List of `Context.Case` to build the case map
Expand All @@ -55,7 +55,7 @@ def __init__(

@property
def cases(self) -> List[Case]:
"""Getter for `cases` property
"""Get the `cases` property
Returns:
List[Case]: list of cases
Expand All @@ -64,7 +64,7 @@ def cases(self) -> List[Case]:

@property
def case_map(self) -> Dict[str, Case]:
"""Getter for `case_map` property
"""Get the `case_map` property
Returns:
Dict[str, Case]: map of cases [name: str, case: Context.Case]
Expand Down
2 changes: 1 addition & 1 deletion src/dictrule/dr_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
optional: bool = False,
prefix_matching: bool = False,
):
"""Initialization method of `dr_property`
"""Constructor method of `dr_property`
Args:
optional (bool, optional): Indicates if the property is optional
Expand Down
Loading

0 comments on commit 91c4b88

Please sign in to comment.