Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Refactor API into multiple pages #328

Merged
merged 3 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ can specify a custom database destination by passing a database url into

```python
#!/usr/bin/env python
"""Example for bootstrapping UNIHAN DB and print out a row."""
import pprint

from sqlalchemy.sql.expression import func
Expand All @@ -25,13 +26,15 @@ session = bootstrap.get_session()

bootstrap.bootstrap_unihan(session)

random_row = session.query(Unhn).order_by(
func.random()
).limit(1).first()
random_row_query = session.query(Unhn).order_by(func.random()).limit(1)

pp = pprint.PrettyPrinter(indent=0)
assert random_row_query is not None

pp.pprint(random_row.to_dict())
random_row = random_row_query.first()

pprint.pprint(bootstrap.to_dict(random_row))

pprint.pprint(random_row.to_dict()) # type:ignore
```

Run:
Expand Down
18 changes: 0 additions & 18 deletions docs/api.md

This file was deleted.

12 changes: 12 additions & 0 deletions docs/api/bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Bootstrap - `unihan_db.bootstrap`

```{module} unihan_db

```

```{eval-rst}
.. automodule:: unihan_db.bootstrap
:members:
:undoc-members:
:show-inheritance:
```
12 changes: 12 additions & 0 deletions docs/api/importer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Importing - `unihan_db.importer`

```{module} unihan_db

```

```{eval-rst}
.. automodule:: unihan_db.importer
:members:
:undoc-members:
:show-inheritance:
```
22 changes: 22 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(api)=

# API

```{module} unihan_db

```

:::{warning}
Be careful with these! APIs are **not** covered considered stable pre-1.0. They can break or be removed between minor versions!

If you need an internal API stabilized please [file an issue](https://github.com/cihai/unihan-db/issues).
:::

```{toctree}
:caption: API
:maxdepth: 1

bootstrap
importer
tables
```
12 changes: 12 additions & 0 deletions docs/api/tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tables - `unihan_db.tables`

```{module} unihan_db

```

```{eval-rst}
.. automodule:: unihan_db.tables
:members:
:undoc-members:
:show-inheritance:
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:hidden:

quickstart
api
api/index
```

```{toctree}
Expand Down
1 change: 1 addition & 0 deletions docs/redirects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"api.md" "api/index.md"