Skip to content

Commit 163c49d

Browse files
committed
Update Doxygen documentation
1 parent da2c614 commit 163c49d

16 files changed

Lines changed: 1006 additions & 522 deletions

File tree

docs/Doxyfile.in

Lines changed: 861 additions & 436 deletions
Large diffs are not rendered by default.

docs/conf.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ master_doc = 'index'
6868
#
6969
# This is also used if you do content translation via gettext catalogs.
7070
# Usually you set "language" from the command line for these cases.
71-
language = None
71+
language = 'en'
7272

7373
# List of patterns, relative to source directory, that match files and
7474
# directories to ignore when looking for source files.

docs/core.rst

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ Description
66

77
The core of the ``skyr`` library is a ``skyr::parse`` function
88
that parses an input string and creates a ``skyr::url_record``
9-
that contains a URL parts, and a ``skyr::serialize`` function
9+
that contains URL parts, and a ``skyr::serialize`` function
1010
that composes a URL string from an existing ``skyr::url_record``.
1111

12+
The ``skyr::parse`` function returns ``std::expected<url_record, url_parse_errc>``
13+
for type-safe error handling without exceptions.
14+
1215
Use these functions directly if your needs are simple. Use the
1316
``skyr::url`` class for more complex operations, including
14-
Unicode encoding and decoding.
17+
Unicode encoding and decoding, URL transformations, and sanitization.
1518

1619
Headers
1720
-------
@@ -31,20 +34,30 @@ Example
3134
#include <skyr/core/url_record.hpp>
3235
#include <skyr/core/parse.hpp>
3336
#include <skyr/core/serialize.hpp>
34-
#include <iostream>
37+
#include <print>
3538

3639
int main() {
37-
auto url = skyr::url_parse("http://example.org/");
38-
std::cout << url << std::endl;
39-
std::cout << "Scheme: " << url.scheme << std::endl;
40-
std::cout << "Hostname: " << url.host.value().to_string());
41-
std::cout << "Pathname: ";
42-
for (const auto &path : url.path) {
43-
<< std::cout << "/" << path;
44-
}
45-
std::cout << std::endl;
40+
auto result = skyr::parse("http://example.org/path/to/file");
41+
42+
if (result) {
43+
const auto& url = result.value();
44+
45+
std::println("Scheme: {}", url.scheme);
4646

47-
std::cout << "Serializer: " << skyr::serialize(url) << std::endl;
47+
if (url.host) {
48+
std::println("Hostname: {}", url.host->serialize());
49+
}
50+
51+
std::print("Pathname: ");
52+
for (const auto& segment : url.path) {
53+
std::print("/{}", segment);
54+
}
55+
std::println("");
56+
57+
std::println("Serialized: {}", skyr::serialize(url));
58+
} else {
59+
std::println("Parse error: {}", result.error());
60+
}
4861
}
4962

5063
API

docs/domain.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,25 @@ Example
2525
.. code-block:: c++
2626

2727
#include <skyr/domain/domain.hpp>
28-
#include <iostream>
28+
#include <print>
2929

3030
int main() {
3131
using namespace std::string_literals;
3232

3333
auto domain = "उदाहरण.परीक्षा"s;
3434
auto encoded = skyr::domain::domain_to_ascii(domain);
3535
if (encoded) {
36-
std::cout << encoded.value() << std::endl;
36+
std::println(encoded.value());
3737
}
3838
}
3939

4040
API
4141
---
4242

43-
Domain to ASCII
44-
^^^^^^^^^^^^^^^
43+
Domain Processing Functions
44+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

46-
.. doxygenfunction:: skyr::domain_to_ascii(std::string_view, bool)
47-
48-
.. doxygenfunction:: skyr::domain_to_unicode(std::string_view, bool)
46+
The library provides the following domain processing functions. See the header files for detailed documentation of all overloads.
4947

5048
Error codes
5149
^^^^^^^^^^^

docs/filesystem.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Example
2121

2222
#include <skyr/url.hpp>
2323
#include <skyr/filesystem/path.hpp>
24-
#include <iostream>
24+
#include <print>
2525

2626
int main() {
2727
auto path = std::filesystem::path("/usr/bin/clang");
2828
auto url = skyr::filesystem::from_path(path).value();
29-
std::cout << url << std::endl;
29+
std::println(url);
3030
}
3131

3232
API

docs/index.rst

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ This library provides:
1414
- A `skyr::url` class that implements a generic URL parser,
1515
conforming with the WhatWG URL specification
1616
- URL serialization and comparison
17+
- **Immutable URL transformations** with `with_*` methods for functional-style URL building
18+
- **URL sanitization** methods to remove credentials, fragments, and query parameters
19+
- **Custom `std::format` support** with format specifiers for URL components
1720
- Percent encoding and decoding functions
1821
- IDNA and Punycode functions for domain name parsing
19-
- Basic Unicode conversion functions
22+
- Unicode conversion utilities
2023

