Skip to content

Commit d044ad9

Browse files
authored
docs: API docs (#58)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 0fce37d commit d044ad9

9 files changed

Lines changed: 472 additions & 92 deletions

File tree

‎.readthedocs.yaml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version, and other tools you might need
8+
build:
9+
os: ubuntu-lts-latest
10+
tools:
11+
python: "3.14"
12+
13+
# Build documentation in the "docs/" directory with Sphinx
14+
sphinx:
15+
configuration: docs/conf.py
16+
17+
python:
18+
install:
19+
- requirements: docs/requirements.txt
20+
21+
formats: all

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ All notable changes to this project will be documented in this file.
2525
* New dict `RFC3987_SYNTAX_TERM_VALIDATORS` mapping `RFC3987_SYNTAX_TERMS` to validator function (via [#49])
2626
* Performance
2727
* Public symbols use lazy loading (via [#43], [#59])
28+
* Docs:
29+
* Added docstrings to public API (via [#58])
2830
* Tests
2931
* Add grammar regression tests (via [#48])
3032

@@ -36,6 +38,7 @@ All notable changes to this project will be documented in this file.
3638
[#50]: https://github.com/jkowalleck/rfc3987-syntax2/pull/50
3739
[#51]: https://github.com/jkowalleck/rfc3987-syntax2/pull/51
3840
[#52]: https://github.com/jkowalleck/rfc3987-syntax2/pull/52
41+
[#58]: https://github.com/jkowalleck/rfc3987-syntax2/pull/58
3942
[#59]: https://github.com/jkowalleck/rfc3987-syntax2/pull/59
4043

4144
## v1.2.0 - 2026-07-16

‎docs/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/_build

‎docs/conf.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import tomllib
2+
from pathlib import Path
3+
from datetime import datetime
4+
5+
6+
_ROOT = Path(__file__).resolve().parents[1]
7+
_pyproject = tomllib.loads((_ROOT / "pyproject.toml").read_text(encoding="utf-8"))
8+
9+
project = _pyproject["project"]["name"]
10+
author = ", ".join(a["name"] for a in _pyproject["project"].get("authors", [])) or "Unknown"
11+
copyright = f"{datetime.now().year}, {author}"
12+
13+
release = _pyproject["project"].get("version", "-dev")
14+
15+
16+
extensions = [
17+
"sphinx.ext.autodoc",
18+
# "sphinx.ext.viewcode",
19+
"autoapi.extension",
20+
"sphinx_rtd_theme",
21+
"myst_parser",
22+
]
23+
24+
source_suffix = ['.rst', '.md']
25+
26+
autoapi_type = 'python'
27+
autoapi_dirs = ['../src/rfc3987_syntax2']
28+
# see https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html#confval-autoapi_options
29+
autoapi_options = [
30+
'show-module-summary',
31+
'members',
32+
'undoc-members',
33+
'inherited-members',
34+
'show-inheritance',
35+
'imported-members'
36+
]
37+
38+
39+
# List of patterns, relative to source directory, that match files and
40+
# directories to ignore when looking for source files.
41+
# This pattern also affects html_static_path and html_extra_path.
42+
# see https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-exclude_patterns
43+
exclude_patterns = [
44+
'_dev', # internal docs
45+
'_build', # build target
46+
'.*', '**/.*', # dotfiles and folders
47+
'Thumbs.db', '**/Thumbs.db',
48+
]
49+
50+
# The theme to use for HTML and HTML Help pages. See the documentation for
51+
# a list of builtin themes.
52+
#
53+
html_theme = 'sphinx_rtd_theme'
54+

‎docs/index.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. include:: ../README.md
2+
:parser: myst_parser.sphinx_
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
:titlesonly:
8+
9+
autoapi/index

‎docs/requirements.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
myst-parser>=5.1.0,<6
4+
sphinx>=9,<10
5+
sphinx-autoapi>=3,<4
6+
sphinx-rtd-theme>=3,<4

‎src/rfc3987_syntax2/__init__.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
# Copyright (c) 2026 Jan Kowalleck - modifications and maintenance
33
# SPDX-License-Identifier: MIT
44

5-
from typing import Any
5+
"""
6+
Re-export of :mod:`.syntax_helpers`
7+
"""
8+
9+
from typing import Any, TYPE_CHECKING
610

711
from . import syntax_helpers as _syntax_helpers
812

913
__all__ = _syntax_helpers.__all__
1014

1115
_EXPORTS_SH = frozenset(_syntax_helpers.__all__)
1216

17+
if TYPE_CHECKING:
18+
from .syntax_helpers import *
19+
# cannot simply re-export - need to respect lazy-loading
1320

1421
def __getattr__(name: str) -> Any:
1522
if name in _EXPORTS_SH:

0 commit comments

Comments
 (0)