Skip to content

Commit

Permalink
Final examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bleudev committed Jun 4, 2024
1 parent 364685c commit e4d4f0f
Showing 1 changed file with 69 additions and 3 deletions.
72 changes: 69 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class A:

## ✅ Tests rules

When you create new class for library you should add tests. All tests must be Unittests and
contains all public features of class.
When you create new class for library you should add tests. All tests must be Unittests,
be in `tests` directory and contains all public features of class.
[How to write unittest?](https://realpython.com/python-testing/#how-to-structure-a-simple-test)

Example of test for UDict class:
Expand All @@ -93,4 +93,70 @@ class UDictTestCase(unittest.TestCase):

## 📺 Examples rules

...
When you create new class for library you also should add examples. All examples must be
`markdown` files, be in `examples` directory and contains all general public features of class.

Example of example:
```markdown
# UDict

## Introduction

UDict is class which is simplifying working with Python dicts.
It has many methods, properties, magic methods.

Firstly, import `UDict` from `ufpy`
```python
from ufpy import UDict
```

## Create UDict

For creating UDict you should use this code:
```python
d = UDict({'id': 2, 'content': 'hello, world'})
# for string keys you can use this way:
d = UDict(id=2, content='hello, world')
```

You can also define `default` value for items when you use item's getter:
```python
d = UDict(id=2, content='hello, world', default=0)
```

## Get items

For getting items you should use the way you use in lists and dicts:
use `UDict[key]` syntax:
```python
d['id'] # 2
```
```

### Cautions and notes

Also, you can use cautions and notes in your examples.

#### Caution

Code:
```markdown
> [!CAUTION]
> This is caution!
```

How it's looking:
> [!CAUTION]
> This is caution!
#### Note

Code:
```markdown
> [!NOTE]
> This is caution!
```

How it's looking:
> [!NOTE]
> This is caution!

0 comments on commit e4d4f0f

Please sign in to comment.