Skip to content

Commit

Permalink
Add documentation for converters
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jan 12, 2019
1 parent 64943b8 commit 8f075e7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Demo: [Jupyter Notebook](https://github.com/jacebrowning/datafiles/blob/develop/

## Installation

Because datafiles relies on dataclasses and type annotations, Python 3.7+ is required. Install it directly into an activated virtual environment:
Because datafiles relies on dataclasses and type annotations, Python 3.7+ is required. Install this library directly into an activated virtual environment:

```
$ pip install datafiles
Expand Down
65 changes: 65 additions & 0 deletions docs/types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Builtin Types

## Booleans

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: bool` | `foobar = True` | `foobar: true` |
| `foobar: bool` | `foobar = False` | `foobar: false` |
| `foobar: bool` | `foobar = None` | `foobar: false` |
| `foobar: Optional[bool]` | `foobar = False` | `foobar: null` |

## Integers

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: int` | `foobar = 42` | `foobar: 42` |
| `foobar: int` | `foobar = 1.23` | `foobar: 1` |
| `foobar: int` | `foobar = None` | `foobar: 0` |
| `foobar: Optional[int]` | `foobar = None` | `foobar: null` |

## Floats

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: float` | `foobar = 1.23` | `foobar: 1.23` |
| `foobar: float` | `foobar = 42` | `foobar: 42.0` |
| `foobar: float` | `foobar = None` | `foobar: 0.0` |
| `foobar: Optional[float]` | `foobar = None` | `foobar: null` |

## Strings

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: str` | `foobar = "Hello, world!"` | `foobar: Hello, world!` |
| `foobar: str` | `foobar = 42` | `foobar: '42'` |
| `foobar: str` | `foobar = None` | `foobar: ''` |
| `foobar: Optional[str]` | `foobar = None` | `foobar: null` |

# Extended Types

## Numbers

```python
from datafiles.converters import Number
```

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: Number` | `foobar = 42` | `foobar: 42` |
| `foobar: Number` | `foobar = 1.23` | `foobar: 1.23` |
| `foobar: Number` | `foobar = None` | `foobar: 0.0` |
| `foobar: Optional[Number]` | `foobar = None` | `foobar: null` |

## Text

```python
from datafiles.converters import Text
```

| Type Annotation | Python Value | YAML Data |
| --- | --- | --- |
| `foobar: str` | `foobar = "Hello, world!"` | `foobar: Hello, world!` |
| `foobar: str` | `foobar = "First\nSecond\n"` | `foobar: | `<br>&nbsp;&nbsp;&nbsp;&nbsp;`First`<br>&nbsp;&nbsp;&nbsp;&nbsp;`Second` |
| `foobar: str` | `foobar = None` | `foobar: ''` |
| `foobar: Optional[str]` | `foobar = None` | `foobar: null` |
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ theme: readthedocs

nav:
- Home: index.md
- Types: types.md
- About:
- Release Notes: about/changelog.md
- Contributing: about/contributing.md
Expand Down

0 comments on commit 8f075e7

Please sign in to comment.