Skip to content

Commit 43d04e2

Browse files
committed
update README and docs
1 parent ba0c4b1 commit 43d04e2

File tree

5 files changed

+105
-21
lines changed

5 files changed

+105
-21
lines changed
File renamed without changes.

README.md

Lines changed: 95 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
![](docs/images/bencode.svg)
22

3-
![build](https://github.com/fbdtemme/bencode/workflows/build/badge.svg?branch=master)
3+
[![build](https://github.com/fbdtemme/bencode/workflows/build/badge.svg?branch=master)](https://github.com/fbdtemme/bencode/actions?query=workflow%3Abuild)
4+
[![docs](https://github.com/fbdtemme/bencode/workflows/documentation/badge.svg?branch=master)](https://fbdtemme.github.io/bencode/)
45
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5cc3eec94d8a486dab62afeab5130def)](https://app.codacy.com/manual/floriandetemmerman/bencode?utm_source=github.com&utm_medium=referral&utm_content=fbdtemme/bencode&utm_campaign=Badge_Grade_Dashboard)
56
[![codecov](https://codecov.io/gh/fbdtemme/bencode/branch/master/graph/badge.svg)](https://codecov.io/gh/fbdtemme/bencode)
67
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
78

9+
[**Features**](#Features) |
10+
[**Status**](#Status) |
11+
[**Documentation**](#Documentation) |
12+
[**Examples**](#Examples) |
13+
[**Building**](#Building) |
14+
[**Integration**](#Integration) |
15+
[**License**](#License)
16+
817
A header-only C++20 bencode serialization/deserialization library.
918

1019
## Features
@@ -15,24 +24,16 @@ A header-only C++20 bencode serialization/deserialization library.
1524
* Support for serializing/deserializing to/from user-defined types.
1625
* Parse directly to custom types by satisfying the `EventConsumer` concept.
1726
* Throwing and non throwing variants of common functions.
18-
* Iterative parsing to be safe against stack overflow attacks.
19-
20-
## Documentation
27+
* Iterative parsing to protect against stack overflow attacks.
2128

22-
Documentation is available on the [bencode GitHub pages](https://fbdtemme.github.io/bencode/)
29+
## Status
2330

24-
## Requirements
31+
This library is still under development, but should be fairly stable.
32+
The API may change at any release prior to 1.0.0.
2533

26-
This project requires C++20.
27-
Currently only GCC 10 is supported.
28-
29-
This library depends on following projects:
30-
* [Catch2](https://github.com/catchorg/Catch2)
31-
* [fmt](https://github.com/fmtlib/fmt)
32-
* [Microsoft GSL](https://github.com/microsoft/GSL)
33-
* [expected-lite](https://github.com/martinmoene/expected-lite)
34+
## Documentation
3435

35-
All dependencies can be fetched from github during configure time or can be installed manually.
36+
Documentation is available on the [bencode GitHub pages](https://fbdtemme.github.io/bencode/)
3637

3738
## Examples
3839

@@ -75,7 +76,9 @@ auto v2 = get_integer(b[1]);
7576
7677
Serialize to bencode using `bvalue`.
7778
```cpp
78-
#include <bencode/bvalue.hpp>
79+
#include <iostream>
80+
#include <bencode/bvalue.hpp>
81+
#include <bencode/encode.hpp>
7982
8083
bc::bvalue b {
8184
{"foo", 1},
@@ -90,8 +93,10 @@ bc::encode_to(std::cout, b);
9093
Serialize to bencode using `encoder`
9194

9295
```cpp
93-
#include <bencode/encode.hpp>
94-
#include <bencode/traits/vector.hpp>
96+
#include <iostream>
97+
#include <vector>
98+
#include <bencode/encode.hpp> // bc::encoder
99+
#include <bencode/traits/vector.hpp> // support for serializating std::vector
95100

96101
bc::encoder es(std::cout);
97102

@@ -105,3 +110,75 @@ es << bc::begin_dict
105110
```
106111
107112
For more examples see the [documentation](https://fbdtemme.github.io/bencode/)
113+
114+
## Building
115+
116+
This project requires C++20.
117+
Currently only GCC 10 is supported.
118+
119+
This library depends on following projects:
120+
* [Catch2](https://github.com/catchorg/Catch2)
121+
* [fmt](https://github.com/fmtlib/fmt)
122+
* [Microsoft GSL](https://github.com/microsoft/GSL)
123+
* [expected-lite](https://github.com/martinmoene/expected-lite)
124+
125+
All dependencies can be fetched from github during configure time or can be installed manually.
126+
127+
The tests can be built as every other project which makes use of the CMake build system.
128+
129+
```{bash}
130+
mkdir build
131+
cd build
132+
cmake -DCMAKE_BUILD_TYPE=Debug ..
133+
make
134+
```
135+
136+
## Integration
137+
138+
You can use the `bencode::bencode` interface target in CMake.
139+
The library can be located with `find_package`.
140+
141+
```cmake
142+
# CMakeLists.txt
143+
find_package(bencode REQUIRED)
144+
...
145+
add_library(foo ...)
146+
...
147+
target_link_libraries(foo INTERFACE bencode::bencode)
148+
```
149+
150+
The source tree can be included in your project and added to your build with `add_subdirectory`.
151+
152+
```cmake
153+
# CMakeLists.txt
154+
# Disable building tests and benchmarks.
155+
set(BENCODE_BUILD_TESTS OFF)
156+
set(BENCODE_BUILD_BENCHMARKS OFF)
157+
158+
add_subdirectory(bencode)
159+
...
160+
add_library(foo ...)
161+
...
162+
target_link_libraries(foo INTERFACE bencode::bencode)
163+
```
164+
165+
You can also use `FetchContent` to download the code from github.
166+
167+
```cmake
168+
# CMakeLists.txt
169+
include(FetchContent)
170+
171+
FetchContent_Declare(bencode
172+
GIT_REPOSITORY https://github.com/fbdtemme/bencode.git
173+
GIT_TAG "master")
174+
175+
FetchContent_MakeAvailable(bencode)
176+
...
177+
add_library(foo ...)
178+
...
179+
target_link_libraries(foo INTERFACE bencode::bencode)
180+
```
181+
182+
## License
183+
184+
Distributed under the MIT license. See `LICENSE` for more information.

docs/getting_started/integration.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ The source tree can be included in your project and included with :code:`add_sub
2727
.. code-block::
2828
2929
# CMakeLists.txt
30-
# Typically you don't care so much for a third party library's tests to be
31-
# run from your own project's code.
30+
# Disable building tests and benchmarks.
3231
set(BENCODE_BUILD_TESTS OFF)
32+
set(BENCODE_BUILD_BENCHMARKS OFF)
33+
3334
add_subdirectory(bencode)
3435
...
3536
add_library(foo ...)
@@ -49,5 +50,7 @@ Embedded (FetchContent)
4950
GIT_TAG "master")
5051
5152
FetchContent_MakeAvailable(bencode)
52-
53+
...
54+
add_library(foo ...)
55+
...
5356
target_link_libraries(foo INTERFACE bencode::bencode)

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ bencode
55

66
A C++20 bencode serialisation/deserialization library.
77

8+
Source code is hosted on `GitHub <https://github.com/fbdtemme/bencode>`_ under the :ref:`MIT license <license>`.
9+
810
.. note:: This documentation site is under construction.
911

1012
Content

docs/other/license.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
License
22
=======
33

4+
.. _license:
5+
46
This project is licensed under the `MIT license <https://opensource.org/licenses/MIT>`_:
57

68
.. pull-quote::

0 commit comments

Comments
 (0)