Incorporated feedback from patrick, exposed docs0readme as navigation, fixed htmlproofer, added anonymous_fields.md to documentation.

This commit is contained in:
Alexander Uhlig
2024-11-18 23:56:31 +00:00
committed by GitHub
parent 2e2b89fee8
commit 789822a1c7
7 changed files with 66 additions and 129 deletions
+2 -1
View File
@@ -3,7 +3,8 @@ name: update-people
on:
push:
branches:
- feature/docs_migration_mkdocs
- f/mkdocs
- main
schedule:
- cron: "0 12 1 * *"
workflow_dispatch: {}
+14 -14
View File
@@ -31,7 +31,7 @@ As the aforementioned libraries are among the most widely used in the respective
- Simple [installation](https://rfl.getml.com/install)
- Simple extendability to [other serialization formats](https://rfl.getml.com/supported_formats/supporting_your_own_format)
- Simple extendability to [custom classes](https://rfl.getml.com/concepts/custom_classes)
- Being one of the fastest serialization libraries in existence, as demonstrated by our [benchmarks](https://getml.com/benchmarks)
- Being one of the fastest serialization libraries in existence, as demonstrated by our [benchmarks](https://rfl.getml.com/benchmarks)
<br>
@@ -83,9 +83,9 @@ Support for more serialization formats is in development. Refer to the [issues](
Please also refer to the *vcpkg.json* in this repository.
# Feature Overview
## Feature Overview
## Simple Example
### Simple Example
```cpp
#include <rfl/json.hpp>
@@ -168,7 +168,7 @@ rfl::ubjson::read<Person>(ubjson_bytes);
rfl::xml::read<Person>(xml_string);
```
## More Comprehensive Example
### More Comprehensive Example
```cpp
#include <iostream>
@@ -241,7 +241,7 @@ std::cout << "Hello, my name is " << homer2.first_name() << " "
<< homer2.last_name() << "." << std::endl;
```
## Error messages
### Error messages
reflect-cpp returns clear and comprehensive error messages:
@@ -262,7 +262,7 @@ Found 5 errors:
5) Field named 'children' not found.
```
## JSON schema
### JSON schema
reflect-cpp also supports generating JSON schemata:
@@ -291,7 +291,7 @@ The resulting JSON schema looks like this:
Note that this is currently supported for JSON only, since most other formats do not support schemata in the first place.
## Enums
### Enums
reflect-cpp supports scoped enumerations:
@@ -324,7 +324,7 @@ This results in the following JSON string:
You can also directly convert between enumerator values and strings with `rfl::enum_to_string()` and `rfl::string_to_enum()`, or
obtain list of enumerator name and value pairs with `rfl::get_enumerators<EnumType>()` or `rfl::get_enumerator_array<EnumType>()`.
## Algebraic data types
### Algebraic data types
reflect-cpp supports Pydantic-style tagged unions, which allow you to form algebraic data types:
@@ -357,7 +357,7 @@ This results in the following JSON string:
Other forms of tagging are supported as well. Refer to the [documentation](https://rfl.getml.com/docs-readme) for details.
## Extra fields
### Extra fields
If you don't know all of your fields at compile time, no problem. Just use `rfl::ExtraFields`:
@@ -381,7 +381,7 @@ This results in the following JSON string:
{"firstName":"Homer","lastName":"Simpson","age":45,"email":"homer@simpson.com","town":"Springfield"}
```
## Reflective programming
### Reflective programming
Beyond serialization and deserialization, reflect-cpp also supports reflective programming in general.
@@ -480,9 +480,9 @@ const auto c2 = rfl::replace(c, a);
```
## Support for containers
### Support for containers
### C++ standard library
#### C++ standard library
reflect-cpp supports the following containers from the C++ standard library:
@@ -509,7 +509,7 @@ reflect-cpp supports the following containers from the C++ standard library:
- `std::vector`
- `std::wstring`
### Additional containers
#### Additional containers
In addition, it supports the following custom containers:
@@ -529,7 +529,7 @@ In addition, it supports the following custom containers:
- `rfl::Validator`: Allows for automatic input validation.
- `rfl::Variant`: An alternative to `std::variant` that compiles considerably faster.
### Custom classes
#### Custom classes
Finally, it is very easy to extend full support to your own classes, refer to the [documentation](https://rfl.getml.com/docs-readme) for details.
-101
View File
@@ -1,101 +0,0 @@
# Documentation
![image](banner2.png)
## 1) The basics
1.1) [Structs](https://github.com/getml/reflect-cpp/blob/main/docs/structs.md) - Recaps the motivating example in the README. A struct is the equivalent of an AND statement or a product type in type theory.
1.2) [Optional fields](https://github.com/getml/reflect-cpp/blob/main/docs/optional_fields.md) - For defining fields in your serialized format that might be absent in some cases.
1.3) [Struct flattening](https://github.com/getml/reflect-cpp/blob/main/docs/flatten_structs.md) - For making struct A "inherit" the fields of struct B.
1.4) [Processors](https://github.com/getml/reflect-cpp/blob/main/docs/processors.md) - For modifying the structs before serialization and deserialization. For instance, processors can be used to transform all field names from `snake_case` to `camelCase`.
1.5) [The rfl::Field-syntax](https://github.com/getml/reflect-cpp/blob/main/docs/field_syntax.md) - Describes an alternative syntax which requires slightly more effort, but allows for some powerful functionalities.
1.6) [String literals](https://github.com/getml/reflect-cpp/blob/main/docs/literals.md) - For representing strings that can only assume a limited number of enumerated values.
1.7) [Enums](https://github.com/getml/reflect-cpp/blob/main/docs/enums.md) - Describes how reflect-cpp handles C++ enums.
1.8) [std::variant and rfl::TaggedUnion](https://github.com/getml/reflect-cpp/blob/main/docs/variants_and_tagged_unions.md) - For structs that can be one of several formats. This is the equivalent of an OR statement or a sum type in type theory.
1.9) [rfl::Box and rfl::Ref](https://github.com/getml/reflect-cpp/blob/main/docs/rfl_ref.md) - For defining recursive structures.
1.10) [rfl::Timestamp](https://github.com/getml/reflect-cpp/blob/main/docs/timestamps.md) - For serializing and deserializing timestamps.
1.11) [rfl::Skip](https://github.com/getml/reflect-cpp/blob/main/docs/rfl_skip.md) - For skipping fields during serialization and/or deserialization.
1.12) [rfl::Result](https://github.com/getml/reflect-cpp/blob/main/docs/result.md) - For error handling without exceptions.
1.13) [Standard containers](https://github.com/getml/reflect-cpp/blob/main/docs/standard_containers.md) - Describes how reflect-cpp treats containers in the standard library.
1.14) [C arrays and inheritance](https://github.com/getml/reflect-cpp/blob/main/docs/c_arrays_and_inheritance.md) - Describes how reflect-cpp handles C arrays and inheritance.
1.15) [rfl::Bytestring](https://github.com/getml/reflect-cpp/blob/main/docs/bytestring.md) - Describes how reflect-cpp handles binary strings for formats that support them.
1.16) [rfl::Binary, rfl::Hex and rfl::Oct](https://github.com/getml/reflect-cpp/blob/main/docs/number_systems.md)- For expressing numbers in different formats.
## 2) Validation
2.1) [Regex patterns](https://github.com/getml/reflect-cpp/blob/main/docs/patterns.md) - For requiring that strings follow used-defined regex patterns.
2.2) [Validating numbers](https://github.com/getml/reflect-cpp/blob/main/docs/validating_numbers.md) - For imposing constraints on numbers.
2.3) [Composing validators](https://github.com/getml/reflect-cpp/blob/main/docs/composing_validators.md) - For defining more complex validators using operators such as `rfl::AllOf` or `rfl::AnyOf`.
2.4) [Size validation](https://github.com/getml/reflect-cpp/blob/main/docs/size_validation.md) - For imposing size constraints on containers such as `std::vector` or `std::string`.
2.5) [JSON schema](https://github.com/getml/reflect-cpp/blob/main/docs/json_schema.md) - For validating your schema before you even send it to your C++ backend.
## 3) Generic elements
3.1) [rfl::Object](https://github.com/getml/reflect-cpp/blob/main/docs/object.md) - A map-like type representing a object with field names that are unknown at compile time.
3.2) [rfl::Generic](https://github.com/getml/reflect-cpp/blob/main/docs/generic.md) - A catch-all type that can represent (almost) anything.
3.3) [rfl::ExtraFields](https://github.com/getml/reflect-cpp/blob/main/docs/extra_fields.md) - For adding extra fields to your structs, the names of which are unknown at compile time.
## 4) Custom classes
4.1) [Custom classes](https://github.com/getml/reflect-cpp/blob/main/docs/custom_classes.md) - For custom classes with private fields.
4.2) [Custom parsers for your classes](https://github.com/getml/reflect-cpp/blob/main/docs/custom_parser.md) - For custom classes with private fields that you want to leave absolutely untouched.
## 5) Useful helper functions and classes
5.1) [rfl::replace](https://github.com/getml/reflect-cpp/blob/main/docs/replace.md) - For replacing one or several fields in a struct.
5.2) [rfl::as](https://github.com/getml/reflect-cpp/blob/main/docs/as.md) - For casting structs as other structs.
5.3) [rfl::NamedTuple](https://github.com/getml/reflect-cpp/blob/main/docs/named_tuple.md) - For structural typing.
5.4) [rfl::Tuple](https://github.com/getml/reflect-cpp/blob/main/docs/rfl_tuple.md) - An alternative to `std::tuple` that compiles more quickly.
5.5) [rfl::to_view](https://github.com/getml/reflect-cpp/blob/main/docs/to_view.md) - For accessing fields of a struct by index or name.
## 6) Supported formats
6.1) [JSON](https://github.com/getml/reflect-cpp/blob/main/docs/json.md)
6.2) [BSON](https://github.com/getml/reflect-cpp/blob/main/docs/bson.md)
6.3) [CBOR](https://github.com/getml/reflect-cpp/blob/main/docs/cbor.md)
6.4) [flexbuffers](https://github.com/getml/reflect-cpp/blob/main/docs/flexbuffers.md)
6.5) [msgpack](https://github.com/getml/reflect-cpp/blob/main/docs/msgpack.md)
6.6) [TOML](https://github.com/getml/reflect-cpp/blob/main/docs/toml.md)
6.7) [UBJSON](https://github.com/getml/reflect-cpp/blob/main/docs/ubjson.md)
6.8) [XML](https://github.com/getml/reflect-cpp/blob/main/docs/xml.md)
6.9) [YAML](https://github.com/getml/reflect-cpp/blob/main/docs/yaml.md)
## 7) Advanced topics
7.1) [Supporting your own format](https://github.com/getml/reflect-cpp/blob/main/docs/supporting_your_own_format.md) - For supporting your own serialization and deserialization formats.
7.2) [Maintaining backwards compatability](https://github.com/getml/reflect-cpp/blob/main/docs/backwards_compatability.md) - Instructions on how to ensure that your API is backwards-compatible with older versions.
+1 -1
View File
@@ -82,5 +82,5 @@ Person{"Bart", "Simpson", ...};
But if you create a custom constructor, then C++ will no longer allow this kind of constructions.
If you want to create the struct from one of your classes (the most like reason, you want to create custom constructors in the first place),
you might want to check out the section on [custom classes](https://github.com/getml/reflect-cpp/blob/main/docs/custom_classes.md) or [custom parsers](https://github.com/getml/reflect-cpp/blob/main/docs/custom_parser.md).
you might want to check out the section on [custom classes](custom_classes.md) or [custom parsers](../custom_parser.md).
+3 -7
View File
@@ -1,9 +1,3 @@
---
hide:
- navigation
---
# Documentation
## The basics
@@ -40,6 +34,8 @@ hide:
[rfl::Binary, rfl::Hex and rfl::Oct](number_systems.md)- For expressing numbers in different formats.
[Anonymous fields](anonymous_fields.md) - For defining fields without using `rfl::Field`.
## Validation
[Regex patterns](patterns.md) - For requiring that strings follow used-defined regex patterns.
@@ -50,7 +46,7 @@ hide:
[Size validation](size_validation.md) - For imposing size constraints on containers such as `std::vector` or `std::string`.
[JSON schema](json_schema.md) - For validating your schema before you even send it to your C++ backend.
[JSON schema](supported_formats/json_schema.md) - For validating your schema before you even send it to your C++ backend.
## Generic elements
+2 -4
View File
@@ -41,12 +41,10 @@ reflect-cpp fills an important gap in C++ development. It minimizes boilerplate
- Simple [installation](https://rfl.getml.com/install)
- Simple extendability to [other serialization formats](https://rfl.getml.com/supported_formats/supporting_your_own_format)
- Simple extendability to [custom classes](https://rfl.getml.com/concepts/custom_classes)
- Being one of the fastest serialization libraries in existence, as demonstrated by our [benchmarks](https://getml.com/benchmarks)
- Being one of the fastest serialization libraries in existence, as demonstrated by our [benchmarks](https://rfl.getml.com/benchmarks)
## reflect-cpp in a nutshell
<h3> Why do we need this?</h3>
## Why do we need this?
Suppose your C++ program has complex data structures it needs to save and load. Or maybe it needs to interact with some kind of external API. If you do this the traditional way, you will have a lot of boilerplate code. This is annoying and error-prone.
+44 -1
View File
@@ -105,7 +105,49 @@ nav:
- Custom Format: supported_formats/supporting_your_own_format.md
# - Reflective Programming: ./reflective_programming.md
- Installation: install.md
- Documentation: docs-readme.md
- Documentation:
- docs-readme.md
- The basics:
- Structs: concepts/structs.md
- Optional fields: optional_fields.md
- Struct flattening: flatten_structs.md
- Processors: concepts/processors.md
- The rfl::Field-syntax: concepts/field_syntax.md
- String literals: literals.md
- Enums: enums.md
- std::variant and rfl::TaggedUnion: variants_and_tagged_unions.md
- rfl::Box and rfl::Ref: rfl_ref.md
- rfl::Timestamp: timestamps.md
- rfl::Skip: rfl_skip.md
- rfl::Result: result.md
- Standard containers: standard_containers.md
- C arrays and inheritance: c_arrays_and_inheritance.md
- rfl::Bytestring: bytestring.md
- rfl::Binary, rfl::Hex and rfl::Oct: number_systems.md
- Anonymous fields: anonymous_fields.md
- Validation:
- Regex patterns: patterns.md
- Validating numbers: validating_numbers.md
- Composing validators: composing_validators.md
- Size validation: size_validation.md
- JSON schema: supported_formats/json_schema.md
- Generic elements:
- rfl::Object: object.md
- rfl::Generic: generic.md
- rfl::ExtraFields: extra_fields.md
- Custom classes:
- Custom classes: concepts/custom_classes.md
- Custom parsers for your classes: custom_parser.md
- Useful helper functions and classes:
- rfl::replace: replace.md
- rfl::as: as.md
- rfl::NamedTuple: named_tuple.md
- rfl::Tuple: rfl_tuple.md
- rfl::to_view: to_view.md
- Advanced topics:
- Supporting your own format: supported_formats/supporting_your_own_format.md
- Maintaining backwards compatability: backwards_compatability.md
- Benchmarks: benchmarks.md
- Contributing: contributing.md
- People: people.md
@@ -146,6 +188,7 @@ plugins:
- mailto:*
- 'data:image/*'
- '#*'
- https://github.com/getml/reflect-cpp/tree/main/.github/actions/people/people.py
hooks: