Skip to content

Updated library documentation #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.7.0] - 2020-04-16

### Added

- A function to convert an encoded domain to Unicode
- Functions to convert a query string to and from a JSON object
- A lot more documentation

### Changed

- Code style changes

## [1.6.0] - 2020-04-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.14)

project(
skyr-url
VERSION 1.6.0
VERSION 1.7.0
HOMEPAGE_URL https://cpp-netlib.github.io/url
DESCRIPTION "A C++ library that implements the WhatWG URL specification"
LANGUAGES CXX
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Windows:
## License

This library is released under the Boost Software License (please see
http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt
http://boost.org/LICENSE_1_0.txt or the accompanying [LICENSE_1_0.txt](LICENSE_1_0.txt)
file for the full text).

## Why *skyr*?
Expand All @@ -224,9 +224,7 @@ itself was randomly chosen.
## Contact

Any questions about this library can be addressed to the cpp-netlib
[developers mailing list]. Issues can be filed using Github at
http://github.com/cpp-netlib/url/issues.
[developers mailing list]([email protected]). Issues can
be filed on our [GitHub page](http://github.com/cpp-netlib/url/issues).

You can also contact me via Twitter [@glynos](https://twitter.com/glynos).

[developers mailing list]: [email protected]
70 changes: 14 additions & 56 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,22 @@ find_package(Doxygen REQUIRED)
find_package(Pandoc REQUIRED)
find_package(Sphinx REQUIRED)

set(DOC_FILES
# Copy RST files
foreach(doc_file
_build
_static
_templates
index.rst
unicode.rst
idna.rst
domain.rst
encoding.rst
encoding_u8_view.rst
encoding_u16_view.rst
encoding_byte_transform.rst
encoding_u16_transform.rst
encoding_u32_transform.rst
url.rst
url_class.rst
url_record.rst
url_error_codes.rst
url_search_parameters.rst
)

# Copy RST files
foreach(doc_file ${DOC_FILES})
core.rst
domain.rst
network.rst
percent_encoding.rst
filesystem.rst
json.rst)
file(COPY ${doc_file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endforeach()

# Generate API documentation using Doxygen
configure_file(
Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
Expand All @@ -47,48 +36,17 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)

add_custom_target(
doxygen ALL
doc ALL
COMMAND
${DOXYGEN}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
COMMENT
"Generating documentation with Doxygen"
)

# Convert markdown to RST
SET(
GENERATED_FROM_MARKDOWN
readme.rst
changelog.rst
)

foreach (file_name ${GENERATED_FROM_MARKDOWN})
skyr_remove_extension(${file_name} basename)
string(TOUPPER ${basename} basename_upper)
set(target ${basename})
string(PREPEND target "doc_")
add_custom_target(
${target}
pandoc ${PROJECT_SOURCE_DIR}/${basename_upper}.md -f markdown -t rst -s -o ${CMAKE_CURRENT_BINARY_DIR}/${file_name}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
BYPRODUCTS
${CMAKE_CURRENT_BINARY_DIR}/${file_name}
COMMENT
"Generating RST file with pandoc" VERBATIM
)
endforeach()

# Bring it all together using Sphinx
add_custom_target(
doc ALL
COMMAND
${PANDOC_EXECUTABLE} ${PROJECT_SOURCE_DIR}/CHANGELOG.md -f markdown -t rst -s -o ${CMAKE_CURRENT_BINARY_DIR}/changelog.rst
COMMAND
${SPHINX_EXECUTABLE} -M html ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND
touch ${CMAKE_CURRENT_BINARY_DIR}/html/.nojekyll
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
doxygen ${GENERATED_FROM_MARKDOWN}
COMMENT
"Generating documentation with Sphinx"
"Generating documentation with Doxygen and Sphinx"
)
26 changes: 8 additions & 18 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Skyr URL"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER =
PROJECT_NUMBER = @skyr-url_VERSION@

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down Expand Up @@ -829,23 +829,13 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = @PROJECT_SOURCE_DIR@/include/skyr/config.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/version.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/domain.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/idna.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/errors.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/ranges/transforms/byte_transform.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/ranges/transforms/u16_transform.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/ranges/transforms/u32_transform.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/ranges/views/u8_view.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/unicode/ranges/views/u16_view.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url/url_error.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url/url_parse.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url/url_record.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url/url_search_parameters.hpp \
@PROJECT_SOURCE_DIR@/include/skyr/url/url_serialize.hpp
INPUT = @PROJECT_SOURCE_DIR@/include/skyr/ \
@PROJECT_SOURCE_DIR@/include/skyr/core/ \
@PROJECT_SOURCE_DIR@/include/skyr/domain/ \
@PROJECT_SOURCE_DIR@/include/skyr/network/ \
@PROJECT_SOURCE_DIR@/include/skyr/percent_encoding/ \
@PROJECT_SOURCE_DIR@/include/skyr/filesystem/ \
@PROJECT_SOURCE_DIR@/include/skyr/json/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
71 changes: 69 additions & 2 deletions docs/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,75 @@ html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

html_theme_options = {
# Navigation bar title. (Default: ``project`` value)
'navbar_title': "Skyr URL",

# Tab name for entire site. (Default: "Site")
'navbar_site_name': "Site",

# A list of tuples containing pages or urls to link to.
# Valid tuples should be in the following forms:
# (name, page) # a link to a page
# (name, "/aa/bb", 1) # a link to an arbitrary relative url
# (name, "http://example.com", True) # arbitrary absolute url
# Note the "1" or "True" value above as the third argument to indicate
# an arbitrary url.
'navbar_links': [
("GitHub", "https://github.com/cpp-netlib/url/", True),
],

# Render the next and previous page links in navbar. (Default: true)
'navbar_sidebarrel': True,

# Render the current pages TOC in the navbar. (Default: true)
'navbar_pagenav': True,

# Tab name for the current pages TOC. (Default: "Page")
'navbar_pagenav_name': "Page",

# Global TOC depth for "site" navbar tab. (Default: 1)
# Switching to -1 shows all levels.
'globaltoc_depth': 2,

# Include hidden TOCs in Site navbar?
#
# Note: If this is "false", you cannot have mixed ``:hidden:`` and
# non-hidden ``toctree`` directives in the same page, or else the build
# will break.
#
# Values: "true" (default) or "false"
'globaltoc_includehidden': "true",

# HTML navbar class (Default: "navbar") to attach to <div> element.
# For black navbar, do "navbar navbar-inverse"
'navbar_class': "navbar navbar-inverse",

# Fix navigation bar to top of page?
# Values: "true" (default) or "false"
'navbar_fixed_top': "true",

# Location of link to source.
# Options are "nav" (default), "footer" or anything else to exclude.
'source_link_position': "nav",

# Bootswatch (http://bootswatch.com/) theme.
#
# Options are nothing (default) or the name of a valid theme
# such as "cosmo" or "sandstone".
#
# The set of valid themes depend on the version of Bootstrap
# that's used (the next config option).
#
# Currently, the supported themes are:
# - Bootstrap 2: https://bootswatch.com/2
# - Bootstrap 3: https://bootswatch.com/3
'bootswatch_theme': "flatly",

# Choose Bootstrap version.
# Values: "3" (default) or "2" (in quotes)
'bootstrap_version': "3",
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down
67 changes: 67 additions & 0 deletions docs/core.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Core
====

Description
-----------

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

Use these functions directly if your needs are simple. Use the
`skyr::url` class for more complex operations, including
Unicode encoding and decoding.

Headers
-------

.. code-block:: c++

#include <skyr/core/url_record.hpp>
#include <skyr/core/parse.hpp>
#include <skyr/core/serialize.hpp>


Example
-------

.. code-block:: c++

#include <skyr/core/url_record.hpp>
#include <skyr/core/parse.hpp>
#include <skyr/core/serialize.hpp>
#include <iostream>

int main() {
auto url = skyr::url_parse("http://example.org/");
std::cout << url << std::endl;
std::cout << "Scheme: " << url.scheme << std::endl;
std::cout << "Hostname: " == url.host.value());
std::cout << "Pathname: ";
for (const auto &path : url.path) {
<< std::cout << "/" << path;
}
std::cout << std::endl;

std::cout << "Serializer: " << skyr::serialize(url) << std::endl;
}

API
---

`skyr::url_record` class
^^^^^^^^^^^^^^^^^^^^^^^^

.. doxygenclass:: skyr::v1::url_record
:members:

`skyr::url_record` functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. doxygenfunction:: skyr::swap(url_record&, url_record&)

.. doxygenfunction:: skyr::parse

.. doxygenfunction:: skyr::serialize
Loading