diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 0000000..88587b3 --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,32 @@ +# Copyright 2024 - 2025 Khalil Estell and the libhal contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 📚 Deploy APIs + +on: + release: + types: + - published + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + +jobs: + api: + uses: libhal/ci/.github/workflows/api_docs_gen.yml@5.x.y + secrets: inherit diff --git a/docs/_static/extra.css b/docs/_static/extra.css new file mode 100644 index 0000000..ff49268 --- /dev/null +++ b/docs/_static/extra.css @@ -0,0 +1,62 @@ +h1 { + color: orange; + font-size: 2em; +} + + +/* anything related to the dark theme */ +html[data-theme="dark"] { + + /* whatever you want to change */ + img { + background: transparent !important; + } +} + +html[data-theme="light"] { + + /* whatever you want to change */ + img { + background: transparent !important; + } + + +} + +.md-typeset h2 { + font-size: 1.5em; +} + +a code { + color: #2980B9; +} + +a:hover code { + color: #3091d1; +} + +a:visited code { + color: #9B59B6; +} + +.md-header__topic { + font-size: 1.6em; + font-weight: 100 !important; +} + +.md-logo { + margin: 0px !important; + padding: 0px !important; +} + +.md-logo img { + height: 2.2rem !important; +} + +.md-tabs__link { + font-size: .8rem !important; +} + +.wy-nav-content { + max-width: none; +} diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000..3f20097 Binary files /dev/null and b/docs/_static/favicon.ico differ diff --git a/docs/_static/favicon.png b/docs/_static/favicon.png new file mode 100644 index 0000000..3f20097 Binary files /dev/null and b/docs/_static/favicon.png differ diff --git a/docs/_static/logo.png b/docs/_static/logo.png new file mode 100644 index 0000000..e65a2a3 Binary files /dev/null and b/docs/_static/logo.png differ diff --git a/docs/_templates/guide_links.html b/docs/_templates/guide_links.html new file mode 100644 index 0000000..a330956 --- /dev/null +++ b/docs/_templates/guide_links.html @@ -0,0 +1,68 @@ +{# Displays links to the top-level TOCtree elements, in the header navbar. #} + diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html new file mode 100644 index 0000000..7170ae5 --- /dev/null +++ b/docs/_templates/layout.html @@ -0,0 +1 @@ +{% extends "!layout.html" %} diff --git a/docs/api/async_context.md b/docs/api/async_context.md new file mode 100644 index 0000000..cea1a59 --- /dev/null +++ b/docs/api/async_context.md @@ -0,0 +1,55 @@ +# async_context + +## async::context + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenclass} v0::context +``` + +## async::basic_context + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenclass} v0::basic_context +``` + +## async::proxy_context + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenclass} v0::proxy_context +``` + +## async::exclusive_access + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenclass} v0::exclusive_access +``` + +## async::blocked_by + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenenum} v0::blocked_by +``` + +## async::future\ + +Defined in namespace `async::v0` + +*import async_context;* + +```{doxygenclass} v0::future +``` diff --git a/docs/api/index.rst b/docs/api/index.rst new file mode 100644 index 0000000..0965adf --- /dev/null +++ b/docs/api/index.rst @@ -0,0 +1,12 @@ +async_context API +=============== + +Defined in namespace ``async::v0`` + +*import async_context;* + +.. toctree:: + :caption: Types + :maxdepth: 2 + + async_context diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..103bc90 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,76 @@ +from sphinx.application import Sphinx +from pathlib import Path +import json +import os +import re + +if not os.environ.get('LIBHAL_API_VERSION'): + print("\nEnvironment variable 'LIBHAL_API_VERSION' must be set!") + exit(1) + +API_VERSION = os.environ.get('LIBHAL_API_VERSION') + +doxygen_conf = Path('doxygen.conf').read_text() +match = re.search(r'PROJECT_NAME\s*=\s*"([^"]+)"', doxygen_conf) +if not match: + print("\nCould not find PROJECT_NAME in doxygen.conf!") + exit(1) +LIBRARY_NAME = match.group(1) + +DEFAULT_SWITCHER_URL = f"https://libhal.github.io/api/{LIBRARY_NAME}/switcher.json" + +LOCAL_BUILD = os.environ.get('LIBHAL_LOCAL_BUILD') + +if LOCAL_BUILD: + switcher_url = "switcher.json" +else: + switcher_url = DEFAULT_SWITCHER_URL + +html_theme = 'pydata_sphinx_theme' +html_theme_options = { + "navbar_start": ["navbar-logo", "guide_links", "version-switcher"], + "navbar_center": ["navbar-nav"], + "navbar_end": ["navbar-icon-links"], + "navbar_persistent": ["search-button-field", "theme-switcher"], + "header_links_before_dropdown": 3, + "switcher": { + "json_url": switcher_url, + "version_match": API_VERSION, + }, + "check_switcher": False, +} + +extensions = ["breathe", "myst_parser"] + + +def write_local_switcher(app, exception): + if LOCAL_BUILD and exception is None: + outdir = Path(app.outdir) + (outdir / 'switcher.json').write_text( + json.dumps([{"version": API_VERSION, "url": "."}])) + + +def setup(app: Sphinx): + app.add_css_file("extra.css") + app.connect("build-finished", write_local_switcher) + + +html_css_files = [ + 'extra.css', +] +breathe_projects = {LIBRARY_NAME: "build/xml"} +breathe_default_project = LIBRARY_NAME +breathe_default_members = ('members',) +project = LIBRARY_NAME +source_suffix = { + '.rst': 'restructuredtext', + '.md': 'markdown' +} +master_doc = 'index' +exclude_patterns = ['.venv', 'build'] +highlight_language = 'c++' +html_static_path = ['_static'] +templates_path = ['_templates'] +todo_include_todos = False +html_favicon = "_static/favicon.ico" +html_logo = "_static/logo.png" diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b85dfed --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,15 @@ +async_context API documentation +======================================= + +**Welcome to async_context API documentation** + +`async_context` is a lightweight, C++23 coroutine library for embedded systems +and resource-constrained environments. Built with stack-based allocation to +avoid heap usage and designed to fit within a single cache line for optimal +performance. + +.. toctree:: + :caption: async_context Docs + :maxdepth: 5 + + async_context API diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..8ef1437 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +sphinx>=8.1.3 +pydata-sphinx-theme>=0.16.1 +myst_parser>=4.0.1 +breathe>=4.36.0