Skip to content

Commit

Permalink
Added Paperbush.from_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
trag1c committed Feb 16, 2023
1 parent 04d62ba commit e5965da
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ Creates a Paperbush parser from an iterable of patterns.
assert a == b
```

## Paperbush.from_mapping
```py
Paperbush.from_mapping(
mapping: Mapping[str, str],
*values: Any,
infer_names: bool = True
)
```
Creates a Paperbush parser from a mapping, where keys are patterns and values
are help messages.

=== "argparse"

```py
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument("x", type=int, help="the base")
parser.add_argument("y", type=int, help="the exponent")
```

=== "Paperbush"

```py
from paperbush import Paperbush

parser = Paperbush.from_mapping({
"x:int": "the base",
"y:int": "the exponent"
})
```

## Paperbush.parse

```py
Expand Down

0 comments on commit e5965da

Please sign in to comment.