Skip to content

Commit a7ceaf4

Browse files
authored
Add URL builder functions (#178)
* Add URL builder functions * Update Doxygen documentation * Add automated documentation publishing workflow * Update documentation * Fix with_method_tests inputs * Simplify includes by grouping headers
1 parent 1dfede3 commit a7ceaf4

32 files changed

Lines changed: 2183 additions & 651 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build-and-deploy:
14+
name: Build and Deploy Documentation
15+
runs-on: ubuntu-24.04
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Install system dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y \
27+
doxygen \
28+
pandoc \
29+
python3 \
30+
python3-pip \
31+
ninja-build
32+
33+
- name: Install Python documentation dependencies
34+
run: |
35+
python3 -m pip install --upgrade pip
36+
python3 -m pip install \
37+
sphinx \
38+
sphinx_bootstrap_theme \
39+
breathe \
40+
recommonmark
41+
42+
- name: Install vcpkg
43+
run: |
44+
git clone https://github.com/Microsoft/vcpkg.git
45+
./vcpkg/bootstrap-vcpkg.sh
46+
47+
- name: Configure CMake
48+
run: |
49+
cmake \
50+
-B build \
51+
-G Ninja \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
54+
.
55+
56+
- name: Build documentation
57+
run: cmake --build build --target doc
58+
59+
- name: Deploy to GitHub Pages
60+
uses: peaceiris/actions-gh-pages@v4
61+
with:
62+
github_token: ${{ secrets.GITHUB_TOKEN }}
63+
publish_dir: ./build/docs/html
64+
publish_branch: gh-pages
65+
user_name: 'github-actions[bot]'
66+
user_email: 'github-actions[bot]@users.noreply.github.com'
67+
commit_message: 'Deploy documentation from ${{ github.sha }}'

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ Key build options:
6464
- `skyr_BUILD_TESTS` (ON): Build tests
6565
- `skyr_BUILD_WPT` (OFF): Build Web Platform Tests runner
6666
- `skyr_BUILD_BENCHMARKS` (OFF): Build performance benchmarks
67-
- `skyr_ENABLE_FILESYSTEM_FUNCTIONS` (ON): Enable filesystem::path conversion
68-
- `skyr_ENABLE_JSON_FUNCTIONS` (ON): Enable JSON serialization
6967
- `skyr_BUILD_WITHOUT_EXCEPTIONS` (OFF): Build without exceptions
7068

69+
**Note**: Filesystem functions are always available (C++23 guarantees `std::filesystem`). JSON functions are automatically enabled when `nlohmann-json` is found.
70+
7171
## Testing
7272

7373
### Run All Tests

CMakeLists.txt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ option(skyr_BUILD_WITHOUT_EXCEPTIONS "Build without exceptions." OFF)
3535
option(skyr_BUILD_WITHOUT_RTTI "Build without RTTI." OFF)
3636
option(skyr_USE_STATIC_CRT "Use static C Runtime library (/MT or MTd)." ON)
3737
option(skyr_BUILD_WITH_LLVM_LIBCXX "Instruct Clang to use LLVM's implementation of C++ standard library" OFF)
38-
option(skyr_ENABLE_FILESYSTEM_FUNCTIONS "Enable functions to convert URL to std::filesystem::path" ON)
39-
option(skyr_ENABLE_JSON_FUNCTIONS "Enable functions to convert URL components to JSON" ON)
4038
option(skyr_ENABLE_SANITIZERS "Enable sanitizers (address, undefined, etc.) for tests and examples" OFF)
4139
option(skyr_CXX_STANDARD_LIBRARY "Path to non-system C++ standard library" "")
4240

@@ -51,13 +49,14 @@ if (skyr_IS_TOP_LEVEL_PROJECT)
5149
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5250
endif()
5351

54-
if (skyr_ENABLE_JSON_FUNCTIONS)
55-
find_package(nlohmann_json CONFIG)
56-
if (NOT nlohmann_json_FOUND)
57-
message(WARNING "nlohmann_json not found. Install with: vcpkg install nlohmann-json")
58-
message(WARNING "JSON functions will be disabled.")
59-
set(skyr_ENABLE_JSON_FUNCTIONS OFF)
60-
endif()
52+
# JSON functions are optional and only available if nlohmann_json is found
53+
find_package(nlohmann_json CONFIG)
54+
if (NOT nlohmann_json_FOUND)
55+
message(WARNING "nlohmann_json not found. Install with: vcpkg install nlohmann-json")
56+
message(WARNING "JSON functions will be disabled.")
57+
set(skyr_HAS_JSON_SUPPORT OFF)
58+
else()
59+
set(skyr_HAS_JSON_SUPPORT ON)
6160
endif()
6261

6362
if (skyr_USE_STATIC_CRT AND (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC"))
@@ -129,11 +128,8 @@ write_basic_package_version_file(
129128
COMPATIBILITY SameMajorVersion
130129
ARCH_INDEPENDENT)
131130

132-
set(skyr_TARGETS skyr-url)
133-
if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
134-
list(APPEND skyr_TARGETS skyr-filesystem)
135-
endif()
136-
if (skyr_ENABLE_JSON_FUNCTIONS)
131+
set(skyr_TARGETS skyr-url skyr-filesystem)
132+
if (skyr_HAS_JSON_SUPPORT)
137133
list(APPEND skyr_TARGETS skyr-json)
138134
endif()
139135

@@ -177,10 +173,10 @@ install(
177173
include/skyr
178174
)
179175

180-
if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
181-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/skyr/filesystem" DESTINATION include/skyr)
182-
endif()
176+
# Filesystem functions are always installed (C++23 guarantees std::filesystem)
177+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/skyr/filesystem" DESTINATION include/skyr)
183178

184-
if (skyr_ENABLE_JSON_FUNCTIONS)
179+
# JSON functions are only installed if nlohmann_json is available
180+
if (skyr_HAS_JSON_SUPPORT)
185181
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/skyr/json" DESTINATION include/skyr)
186182
endif()

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ This library provides:
2020
* A ``skyr::url`` class that implements a generic URL parser,
2121
conforming with the [WhatWG URL specification](https://url.spec.whatwg.org/#url-class)
2222
* URL serialization and comparison
23+
* **Immutable URL transformations** with `with_*` methods for functional-style URL building
24+
* **URL sanitization** methods to remove credentials, fragments, and query parameters
25+
* **`std::format` support** with custom format specifiers for URL components
2326
* Percent encoding and decoding functions
2427
* IDNA and Punycode functions for domain name parsing
2528
* Unicode conversion utilities
@@ -36,7 +39,7 @@ This library provides:
3639
## Using the library
3740

3841
This project requires:
39-
* A **C++23 compliant compiler** (GCC 13+, Clang 16+, MSVC 2022 17.6+)
42+
* A **C++23 compliant compiler** (GCC 13+, Clang 19+, MSVC 2022+)
4043
* **No external dependencies** for core URL parsing
4144

4245
### ``vcpkg``
@@ -101,30 +104,25 @@ On Windows, replace the target with ``RUN_TESTS``:
101104
> cmake --build _build --target RUN_TESTS
102105
```
103106

104-
To install the library:
107+
To install the library (optional):
105108

106109
```bash
107110
> cmake --build _build --target install
108111
```
109112

110-
## Testing and installing the project
111-
112-
### Installing with `CMake` and `Ninja`
113+
Or with a custom install prefix:
113114

114115
```bash
115-
> cmake .. \
116+
> cmake \
117+
-B _build \
116118
-G "Ninja" \
117119
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/vcpkg/scripts/buildsystems/vcpkg.cmake \
118-
-DCMAKE_INSTALL_PREFIX=$PREFIX
119-
> ninja
120-
> ninja test
121-
> ninja install
120+
-DCMAKE_INSTALL_PREFIX=/your/install/path \
121+
.
122+
> cmake --build _build --target install
122123
```
123124

124-
Where `$PREFIX` is the location where you want to install the
125-
library. Depending on the location of `$PREFIX`, you may need to run
126-
the install command as an administrator (e.g. on Linux as `sudo`).
127-
125+
**Note**: Depending on the install location, you may need administrator privileges (e.g., `sudo` on Linux).
128126

129127
## Example usage
130128

cmake/skyr-url-functions.cmake

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,5 @@ function(skyr_remove_extension file_name basename)
2424
endfunction()
2525

2626

27-
function(skyr_check_filesystem compile_definitions)
28-
check_cxx_source_compiles("#include <filesystem>
29-
int main() { std::filesystem::path p{}; }" SKYR_USE_CXX17_FILESYSTEM)
30-
if (SKYR_USE_CXX17_FILESYSTEM)
31-
set(_compile_definitions "-DSKYR_USE_CXX17_FILESYSTEM")
32-
else()
33-
check_cxx_source_compiles("#include <experimental/filesystem>
34-
int main() { std::experimental::filesystem::path p{}; }" SKYR_USE_CXX17_EXPERIMENTAL_FILESYSTEM)
35-
if (SKYR_USE_CXX17_EXPERIMENTAL_FILESYSTEM)
36-
set(_compile_definitions "-DSKYR_USE_CXX17_EXPERIMENTAL_FILESYSTEM")
37-
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU OR ${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
38-
set(_compile_definitions "${_compile_definitions} -D_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM")
39-
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES MSVC)
40-
set(_compile_definitions "${_compile_definitions} -D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING")
41-
endif()
42-
else()
43-
message(FATAL_ERROR "Filesystem operations are not supported")
44-
endif()
45-
endif()
46-
47-
set(${compile_definitions} ${_compile_definitions} PARENT_SCOPE)
48-
endfunction()
27+
# Legacy filesystem check function removed
28+
# C++23 guarantees std::filesystem support, so no checks are needed

cmake/targets/skyr/CMakeLists.txt

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,36 @@ add_library(skyr::url ALIAS skyr-url)
2828

2929
#################################################
3030
# skyr-filesystem
31+
# Always available (C++23 guarantees std::filesystem)
3132
#################################################
3233

33-
if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
34-
add_library(skyr-filesystem INTERFACE)
34+
add_library(skyr-filesystem INTERFACE)
3535

36-
target_compile_features(skyr-filesystem INTERFACE cxx_std_23)
36+
target_compile_features(skyr-filesystem INTERFACE cxx_std_23)
3737

38-
skyr_check_filesystem(filesystem_definitions)
39-
target_compile_definitions(
40-
skyr-filesystem
41-
INTERFACE
42-
${filesystem_definitions}
43-
)
44-
45-
target_link_libraries(
46-
skyr-filesystem
47-
INTERFACE
48-
skyr-url
49-
)
38+
target_link_libraries(
39+
skyr-filesystem
40+
INTERFACE
41+
skyr-url
42+
)
5043

51-
target_include_directories(
52-
skyr-filesystem
53-
INTERFACE
54-
$<INSTALL_INTERFACE:include>
55-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
56-
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
57-
)
44+
target_include_directories(
45+
skyr-filesystem
46+
INTERFACE
47+
$<INSTALL_INTERFACE:include>
48+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
49+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
50+
)
5851

59-
add_library(skyr::skyr-filesystem ALIAS skyr-filesystem)
60-
add_library(skyr::filesystem ALIAS skyr-filesystem)
61-
endif()
52+
add_library(skyr::skyr-filesystem ALIAS skyr-filesystem)
53+
add_library(skyr::filesystem ALIAS skyr-filesystem)
6254

6355
#################################################
6456
# skyr-json
57+
# Optional - only available if nlohmann_json is found
6558
#################################################
6659

67-
if (skyr_ENABLE_JSON_FUNCTIONS)
60+
if (skyr_HAS_JSON_SUPPORT)
6861
add_library(skyr-json INTERFACE)
6962

7063
target_compile_features(skyr-json INTERFACE cxx_std_23)

0 commit comments

Comments
 (0)