Skip to content

Commit 3be0a4d

Browse files
authored
use cargo-doc2readme (#15)
1 parent cf9d13f commit 3be0a4d

File tree

6 files changed

+54
-36
lines changed

6 files changed

+54
-36
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
- uses: actions/checkout@v2
9696
with:
9797
submodules: recursive
98-
- uses: docker://ghcr.io/msrd0/alpine-cargo-readme
98+
- uses: docker://ghcr.io/msrd0/cargo-doc2readme
9999
with:
100100
entrypoint: ./readme.sh
101101
args: --check

README.tpl renamed to README.j2

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This repository contains the following crates:
3232

3333
# openapi_type
3434

35-
{{readme}}
35+
{{ readme }}
3636

3737
## Versioning
3838

@@ -41,7 +41,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
4141

4242
## License
4343

44-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
44+
Copyright (C) 2021 Dominic Meiser and [contributors].
4545

4646
```
4747
Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,3 +56,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5656
See the License for the specific language governing permissions and
5757
limitations under the License.
5858
```
59+
60+
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
61+
{% if links != "" -%}
62+
{{ links }}
63+
{%- endif -%}

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ This repository contains the following crates:
3232

3333
# openapi_type
3434

35-
This crate gives static type information for primitives and commonly used types from the standard
36-
library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a
37-
derive macro for structs and enums to gain access to their static type information at runtime.
35+
This crate gives static type information for primitives and commonly used types from the standard library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime.
36+
37+
The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, [`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static type information in a way that is convenient to use for a generated OpenAPI specification, but can also be utilized in other use cases as well.
3838

39-
The core of this crate is the [`OpenapiType`] trait. It has one static function,
40-
[`schema`](OpenapiType::schema), which returns an [`OpenapiSchema`]. This assembles the static
41-
type information in a way that is convenient to use for a generated OpenAPI specification, but
42-
can also be utilized in other use cases as well.
4339

4440
## Custom Types
45-
To gain access to the static type information of your custom types at runtime, the easiest way
46-
is to use the derive macro:
41+
42+
To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro:
43+
4744

4845
```rust
4946
#[derive(OpenapiType)]
@@ -53,9 +50,12 @@ struct FooBar {
5350
}
5451
```
5552

53+
5654
## OpenAPI specification
55+
5756
Using above type, running `FooBar::schema().into_schema()` yields
5857

58+
5959
```yaml
6060
type: object
6161
title: FooBar
@@ -71,11 +71,9 @@ required:
7171
- bar
7272
```
7373
74-
Note, however, that this is not sufficient for more complex types. If one of your structs fields
75-
is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain
76-
a reference to that schema. Therefore, always remember to put the
77-
[`dependencies`](OpenapiSchema::dependencies) into the specification alongside the type you are
78-
interested in.
74+
Note, however, that this is not sufficient for more complex types. If one of your structs fields is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain a reference to that schema. Therefore, always remember to put the [`dependencies`][__link3] into the specification alongside the type you are interested in.
75+
76+
7977

8078
## Versioning
8179

@@ -84,7 +82,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
8482

8583
## License
8684

87-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
85+
Copyright (C) 2021 Dominic Meiser and [contributors].
8886

8987
```
9088
Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,3 +97,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9997
See the License for the specific language governing permissions and
10098
limitations under the License.
10199
```
100+
101+
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
102+
[__link0]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiType
103+
[__link1]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiType::schema
104+
[__link2]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiSchema
105+
[__link3]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiSchema::dependencies

crates-io.tpl renamed to crates-io.j2

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openapi_type [![Rust 1.49+](https://img.shields.io/badge/rustc-1.49+-orange.svg)](https://blog.rust-lang.org/2020/12/31/Rust-1.49.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type)
22

3-
{{readme}}
3+
{{ readme }}
44

55
## Versioning
66

@@ -9,7 +9,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
99

1010
## License
1111

12-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
12+
Copyright (C) 2021 Dominic Meiser and [contributors].
1313

1414
```
1515
Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,3 +24,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2424
See the License for the specific language governing permissions and
2525
limitations under the License.
2626
```
27+
28+
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
29+
{% if links != "" -%}
30+
{{ links }}
31+
{%- endif -%}

crates-io.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
# openapi_type [![Rust 1.49+](https://img.shields.io/badge/rustc-1.49+-orange.svg)](https://blog.rust-lang.org/2020/12/31/Rust-1.49.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type)
22

3-
This crate gives static type information for primitives and commonly used types from the standard
4-
library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a
5-
derive macro for structs and enums to gain access to their static type information at runtime.
3+
This crate gives static type information for primitives and commonly used types from the standard library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime.
4+
5+
The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, [`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static type information in a way that is convenient to use for a generated OpenAPI specification, but can also be utilized in other use cases as well.
66

7-
The core of this crate is the [`OpenapiType`] trait. It has one static function,
8-
[`schema`](OpenapiType::schema), which returns an [`OpenapiSchema`]. This assembles the static
9-
type information in a way that is convenient to use for a generated OpenAPI specification, but
10-
can also be utilized in other use cases as well.
117

128
## Custom Types
13-
To gain access to the static type information of your custom types at runtime, the easiest way
14-
is to use the derive macro:
9+
10+
To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro:
11+
1512

1613
```rust
1714
#[derive(OpenapiType)]
@@ -21,9 +18,12 @@ struct FooBar {
2118
}
2219
```
2320

21+
2422
## OpenAPI specification
23+
2524
Using above type, running `FooBar::schema().into_schema()` yields
2625

26+
2727
```yaml
2828
type: object
2929
title: FooBar
@@ -39,11 +39,9 @@ required:
3939
- bar
4040
```
4141
42-
Note, however, that this is not sufficient for more complex types. If one of your structs fields
43-
is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain
44-
a reference to that schema. Therefore, always remember to put the
45-
[`dependencies`](OpenapiSchema::dependencies) into the specification alongside the type you are
46-
interested in.
42+
Note, however, that this is not sufficient for more complex types. If one of your structs fields is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain a reference to that schema. Therefore, always remember to put the [`dependencies`][__link3] into the specification alongside the type you are interested in.
43+
44+
4745

4846
## Versioning
4947

@@ -52,7 +50,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
5250

5351
## License
5452

55-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
53+
Copyright (C) 2021 Dominic Meiser and [contributors].
5654

5755
```
5856
Licensed under the Apache License, Version 2.0 (the "License");
@@ -67,3 +65,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6765
See the License for the specific language governing permissions and
6866
limitations under the License.
6967
```
68+
69+
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
70+
[__link0]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiType
71+
[__link1]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiType::schema
72+
[__link2]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiSchema
73+
[__link3]: https://docs.rs/openapi_type/0.2.1/openapi_type/?search=openapi_type::OpenapiSchema::dependencies

readme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for readme in README crates-io
1515
do
1616
output=$readme.md
1717
[ $check == y ] && output=$(mktemp)
18-
cargo readme -t $readme.tpl -o $output
18+
cargo doc2readme -t $readme.j2 -o $output
1919
if [ $check == y ]
2020
then
2121
diff $readme.md $output || ok=1

0 commit comments

Comments
 (0)