2124
Quick Start
2225
-----------
2326

24-
This project requires the availability of a C++17 compliant compiler
25-
and standard library.
27+
This project requires a **C++23 compliant compiler** (GCC 13+, Clang 19+, MSVC 2022+)
28+
and has **zero external dependencies** for core URL parsing.
2629

2730
1. Download ``vcpkg`` and install the dependencies
2831
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -45,36 +48,24 @@ and standard library.
4548
// url_test.cpp
4649

4750
#include <skyr/url.hpp>
48-
#include <skyr/percent_encoding/percent_decode.hpp>
49-
#include <iostream>
51+
#include <skyr/url_format.hpp>
52+
#include <print>
5053

5154
int main() {
52-
using namespace skyr::literals;
53-
54-
try {
55-
auto url =
56-
"http://sub.example.إختبار:8090/\xcf\x80?a=1&c=2&b=\xe2\x80\x8d\xf0\x9f\x8c\x88"_url;
57-
58-
std::cout << "Protocol: " << url.protocol() << std::endl;
59-
60-
std::cout << "Domain? " << std::boolalpha << url.is_domain() << std::endl;
61-
std::cout << "Domain: " << url.hostname() << std::endl;
62-
std::cout << "Domain: "
63-
<< skyr::domain_to_u8(url.hostname()).value() << std::endl;
64-
65-
std::cout << "Port: " << url.port<std::uint16_t>().value() << std::endl;
66-
67-
std::cout << "Pathname: "
68-
<< skyr::percent_decode<std::string>(url.pathname()).value() << std::endl;
69-
70-
std::cout << "Search parameters" << std::endl;
71-
const auto &search = url.search_parameters();
72-
for (const auto &[key, value] : search) {
73-
std::cout << " " << "key: " << key << ", value = " << value << std::endl;
74-
}
75-
}
76-
catch (const skyr::url_parse_error &e) {
77-
std::cout << e.code().message() << std::endl;
55+
auto url = skyr::url("http://sub.example.إختبار:8090/\xcf\x80?a=1&c=2&b=\xe2\x80\x8d\xf0\x9f\x8c\x88");
56+
57+
// Using std::format support
58+
std::println("Scheme: {:s}", url);
59+
std::println("Domain? {}", url.is_domain());
60+
std::println("Domain: {:h}", url); // Encoded (punycode)
61+
std::println("Domain: {:hd}", url); // Decoded (unicode)
62+
std::println("Port: {:p}", url);
63+
std::println("Pathname: {:Pd}", url); // Decoded pathname
64+
65+
std::println("\nSearch parameters:");
66+
const auto &search = url.search_parameters();
67+
for (const auto &[key, value] : search) {
68+
std::println(" key: {}, value = {}", key, value);
7869
}
7970
}
8071

@@ -85,12 +76,12 @@ and standard library.
8576
8677
# CMakeLists.txt
8778
79+
cmake_minimum_required(VERSION 3.21)
8880
project(my_project)
8981
90-
find_package(tl-expected CONFIG REQUIRED)
9182
find_package(skyr-url CONFIG REQUIRED)
9283
93-
set(CMAKE_CXX_STANDARD 17)
84+
set(CMAKE_CXX_STANDARD 23)
9485
9586
add_executable(url_test url_test.cpp)
9687
target_link_libraries(url_test PRIVATE skyr::skyr-url)
@@ -112,13 +103,13 @@ and standard library.
112103
Design objectives
113104
^^^^^^^^^^^^^^^^^
114105

115-
* Uses modern C++17 features
116-
* Cross-platform
117-
* Easy to use and read
118-
* Compliant to the the WhatWG URL standard
119-
* Works naturally with Unicode strings
120-
* Uses modern CMake and is available as a dependency using a package
121-
manager
106+
* Uses modern C++23 features (``std::expected``, ``std::format``, ``std::ranges``)
107+
* Header-only library with zero external dependencies
108+
* Cross-platform (Linux, macOS, Windows)
109+
* Easy to use and read with immutable, functional-style API
110+
* Compliant with the WhatWG URL specification
111+
* Works naturally with Unicode strings (IDNA/Punycode support)
112+
* Uses modern CMake and is available via vcpkg
122113

123114
Documentation
124115
-------------

docs/network.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Example
2020
.. code-block:: c++
2121

2222
#include <skyr/url.hpp>
23-
#include <iostream>
23+
#include <print>
2424
#include <cassert>
2525

2626
int main() {
2727
using namespace skyr::literals;
2828

2929
auto url = "http://[1080:0:0:0:8:800:200C:417A]:8090/"_url;
3030
assert(url.is_ipv6_address());
31-
std::cout << "IPv6 Host: " << urlhostname() << std::endl;
31+
std::println("IPv6 Host: {}", url.hostname());
3232
}
3333

3434
API

docs/percent_encoding.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ Example
2222

2323
#include <skyr/url.hpp>
2424
#include <skyr/percent_encoding/percent_decode.hpp>
25-
#include <iostream>
25+
#include <print>
2626

2727
int main() {
2828
using namespace skyr::literals;
2929

3030
auto url = "http://www.example.org/\xcf\x80/"_url;
31-
std::cout << skyr::percent_decode<std::string>(url.pathname()).value() << std::endl;
31+
std::println(skyr::percent_decode<std::string>(url.pathname()).value());
3232
}
3333

3434
API

docs/url.rst

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ Description
55
-----------
66

77
The ``skyr::url`` class parses a URL in the constructor and provides
8-
a rich interface to access and process the URL components. The
9-
``skyr::url`` constructor throws a ``skyr::url_parse_error`` on failure.
8+
a rich interface to access and process the URL components. The library
9+
uses C++23 ``std::expected`` for error handling, providing type-safe
10+
error propagation without exceptions.
11+
12+
Key features:
13+
14+
* Immutable URL transformations with ``with_*`` methods
15+
* URL sanitization methods to remove credentials, fragments, and query parameters
16+
* Custom ``std::format`` support with format specifiers for URL components
17+
* Percent encoding and decoding
18+
* IDNA and Punycode for internationalized domain names
1019

1120
Headers
1221
-------
@@ -15,29 +24,67 @@ Headers
1524

1625
#include <skyr/url.hpp>
1726

18-
Example
19-
-------
27+
Basic Example
28+
-------------
2029

2130
.. code-block:: c++
2231

2332
#include <skyr/url.hpp>
24-
#include <iostream>
33+
#include <print>
2534

2635
int main() {
27-
using namespace skyr::literals;
36+
auto url = skyr::url("http://example.com/path?query=1");
2837

29-
try {
30-
auto url = "http://example.com/"_url;
38+
std::println("Scheme: {}", url.scheme());
39+
std::println("Hostname: {}", url.hostname());
40+
std::println("Pathname: {}", url.pathname());
41+
std::println("Search: {}", url.search());
42+
}
3143

32-
std::cout << "Protocol: " << url.protocol() << std::endl;
33-
std::cout << "Hostname: " << url.hostname() << std::endl;
34-
std::cout << "Pathname: " << url.pathname() << std::endl;
35-
}
36-
catch (const skyr::url_parse_error &e) {
37-
std::cout << e.code().message() << std::endl;
44+
Immutable Transformations
45+
--------------------------
46+
47+
.. code-block:: c++
48+
49+
#include <skyr/url.hpp>
50+
#include <print>
51+
52+
int main() {
53+
auto dev_url = skyr::url("http://localhost:3000/api/v1/users");
54+
55+
// Transform development URL to production
56+
auto prod_url = dev_url.with_scheme("https")
57+
.and_then([](auto&& u) { return u.with_hostname("api.example.com"); })
58+
.and_then([](auto&& u) { return u.with_port(""); })
59+
.and_then([](auto&& u) { return u.with_pathname("/api/v2/users"); });
60+
61+
if (prod_url) {
62+
std::println("Production: {}", prod_url->href());
3863
}
3964
}
4065

66+
URL Sanitization
67+
----------------
68+
69+
.. code-block:: c++
70+
71+
#include <skyr/url.hpp>
72+
#include <print>
73+
74+
int main() {
75+
auto url = skyr::url("http://user:pass@example.com/path?debug=true&id=123#section");
76+
77+
// Remove credentials and fragment
78+
auto safe_url = url.sanitize();
79+
std::println("{}", safe_url.href());
80+
// Output: http://example.com/path?debug=true&id=123
81+
82+
// Chain operations to remove specific parameters
83+
auto clean_url = url.sanitize().without_params({"debug"});
84+
std::println("{}", clean_url.href());
85+
// Output: http://example.com/path?id=123
86+
}
87+
4188
API
4289
---
4390

include/skyr/core/host.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class host {
6060
}
6161

6262
/// Constructor
63-
/// \param hsost An empty host
63+
/// \param host An empty host
6464
constexpr explicit host(empty_host host) : host_(host) {
6565
}
6666

0 commit comments

Comments
 (0)