Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Commit 2e20777

Browse files
authored
sync with pybind/cmake_example; update docs (#15)
* update, fix * update docs * fix version
1 parent b97efd8 commit 2e20777

12 files changed

Lines changed: 174 additions & 106 deletions

File tree

.pre-commit-config.yaml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
repos:
2020
# Standard hooks
2121
- repo: https://github.com/pre-commit/pre-commit-hooks
22-
rev: v4.1.0
22+
rev: v4.4.0
2323
hooks:
2424
- id: check-added-large-files
2525
- id: check-case-conflict
@@ -32,41 +32,36 @@ repos:
3232
- id: mixed-line-ending
3333
- id: requirements-txt-fixer
3434
- id: trailing-whitespace
35-
- id: end-of-file-fixer
3635

3736
# Black, the code formatter, natively supports pre-commit
3837
- repo: https://github.com/psf/black
39-
rev: 22.3.0
38+
rev: 23.1.0
4039
hooks:
4140
- id: black
4241
exclude: ^(docs)
4342

44-
# Sort your imports in a standard form
45-
- repo: https://github.com/PyCQA/isort
46-
rev: 5.11.5
43+
- repo: https://github.com/charliermarsh/ruff-pre-commit
44+
rev: "v0.0.254"
4745
hooks:
48-
- id: isort
46+
- id: ruff
47+
args: ["--fix", "--show-fixes"]
4948

50-
# Upgrade older Python syntax
51-
- repo: https://github.com/asottile/pyupgrade
52-
rev: v2.31.1
49+
# Checking static types
50+
- repo: https://github.com/pre-commit/mirrors-mypy
51+
rev: "v1.0.1"
5352
hooks:
54-
- id: pyupgrade
55-
args: ["--py36-plus"]
53+
- id: mypy
54+
files: "setup.py"
55+
args: []
56+
additional_dependencies: [types-setuptools]
5657

5758
# Changes tabs to spaces
5859
- repo: https://github.com/Lucas-C/pre-commit-hooks
59-
rev: v1.1.13
60+
rev: v1.4.2
6061
hooks:
6162
- id: remove-tabs
6263
exclude: ^(docs|Makefile)
6364

64-
- repo: https://github.com/PyCQA/flake8
65-
rev: 3.9.2
66-
hooks:
67-
- id: flake8
68-
additional_dependencies: [flake8-bugbear]
69-
7065
# CMake formatting
7166
- repo: https://github.com/cheshirekow/cmake-format-precommit
7267
rev: v0.6.13

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ build:
2323
docs_build:
2424
mkdocs build
2525
docs_serve:
26-
mkdocs serve
26+
mkdocs serve -a 0.0.0.0:8088
2727

2828
DOCKER_TAG_WINDOWS ?= ghcr.io/cubao/build-env-windows-x64:v0.0.1
2929
DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.1

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,55 @@
1-
# Usage
1+
# cmake-example
2+
3+
Online document: **[readthedocs](http://cmake-example.readthedocs.io/)**
4+
5+
<!--intro-start-->
6+
7+
## Usage
8+
9+
Install:
210

311
```bash
412
python3 -m pip install cubao_cmake_example # install from pypi
513
python3 -c 'import cubao_cmake_example; print(cubao_cmake_example.add(1, 2))'
614
```
715

16+
CLI interface: (created with [python-fire](https://github.com/google/python-fire))
17+
818
```bash
919
python3 -m cubao_cmake_example add 1 2
1020
python3 -m cubao_cmake_example subtract 9 4
1121
```
1222

23+
Help:
24+
25+
```bash
26+
$ python3 -m cubao_cmake_example --help
27+
INFO: Showing help with the command '__main__.py -- --help'.
28+
29+
NAME
30+
__main__.py
31+
32+
SYNOPSIS
33+
__main__.py GROUP | COMMAND
34+
35+
GROUPS
36+
GROUP is one of the following:
37+
38+
fire
39+
The Python Fire module.
40+
41+
COMMANDS
42+
COMMAND is one of the following:
43+
44+
add
45+
add(arg0: int, arg1: int) -> int
46+
47+
subtract
48+
subtract(arg0: int, arg1: int) -> int
49+
50+
pure_python_func
51+
```
52+
1353
```bash
1454
$ python3 -m cubao_cmake_example pure_python_func --help
1555
INFO: Showing help with the command '__main__.py pure_python_func -- --help'.
@@ -30,21 +70,19 @@ FLAGS
3070
--arg3=ARG3
3171
Type: str
3272
Default: 'you shall not pass'
33-
```
3473

35-
```bash
3674
$ python3 -m cubao_cmake_example pure_python_func --arg1=43234
3775
int: 43234, float: 3.14, str: you shall not pass
3876
```
3977

40-
See more examples at [cubao](https://github.com/cubao), e.g.:
78+
<!--intro-end-->
4179

42-
- [pybind11-rdp](https://github.com/cubao/pybind11-rdp): C++ implementation
43-
of the Ramer-Douglas-Peucker algorithm (binding to python via pybind11)
44-
- [concave_hull](https://github.com/cubao/concave_hull): A very fast 2D concave hull algorithm, for python
80+
---
4581

4682
# Make a release
4783

84+
(We now use Github Workflow to release to pypi. Skip the rest if you don't want to manually compile wheels.)
85+
4886
## On linux
4987

5088
Install docker then

cubao_cmake_example/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from pybind11_cubao_cmake_example import * # noqa
2-
from pybind11_cubao_cmake_example import __version__ # noqa
1+
from pybind11_cubao_cmake_example import * # noqa: F403
2+
from pybind11_cubao_cmake_example import __version__ # noqa: F401
33

44

55
def pure_python_func(

cubao_cmake_example/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cubao_cmake_example import * # noqa
1+
from cubao_cmake_example import * # noqa: F403
22

33
if __name__ == "__main__":
44
import fire

docs/about/release-notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pip install -U cubao_cmake_example
2424

2525
---
2626

27-
You can also checkout release on:
27+
You can also checkout releases on:
2828

2929
- GitHub: <https://github.com/cubao/cmake_example/releases>
30-
- pypi: <https://pypi.org/project/cubao-cmake-example>
30+
- PyPi: <https://pypi.org/project/cubao-cmake-example>

docs/code.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# code
2+
3+
GitHub: [cmake-example](https://github.com/cubao/cmake_example)
4+
5+
## CMakeLists.txt
6+
7+
```cmake
8+
{%
9+
include-markdown "../CMakeLists.txt"
10+
comments=false
11+
%}
12+
```
13+
14+
## src/main.cpp
15+
16+
```cpp
17+
{%
18+
include-markdown "../src/main.cpp"
19+
comments=false
20+
%}
21+
```
22+
23+
## setup.py
24+
25+
<details>
26+
<summary>code</summary>
27+
28+
```python
29+
{%
30+
include-markdown "../setup.py"
31+
comments=false
32+
%}
33+
```
34+
35+
</details>
36+
37+
## tests/test_basic.py
38+
39+
```cpp
40+
{%
41+
include-markdown "../tests/test_basic.py"
42+
comments=false
43+
%}
44+
```

docs/index.md

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,11 @@ with some modifications:
99
- release to pypi
1010
- use markdown document
1111

12-
## Usage
13-
14-
Install:
15-
16-
```bash
17-
python3 -m pip install cubao_cmake_example # install from pypi
18-
python3 -c 'import cubao_cmake_example; print(cubao_cmake_example.add(1, 2))'
19-
```
20-
21-
CLI interface:
22-
23-
```bash
24-
python3 -m cubao_cmake_example add 1 2
25-
python3 -m cubao_cmake_example subtract 9 4
26-
```
27-
28-
Help:
29-
30-
```bash
31-
$ python3 -m cubao_cmake_example pure_python_func --help
32-
INFO: Showing help with the command '__main__.py pure_python_func -- --help'.
33-
34-
NAME
35-
__main__.py pure_python_func
36-
37-
SYNOPSIS
38-
__main__.py pure_python_func <flags>
39-
40-
FLAGS
41-
--arg1=ARG1
42-
Type: int
43-
Default: 42
44-
--arg2=ARG2
45-
Type: float
46-
Default: 3.14
47-
--arg3=ARG3
48-
Type: str
49-
Default: 'you shall not pass'
50-
51-
$ python3 -m cubao_cmake_example pure_python_func --arg1=43234
52-
int: 43234, float: 3.14, str: you shall not pass
53-
```
12+
{%
13+
include-markdown "../README.md"
14+
start="<!--intro-start-->"
15+
end="<!--intro-end-->"
16+
%}
5417

5518
<div class="text-center">
5619
<a href="https://github.com/cubao/cmake_example" class="btn btn-primary" role="button">Code on GitHub</a>
@@ -59,8 +22,4 @@ int: 43234, float: 3.14, str: you shall not pass
5922

6023
## Related
6124

62-
More examples at [cubao](https://github.com/cubao), e.g.:
63-
64-
- [pybind11-rdp](https://github.com/cubao/pybind11-rdp): C++ implementation
65-
of the Ramer-Douglas-Peucker algorithm (binding to python via pybind11)
66-
- [concave_hull](https://github.com/cubao/concave_hull): A very fast 2D concave hull algorithm, for python
25+
See more projects at [cubao](https://cubao.readthedocs.io).

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
mkdocs>=1.3.0
1+
mkdocs==1.4.2
2+
mkdocs-include-markdown-plugin==4.0.3

mkdocs.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ edit_uri: blob/master/docs/
88

99
theme: readthedocs
1010
nav:
11-
- Home: index.md
12-
- About:
13-
- Release Notes: about/release-notes.md
14-
- License: about/license.md
11+
- Home: index.md
12+
- Code: code.md
13+
- About:
14+
- Release Notes: about/release-notes.md
15+
- License: about/license.md
16+
plugins:
17+
- include-markdown
1518

16-
copyright: Copyright &copy; line
19+
copyright: Copyright &copy; 2023 <a href="https://cubao.readthedocs.io">cubao team</a>.

0 commit comments

Comments
 (0)