Skip to content

Commit d128813

Browse files
committed
Improve doxygen docs
1 parent 56ba8ac commit d128813

10 files changed

+347
-162
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rapid YAML
22
[![MIT Licensed](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/biojppm/rapidyaml/blob/master/LICENSE.txt)
33
[![release](https://img.shields.io/github/v/release/biojppm/rapidyaml?color=g&include_prereleases&label=release%20&sort=semver)](https://github.com/biojppm/rapidyaml/releases)
4-
[![Documentation Status](https://readthedocs.org/projects/rapidyaml/badge/?version=latest)](https://rapidyaml.readthedocs.io/en/latest/?badge=latest)
4+
[![Documentation Status](https://readthedocs.org/projects/rapidyaml/badge/?version=latest)](https://rapidyaml.readthedocs.io/latest/?badge=latest)
55

66
[![PyPI](https://img.shields.io/pypi/v/rapidyaml?color=g)](https://pypi.org/project/rapidyaml/)
77
[![Gitter](https://badges.gitter.im/rapidyaml/community.svg)](https://gitter.im/rapidyaml/community)
@@ -51,7 +51,7 @@ ryml is written in C++11, and compiles cleanly with:
5151
* Intel Compiler
5252

5353
ryml's API documentation is [available at
54-
ReadTheDocs](https://rapidyaml.readthedocs.io/en/latest/).
54+
ReadTheDocs](https://rapidyaml.readthedocs.io/latest/).
5555

5656
ryml is [extensively unit-tested in Linux, Windows and
5757
MacOS](https://github.com/biojppm/rapidyaml/actions). The tests cover
@@ -239,7 +239,7 @@ level API for accessing and traversing the data tree.
239239

240240
The following snippet is a very quick overview taken from quickstart
241241
sample ([see on
242-
doxygen](https://rapidyaml.readthedocs.io/en/latest/group__doc__quickstart.html)/[see
242+
doxygen](https://rapidyaml.readthedocs.io/latest/group__doc__quickstart.html)/[see
243243
on github](samples/quickstart.cpp). After cloning ryml
244244
(don't forget the `--recursive` flag for git), you can very easily
245245
build and run this executable using any of the build samples, eg the

doc/Doxyfile

+5
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,9 @@ INPUT = \
957957
../ext/c4core/src/c4/charconv.hpp \
958958
../ext/c4core/src/c4/format.hpp \
959959
../ext/c4core/src/c4/base64.hpp \
960+
../ext/c4core/src/c4/std/string.hpp \
961+
../ext/c4core/src/c4/std/string_view.hpp \
962+
../ext/c4core/src/c4/std/vector.hpp \
960963

961964
# This tag can be used to specify the character encoding of the source files
962965
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -2495,6 +2498,8 @@ PREDEFINED = \
24952498
"C4_MUST_BE_TRIVIAL_COPY(cls)= " \
24962499
"C4_NO_INLINE= " \
24972500
"C4_NO_UBSAN_IOVRFLW= " \
2501+
"C4_NODISCARD= " \
2502+
"C4_NORETURN= " \
24982503
"C4_PURE= " \
24992504
"C4_REQUIRE_RW(ty)=ty " \
25002505
"C4_RESTRICT= " \

doc/doxy_main.md

+1-19
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,7 @@
1010
* @ref doc_node_type
1111
* @ref doc_tree
1212
* @ref doc_node_classes
13-
* For serialization/deserialization:
14-
* See @ref sample_scalar_types for when the type is scalar (a leaf node in the YAML tree, containing a string representation):
15-
* See examples on how to @ref sample_to_chars_scalar
16-
* See examples on how to @ref sample_from_chars_scalar
17-
* See the sample @ref sample::sample_user_scalar_types
18-
* When serializing floating point values in C++ earlier than 17,
19-
be aware that there may be a truncation of the precision with
20-
the default to_chars implementation. To enforce a particular
21-
precision, use for example @ref c4::fmt::real, or call
22-
directly @ref c4::ftoa or @ref c4::dtoa, or any other method
23-
(remember that ryml only stores the final string, so nothing
24-
prevents you from creating it). See the relevant sample: @ref
25-
sample::sample_float_precision.
26-
* See @ref sample_container_types for when the type is a container (ie, a node which has children, which may themselves be containers).
27-
* See the sample @ref sample::sample_user_container_types
28-
* ryml does not use any STL containers internally, but it can be
29-
used to serialize and deserialize these containers. See @ref
30-
sample::sample_std_types for an example. See the header @ref
31-
ryml_std.hpp and also the headers it includes.
13+
* For serialization/deserialization, see @ref doc_serialization.
3214
* @ref doc_tag_utils - how to resolve tags
3315
* @ref doc_callbacks - how to set up error/allocation/deallocation
3416
callbacks either globally for the library, or for specific objects

doc/index.rst

+75-7
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ and eat it too. Being rapid is definitely NOT the same as being
1212
unpractical, so ryml was written with easy AND efficient usage in
1313
mind.
1414

15-
ryml is available as a single header file, or it can be used as a
16-
simple library with cmake -- both separately (ie
17-
build -> install -> ``find_package()``) or together with your project (ie with
15+
ryml is available both as a single header file, or as a simple library
16+
with cmake -- both separately (ie build -> install ->
17+
``find_package()``) or together with your project (ie with
1818
``add_subdirectory()``). (See below for examples).
1919

2020
ryml can use custom global and per-tree memory allocators and error
2121
handler callbacks, and is exception-agnostic. ryml provides a default
2222
implementation for the allocator (using ``std::malloc()``) and error
23-
handlers (using either exceptions, ``longjmp()`` or ``std::abort()``),
24-
but you can opt out of and provide your own memory allocation and
25-
error callbacks.
23+
handlers (using either exceptions or ``std::abort()``), but you can
24+
opt out the default implementation and provide your own memory
25+
allocation and error callbacks.
2626

2727
For maximum portability, ryml does not depend on the STL, ie, it does
2828
not use any std container as part of its data structures. But ryml can
@@ -53,10 +53,78 @@ Table of contents
5353
.. toctree::
5454
:maxdepth: 3
5555

56-
./sphinx_api_documentation
56+
Doxygen docs <doxygen/index.html#http://>
5757
./sphinx_quicklinks
5858
./sphinx_is_it_rapid
5959
./sphinx_yaml_standard
6060
./sphinx_using
6161
./sphinx_other_languages
6262
./sphinx_alternative_libraries
63+
64+
65+
API teaser
66+
==========
67+
68+
Here's a short teaser from the API quickstart overview (`see on
69+
doxygen <doxygen/group__doc__quickstart.html>`_ / `see full code on
70+
github
71+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/samples/quickstart.cpp>`_):
72+
73+
.. code-block:: c++
74+
75+
// Parse YAML code in place, potentially mutating the buffer:
76+
char yml_buf[] = "{foo: 1, bar: [2, 3], john: doe}";
77+
ryml::Tree tree = ryml::parse_in_place(yml_buf);
78+
79+
// read from the tree:
80+
ryml::NodeRef bar = tree["bar"];
81+
CHECK(bar[0].val() == "2");
82+
CHECK(bar[1].val() == "3");
83+
CHECK(bar[0].val().str == yml_buf + 15); // points at the source buffer
84+
CHECK(bar[1].val().str == yml_buf + 18);
85+
86+
// deserializing:
87+
int bar0 = 0, bar1 = 0;
88+
bar[0] >> bar0;
89+
bar[1] >> bar1;
90+
CHECK(bar0 == 2);
91+
CHECK(bar1 == 3);
92+
93+
// serializing:
94+
bar[0] << 10; // creates a string in the tree's arena
95+
bar[1] << 11;
96+
CHECK(bar[0].val() == "10");
97+
CHECK(bar[1].val() == "11");
98+
99+
// add nodes
100+
bar.append_child() << 12; // see also operator= (explanation below)
101+
CHECK(bar[2].val() == "12");
102+
103+
// emit tree
104+
// to std::string
105+
CHECK(ryml::emitrs_yaml<std::string>(tree) == R"(foo: 1
106+
bar:
107+
- 10
108+
- 11
109+
- 12
110+
john: doe
111+
)");
112+
std::cout << tree; // emit to stdout
113+
ryml::emit_yaml(tree, stdout); // emit to file
114+
115+
// emit node
116+
ryml::ConstNodeRef foo = tree["foo"];
117+
// to std::string
118+
CHECK(ryml::emitrs_yaml<std::string>(foo) == "foo: 1\n");
119+
std::cout << foo; // emit node to stdout
120+
ryml::emit_yaml(foo, stdout); // emit node to file
121+
122+
123+
.. note::
124+
Please refer to the `Doxygen documentation
125+
<./doxygen/index.html>`_, and read the `overview sample
126+
<doxygen/group__doc__quickstart.html#ga1118e0fb55403d0e061626cf8a07cc0c>`_;
127+
this will quickly teach you the basic concepts and caveats, which
128+
will save you a lot of time.
129+
130+
.. include:: sphinx_try_quickstart.rst

doc/sphinx_api_documentation.rst

-52
This file was deleted.

doc/sphinx_is_it_rapid.rst

+27-22
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ against other libraries.
3838
Comparison with yaml-cpp
3939
------------------------
4040

41-
The first result set is for Windows, and is using a `appveyor.yml config
42-
file <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/appveyor.yml>`__. A comparison of these results is
43-
summarized on the table below:
41+
The first result set is for Windows, and is using a `appveyor.yml
42+
config file
43+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/appveyor.yml>`__. A
44+
comparison of these results is summarized on the table below:
4445

4546
=========================== ===== ======= ==========
4647
Read rates (MB/s) ryml yamlcpp compared
@@ -49,12 +50,13 @@ appveyor / vs2017 / Release 101.5 5.3 20x / 5.2%
4950
appveyor / vs2017 / Debug 6.4 0.0844 76x / 1.3%
5051
=========================== ===== ======= ==========
5152

52-
The next set of results is taken in Linux, comparing g++ 8.2 and clang++
53-
7.0.1 in parsing a YAML buffer from a `travis.yml config
54-
file <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/travis.yml>`__ or a JSON buffer from a
55-
`compile_commands.json file <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__. You
56-
can `see the full results
57-
here <https://github.com/biojppm/rapidyaml/blob/v0.5.0/results/parse.linux.i7_6800K.md>`__. Summarizing:
53+
The next set of results is taken in Linux, comparing g++ 8.2 and
54+
clang++ 7.0.1 in parsing a YAML buffer from a `travis.yml config file
55+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/travis.yml>`__
56+
or a JSON buffer from a `compile_commands.json file
57+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__. You
58+
can `see the full results here
59+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/results/parse.linux.i7_6800K.md>`__. Summarizing:
5860

5961
========================== ===== ======= ========
6062
Read rates (MB/s) ryml yamlcpp compared
@@ -86,13 +88,14 @@ Performance reading JSON
8688
So how does ryml compare against other JSON readers? Well, it may not
8789
be the fastest, but it's definitely ahead of the pack!
8890

89-
The benchmark is the `same as above <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_parse.cpp>`__, and it is
90-
reading the
91-
`compile_commands.json <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__, The
92-
``_arena`` suffix notes parsing a read-only buffer (so buffer copies are
93-
performed), while the ``_inplace`` suffix means that the source buffer
94-
can be parsed in place. The ``_reuse`` means the data tree and/or parser
95-
are reused on each benchmark repeat.
91+
The benchmark is the `same as above
92+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_parse.cpp>`__,
93+
and it is reading the `compile_commands.json
94+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__,
95+
The ``_arena`` suffix notes parsing a read-only buffer (so buffer
96+
copies are performed), while the ``_inplace`` suffix means that the
97+
source buffer can be parsed in place. The ``_reuse`` means the data
98+
tree and/or parser are reused on each benchmark repeat.
9699

97100
Here’s what we get with g++ 8.2:
98101

@@ -127,12 +130,14 @@ result).
127130
Performance emitting
128131
--------------------
129132

130-
`Emitting benchmarks <https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_emit.cpp>`__ also show similar speedups from
131-
the existing libraries, also anecdotally reported by some users `(eg,
132-
here’s a user reporting 25x speedup from
133-
yaml-cpp) <https://github.com/biojppm/rapidyaml/issues/28#issue-553855608>`__.
134-
Also, in some cases (eg, block folded multiline scalars), the speedup is
135-
as high as 200x (eg, 7.3MB/s -> 1.416MG/s).
133+
`Emitting benchmarks
134+
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_emit.cpp>`__
135+
also show similar speedups from the existing libraries, also
136+
anecdotally reported by some users `(eg, here’s a user reporting 25x
137+
speedup from yaml-cpp)
138+
<https://github.com/biojppm/rapidyaml/issues/28#issue-553855608>`__.
139+
Also, in some cases (eg, block folded multiline scalars), the speedup
140+
is as high as 200x (eg, 7.3MB/s -> 1.416MG/s).
136141

137142

138143
Serialization performance

doc/sphinx_quicklinks.rst

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Quick links
99

1010
* `Pull Requests <https://github.com/biojppm/rapidyaml/pull>`_
1111

12+
* `Kanban board <https://github.com/biojppm/rapidyaml/projects/1>`_
13+
1214
* Latest release: `0.5.0 <https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0>`_
1315

1416
* `Release page [0.5.0] <https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0>`_

ext/c4core

0 commit comments

Comments
 (0)