More documentation updates for 3.11.0 (#3553)

* mkdocs: add string_view examples

* mkdocs: reference underlying operators

* mkdocs: add operator<=> examples

* mkdocs: fix style check issues

* mkdocs: tweak BJData page

* mkdocs: add CMake option hints to macros

* mkdocs: fix JSON_DISABLE_ENUM_SERIALIZATION definition

* mkdocs: fix link to unit-udt.cpp

* mkdocs: fix "Arbitrary Type Conversions" title

* mkdocs: link to api/macros/*.md instead of features/macros.md

* mkdocs: document JSON_DisableEnumSerialization CMake option

* mkdocs: encode required C++ standard in example files

* docset: detect gsed/sed

* docset: update index

* docset: fix CSS patching

* docset: add list_missing_pages make target

* docset: add list_removed_paths make target

* docset: replace page titles with name from index

* docset: add install target for Zeal docset browser

* Use GCC_TOOL in ci_test_documentation target
This commit is contained in:
Florian Albrechtskirchinger
2022-07-31 14:05:58 +02:00
committed by GitHub
parent 11ba5c1120
commit d3e347bd2d
84 changed files with 1024 additions and 259 deletions

View File

@@ -137,11 +137,11 @@ Strong exception safety: if an exception occurs, the original value stays intact
--8<-- "examples/at__object_t_key_type.output"
```
??? example "Example (2) access specified object element with bounds checking"
??? example "Example: (2) access specified object element with bounds checking"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__object_t_key_type_const.cpp"
```
@@ -152,34 +152,64 @@ Strong exception safety: if an exception occurs, the original value stays intact
--8<-- "examples/at__object_t_key_type_const.output"
```
??? example "Example (4) access specified element via JSON Pointer"
??? example "Example: (3) access specified object element using string_view with bounds checking"
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/at__keytype.c++17.output"
```
??? example "Example: (3) access specified object element using string_view with bounds checking"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__keytype_const.c++17.cpp"
```
Output:
```json
--8<-- "examples/at__keytype_const.c++17.output"
```
??? example "Example: (4) access specified element via JSON Pointer"
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at_json_pointer.cpp"
--8<-- "examples/at__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/at_json_pointer.output"
--8<-- "examples/at__json_pointer.output"
```
??? example "Example (4) access specified element via JSON Pointer"
??? example "Example: (4) access specified element via JSON Pointer"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at_json_pointer_const.cpp"
--8<-- "examples/at__json_pointer_const.cpp"
```
Output:
```json
--8<-- "examples/at_json_pointer_const.output"
--8<-- "examples/at__json_pointer_const.output"
```
## See also

View File

@@ -69,32 +69,46 @@ Logarithmic in the size of the JSON object.
## Examples
??? example "Example (1) check with key"
??? example "Example: (1) check with key"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains.cpp"
--8<-- "examples/contains__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/contains.output"
--8<-- "examples/contains__object_t_key_type.output"
```
??? example "Example (3) check with JSON pointer"
??? example "Example: (2) check with key using string_view"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains_json_pointer.cpp"
--8<-- "examples/contains__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/contains_json_pointer.output"
--8<-- "examples/contains__keytype.c++17.output"
```
??? example "Example: (3) check with JSON pointer"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/contains__json_pointer.output"
```
## Version history

View File

@@ -44,18 +44,32 @@ This method always returns `0` when executed on a JSON type that is not an objec
## Examples
??? example
??? example "Example: (1) count number of elements"
The example shows how `count()` is used.
```cpp
--8<-- "examples/count.cpp"
--8<-- "examples/count__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/count.output"
--8<-- "examples/count__object_t_key_type.output"
```
??? example "Example: (2) count number of elements using string_view"
The example shows how `count()` is used.
```cpp
--8<-- "examples/count__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/count__keytype.c++17.output"
```
## Version history

View File

@@ -165,13 +165,27 @@ Strong exception safety: if an exception occurs, the original value stays intact
The example shows the effect of `erase()` for different JSON types using an object key.
```cpp
--8<-- "examples/erase__key_type.cpp"
--8<-- "examples/erase__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/erase__key_type.output"
--8<-- "examples/erase__object_t_key_type.output"
```
??? example "Example: (4) remove element from a JSON object given a key using string_view"
The example shows the effect of `erase()` for different JSON types using an object key.
```cpp
--8<-- "examples/erase__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/erase__keytype.c++17.output"
```
??? example "Example: (5) remove element from a JSON array given an index"

View File

@@ -48,18 +48,32 @@ This method always returns `end()` when executed on a JSON type that is not an o
## Examples
??? example
??? example "Example: (1) find object element by key"
The example shows how `find()` is used.
```cpp
--8<-- "examples/find__key_type.cpp"
--8<-- "examples/find__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/find__key_type.output"
--8<-- "examples/find__object_t_key_type.output"
```
??? example "Example: (2) find object element by key using string_view"
The example shows how `find()` is used.
```cpp
--8<-- "examples/find__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/find__keytype.c++17.output"
```
## See also

View File

@@ -48,7 +48,8 @@ Constant.
## See also
- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md) - library version information
- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md)
\- library version information
## Version history

View File

@@ -111,89 +111,117 @@ Strong exception safety: if an exception occurs, the original value stays intact
## Examples
??? example "Example (1): access specified array element"
??? example "Example: (1) access specified array element"
The example below shows how array elements can be read and written using `[]` operator. Note the addition of
`#!json null` values.
```cpp
--8<-- "examples/operatorarray__size_type.cpp"
--8<-- "examples/operator_array__size_type.cpp"
```
Output:
```json
--8<-- "examples/operatorarray__size_type.output"
--8<-- "examples/operator_array__size_type.output"
```
??? example "Example (1): access specified array element"
??? example "Example: (1) access specified array element (const)"
The example below shows how array elements can be read using the `[]` operator.
```cpp
--8<-- "examples/operatorarray__size_type_const.cpp"
--8<-- "examples/operator_array__size_type_const.cpp"
```
Output:
```json
--8<-- "examples/operatorarray__size_type_const.output"
--8<-- "examples/operator_array__size_type_const.output"
```
??? example "Example (2): access specified object element"
??? example "Example: (2) access specified object element"
The example below shows how object elements can be read and written using the `[]` operator.
```cpp
--8<-- "examples/operatorarray__key_type.cpp"
--8<-- "examples/operator_array__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/operatorarray__key_type.output"
--8<-- "examples/operator_array__object_t_key_type.output"
```
??? example "Example (2): access specified object element (const)"
??? example "Example: (2) access specified object element (const)"
The example below shows how object elements can be read using the `[]` operator.
```cpp
--8<-- "examples/operatorarray__key_type_const.cpp"
--8<-- "examples/operator_array__object_t_key_type_const.cpp"
```
Output:
```json
--8<-- "examples/operatorarray__key_type_const.output"
--8<-- "examples/operator_array__object_t_key_type_const.output"
```
??? example "Example (4): access specified element via JSON Pointer"
??? example "Example: (3) access specified object element using string_view"
The example below shows how object elements can be read using the `[]` operator.
```cpp
--8<-- "examples/operator_array__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/operator_array__keytype.c++17.output"
```
??? example "Example: (3) access specified object element using string_view (const)"
The example below shows how object elements can be read using the `[]` operator.
```cpp
--8<-- "examples/operator_array__keytype_const.c++17.cpp"
```
Output:
```json
--8<-- "examples/operator_array__keytype_const.c++17.output"
```
??? example "Example: (4) access specified element via JSON Pointer"
The example below shows how values can be read and written using JSON Pointers.
```cpp
--8<-- "examples/operatorjson_pointer.cpp"
--8<-- "examples/operator_array__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/operatorjson_pointer.output"
--8<-- "examples/operator_array__json_pointer.output"
```
??? example "Example (4): access specified element via JSON Pointer (const)"
??? example "Example: (4) access specified element via JSON Pointer (const)"
The example below shows how values can be read using JSON Pointers.
```cpp
--8<-- "examples/operatorjson_pointer_const.cpp"
--8<-- "examples/operator_array__json_pointer_const.cpp"
```
Output:
```json
--8<-- "examples/operatorjson_pointer_const.output"
--8<-- "examples/operator_array__json_pointer_const.output"
```
## See also

View File

@@ -78,5 +78,5 @@ Linear in the size of the JSON value.
## Version history
- Since version 1.0.0.
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../../features/macros.md#json_use_implicit_conversions) added
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
in version 3.9.0.

View File

@@ -15,7 +15,7 @@ bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; // (2)
according to the following rules:
- The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either
operand is `NaN` and the other operand is either `NaN` or any other number.
- Otherwise, returns the result of `#!cpp !(lhs < rhs)`.
- Otherwise, returns the result of `#!cpp !(lhs < rhs)` (see [**operator<**](operator_lt.md)).
2. Compares wether a JSON value is greater than or equal to a scalar or a scalar is greater than or
equal to a JSON value by converting the scalar to a JSON value and comparing both JSON values

View File

@@ -15,7 +15,7 @@ bool operator>(ScalarType lhs, const const_reference rhs) noexcept; // (2)
following rules:
- The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either
operand is `NaN` and the other operand is either `NaN` or any other number.
- Otherwise, returns the result of `#!cpp !(lhs <= rhs)`.
- Otherwise, returns the result of `#!cpp !(lhs <= rhs)` (see [**operator<=**](operator_le.md)).
2. Compares wether a JSON value is greater than a scalar or a scalar is greater than a JSON value by
converting the scalar to a JSON value and comparing both JSON values according to 1.

View File

@@ -15,7 +15,7 @@ bool operator<=(ScalarType lhs, const const_reference rhs) noexcept; // (2)
according to the following rules:
- The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either
operand is `NaN` and the other operand is either `NaN` or any other number.
- Otherwise, returns the result of `#!cpp !(rhs < lhs)`.
- Otherwise, returns the result of `#!cpp !(rhs < lhs)` (see [**operator<**](operator_lt.md)).
1. Compares wether a JSON value is less than or equal to a scalar or a scalar is less than or equal
to a JSON value by converting the scalar to a JSON value and comparing both JSON values according

View File

@@ -55,6 +55,36 @@ Linear.
2. Comparing a `NaN` with another `NaN`.
3. Comparing a `NaN` and any other number.
## Examples
??? example "Example: (1) comparing JSON values"
The example demonstrates comparing several JSON values.
```cpp
--8<-- "examples/operator_spaceship__const_reference.c++20.cpp"
```
Output:
```json
--8<-- "examples/operator_spaceship__const_reference.c++20.output"
```
??? example "Example: (2) comparing JSON values and scalars"
The example demonstrates comparing several JSON values and scalars.
```cpp
--8<-- "examples/operator_spaceship__scalartype.c++20.cpp"
```
Output:
```json
--8<-- "examples/operator_spaceship__scalartype.c++20.output"
```
## See also
- [**operator==**](operator_eq.md) - comparison: equal

View File

@@ -105,32 +105,46 @@ changes to any JSON value.
## Examples
??? example "Example (1): access specified object element with default value"
??? example "Example: (1) access specified object element with default value"
The example below shows how object elements can be queried with a default value.
```cpp
--8<-- "examples/basic_json__value.cpp"
--8<-- "examples/value__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/basic_json__value.output"
--8<-- "examples/value__object_t_key_type.output"
```
??? example "Example (3): access specified object element via JSON Pointer with default value"
??? example "Example: (2) access specified object element using string_view with default value"
The example below shows how object elements can be queried with a default value.
```cpp
--8<-- "examples/basic_json__value_ptr.cpp"
--8<-- "examples/value__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/basic_json__value_ptr.output"
--8<-- "examples/value__keytype.c++17.output"
```
??? example "Example: (3) access specified object element via JSON Pointer with default value"
The example below shows how object elements can be queried with a default value.
```cpp
--8<-- "examples/value__json_ptr.cpp"
```
Output:
```json
--8<-- "examples/value__json_ptr.output"
```
## See also