Skip to content

Commit

Permalink
👷 Move documentation build to a separate repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Krupinski committed Jun 4, 2024
1 parent 9bb4a9d commit 80a9175
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 154 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/mkdocs.yaml

This file was deleted.

73 changes: 2 additions & 71 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,8 @@
[![test](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml/badge.svg)](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml)

# Lapidary

[![test](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml/badge.svg)](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml)

Python DSL for Web API clients.

Also check [lapidary-render](https://github.com/python-lapidary/lapidary-render/),
a command line program that generates Lapidary clients from OpenAPI.

## Features

- [x] Write Web API clients declaratively
- [x] Use pydantic models for JSON data
- [ ] Compatibility with OpenAPI 3.0 and 3.1

## Installation

```console
pip install lapidary
```

or with Poetry

```console
poetry add lapidary
```

## Usage

With Lapidary, you define an API client by creating a class that mirrors the API structure, akin to OpenAPI but through
decorated and annotated Python methods. Calling these method handles making HTTP requests and transforming the responses
back into Python objects.

```python
from typing import Annotated, Self
from lapidary.runtime import *

# Define models

class Cat(ModelBase):
id: int
name: str

# Declare the client

class CatClient(ClientBase):
def __init__(
self,
base_url='http://localhost:8080/api',
):
super().__init__(base_url=base_url)

@get('/cat/{id}')
async def cat_get(
self: Self,
*,
id: Annotated[int, Path(style=ParamStyle.simple)],
) -> Annotated[Cat, Responses({
'2XX': {
'application/json': Cat
},
})]:
pass

# User code

async def main():
client = CatClient()
cat = await client.cat_get(id=7)
```

See [this test file](https://github.com/python-lapidary/lapidary/blob/develop/tests/test_client.py) for a working
example.

[Full documentation](https://lapidary.dev)

Also check the [library of clients](https://github.com/orgs/lapidary-library/repositories).
34 changes: 5 additions & 29 deletions config/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
site_name: Lapidary
site_description: Build Web API clients with python annotations
copyright: © 2024 Rafał Krupiński
site_name: Lapidary runtime
repo_url: https://github.com/python-lapidary/lapidary
repo_name: python-lapidary/lapidary
edit_uri: ''

docs_dir: ../docs
site_dir: ../site
site_url: https://lapidary.dev/

nav:
- Lapidary: index.md
- index.md
- Usage:
- usage/client.md
- usage/operation.md
- usage/auth.md
- Reference:
- reference/lapidary.md

plugins:
- mkdocstrings:
handlers:
python:
paths:
- ../src
- src
options:
docstring_style: sphinx

theme:
name: material
logo: logo.svg
favicon: logo.png
language: en
features:
- navigation.instant
- navigation.sections
plugins:
- privacy
custom_dir: theme
markdown_extensions:
- admonition
- tables
- pymdownx.tasklist

extra:
analytics:
provider: goatcounter
code: lapidary
2 changes: 0 additions & 2 deletions config/theme/partials/integrations/analytics/goatcounter.html

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.md

This file was deleted.

72 changes: 72 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Lapidary

Python DSL for Web API clients.

## Features

- [x] Write Web API clients declaratively
- [x] Use pydantic models for JSON data
- [ ] Compatibility with OpenAPI 3.0 and 3.1

## Installation

```console
pip install lapidary
```

or with Poetry

```console
poetry add lapidary
```

## Usage

With Lapidary, you define an API client by creating a class that mirrors the API structure, akin to OpenAPI but through
decorated and annotated Python methods. Calling these method handles making HTTP requests and transforming the responses
back into Python objects.

```python
from typing import Annotated, Self
from lapidary.runtime import *

# Define models

class Cat(ModelBase):
id: int
name: str

# Declare the client

class CatClient(ClientBase):
def __init__(
self,
base_url='http://localhost:8080/api',
):
super().__init__(base_url=base_url)

@get('/cat/{id}')
async def cat_get(
self: Self,
*,
id: Annotated[int, Path(style=ParamStyle.simple)],
) -> Annotated[Cat, Responses({
'2XX': {
'application/json': Cat
},
})]:
pass

# User code

async def main():
client = CatClient()
cat = await client.cat_get(id=7)
```

See [this test file](https://github.com/python-lapidary/lapidary/blob/develop/tests/test_client.py) for a working
example.

[Full documentation](https://lapidary.dev)

Also check the [library of clients](https://github.com/orgs/lapidary-library/repositories).
Binary file removed docs/logo.png
Binary file not shown.
18 changes: 0 additions & 18 deletions docs/logo.svg

This file was deleted.

3 changes: 3 additions & 0 deletions docs/reference/lapidary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Lapidary Reference

::: lapidary.runtime

0 comments on commit 80a9175

Please sign in to comment.