Skip to content

Commit

Permalink
md toc gen
Browse files Browse the repository at this point in the history
  • Loading branch information
tripott committed Jun 8, 2022
1 parent 6a57447 commit 96d0589
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ black:
python -m black .## Run ci part
.PHONY: ci
ci: lint test
toc:
cat README.md | bash toc.sh 2 2
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
Official hyper <a href="https://docs.hyper.io">documentation</a>.
</p>

- [Install](#install)
- [Usage](#usage)
- [Services and Actions](#services-and-actions)
- [hyper vision 😎](#hyper-vision-😎)
- [Types and type checking](#types-and-type-checking)
- [Sync](#sync)
- [Sync examples](#sync-examples)
- [Async](#async)
- [Async examples](#async-examples)
- [Contributing](#contributing)
- [License](#license)
- [Code of Conduct](#code-of-conduct)
- [Linting](#linting)
- [Tests](#tests)
- [Tag and Release](#tag-and-release)
- [Build](#build)
- [Publishing to TestPyPI](#publishing-to-testpypi)
- [Publishing to PyPI](#publishing-to-pypi)

## Install

Expand Down Expand Up @@ -110,21 +128,6 @@ hyper.[service].[action] - with each service there are a different set of action
![hyper vision cache](./hyper-vision.png)


## Sync

`hyper_connect` supports both synchronous and asynchronous methods for each service type (data, cache, storage, etc.). It's easy to distinguish between the two. Synchronous method names will **not** end in `_async`.

```py
result = hyper.data.add(movie)
```


While asynchronous methods end in `_async`:

```py
result = await hyper.data.add_async(movie)
```

## Types and type checking

Common types you'll encounter include `HYPER`, `ListOptions`, `QueryOptions`, and `SearchQueryOptions`.
Expand Down Expand Up @@ -174,6 +177,21 @@ also_valid_options: ListOptions = {
}
```

## Sync

`hyper_connect` supports both synchronous and asynchronous methods for each service type (data, cache, storage, etc.). It's easy to distinguish between the two. Synchronous method names will **not** end in `_async`.

```py
result = hyper.data.add(movie)
```


While asynchronous methods end in `_async`:

```py
result = await hyper.data.add_async(movie)
```

## Sync examples

[examples.py](./examples.py) contains some simple synchronous examples. This repository's **tests* folder also contains some illustrative integration tests.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hyper_connect"
version = "0.0.4"
version = "0.0.5"
description = "python SDK package for hyper"
authors = ["Trip Ottinger"]
license = "Apache 2.0"
Expand Down
11 changes: 11 additions & 0 deletions toc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# It will read the input and:
#
# 1. Extract only the headers via grep (using $1 and $2 as first and last heading level)
# 2. Extract the header text via sed and created ':' separated records of the form '###:Full Text:Full Text'
# 3. Compose each TOC line via awk by replacing '#' with ' ' and stripping spaces and caps of reference

grep -E "^#{${1:-1},${2:-2}} " | \
sed -E 's/(#+) (.+)/\1:\2:\2/g' | \
awk -F ":" '{ gsub(/#/," ",$1); gsub(/[ ]/,"-",$3); print $1 "- [" $2 "](#" tolower($3) ")" }'

0 comments on commit 96d0589

Please sign in to comment.