Skip to content

Python/mkdocs init #257

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions python/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to MkDocs

For full documentation visit [mkdocs.org](https://www.mkdocs.org).

## Commands

* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.

## Project layout

mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
3 changes: 3 additions & 0 deletions python/griffe_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from griffe_extensions.sync_stubs_inspector import InspectSpecificObjects

__all__ = ["InspectSpecificObjects"]
21 changes: 21 additions & 0 deletions python/griffe_extensions/sync_stubs_inspector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import griffe

logger = griffe.get_logger("griffe_inspect_specific_objects")


class InspectSpecificObjects(griffe.Extension):
"""Only inspect specific objects (such as ones with stubs)"""

def __init__(self, paths: list[str]) -> None:
self.objects = paths

def on_instance(self, *, obj: griffe.Object, **kwargs) -> None:
if obj.path not in self.objects:
return

# Skip over the stub files themselves
if str(obj.filepath).endswith(".pyi"):
return
# Load the stub file instead of importing the .py
inspected_module = griffe.inspect(obj.module.path, filepath=obj.filepath)
obj.parent.set_member(obj.name, inspected_module[obj.name])
5 changes: 0 additions & 5 deletions python/lib/sift_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
from sift_client.client import SiftClient
from sift_client.transport import SiftConnectionConfig

__all__ = [
"SiftClient",
"SiftConnectionConfig",
]
10 changes: 10 additions & 0 deletions python/lib/sift_client/_internal/sync_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import asyncio
import inspect
import sys
from functools import wraps
from typing import Any, Type, TypeVar

Expand Down Expand Up @@ -61,6 +62,7 @@ def _run(self, coro):
"__doc__": f"Sync counterpart to `{name}`.\n\n{cls.__doc__ or ''}",
"__init__": __init__,
"_run": _run,
"__qualname__": sync_name, # Add __qualname__ to help static analyzers
}

# helper to wrap an async method and make into a sync method
Expand Down Expand Up @@ -134,7 +136,15 @@ def sync_prop(self, _prop_name=prop_name):

namespace[name] = _wrap_sync(name)

# Create the sync class
sync_class = type(sync_name, (object,), namespace) # noqa

# Register the class in the module's globals
# This helps static analysis tools recognize it as a proper class
if module in sys.modules:
module_globals = sys.modules[module].__dict__
module_globals[sync_name] = sync_class

_registered.append(SyncAPIRegistration(async_cls=cls, sync_cls=sync_class))

return sync_class
1 change: 1 addition & 0 deletions python/lib/sift_client/resources/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion python/lib/sift_client/resources/sync_stubs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This package contains synchronous versions of all async API classes.
"""

from sift_client._internal.sync_wrapper import generate_sync_api
from sift_client._internal.sync_wrapper import generate_sync_api as generate_sync_api
from sift_client.resources import AssetsAPIAsync, PingAPIAsync

PingAPI = generate_sync_api(PingAPIAsync, "PingAPI")
Expand Down
2 changes: 2 additions & 0 deletions python/lib/sift_client/resources/sync_stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from typing import Any
from sift_client.client import SiftClient
from sift_client.types.asset import Asset, AssetUpdate


class AssetsAPI:
"""
Sync counterpart to `AssetsAPIAsync`.
Expand Down Expand Up @@ -131,6 +132,7 @@ class AssetsAPI:
"""
...


class PingAPI:
"""
Sync counterpart to `PingAPIAsync`.
Expand Down
1 change: 1 addition & 0 deletions python/lib/sift_client/util/cel_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def greater_than(field: str, value: int | float | datetime) -> str:
return f"{field} > {as_string}"



def less_than(field: str, value: int | float | datetime) -> str:
"""
Generates a CEL expression that checks whether a numeric or datetime field is less than a given value.
Expand Down
69 changes: 69 additions & 0 deletions python/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
site_name: Sift Python Client Library
repo_url: https://github.com/sift-stack/sift/tree/main/python
copyright: "Copyright 2025 Sift Stack, Inc."
theme:
name: material
palette:
# Palette toggle for light mode
- scheme: default
primary: grey
accent: deep orange
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for dark mode
- scheme: slate
primary: black
accent: deep orange
toggle:
icon: material/brightness-4
name: Switch to light mode
logo: https://avatars.githubusercontent.com/u/105525178?s=200&v=4
features:
- navigation.tabs
- navigation.sections
- toc.follow
- navigation.top
- search.suggest

nav:
- Home: index.md

plugins:
- search
- autorefs
- mkdocstrings:
default_handler: python
handlers:
python:
options:
load_external_modules: true
show_source: false
find_stubs_package: true
show_if_no_docstring: true
filters: "public"
show_submodules: false
# Styling
group_by_category: true
docstring_section_style: spacy
docstring_style: "google"
heading_level: 1
merge_init_into_class: true
separate_signature: true
show_root_heading: true
show_signature_annotations: true
signature_crossrefs: true
show_symbol_type_heading: true
show_symbol_type_toc: true
summary: true
# Custom Griffe extension to only inspect sync_stubs
extensions:
- griffe_extensions/sync_stubs_inspector.py:InspectSpecificObjects:
paths:
- sift_client.resources.sync_stubs


- api-autonav:
modules: [ lib/sift_client ] #, lib/sift ]
exclude_private: true
nav_item_prefix: ""
1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ build = ["pdoc==14.5.0", "build==1.2.1"]
openssl = ["pyOpenSSL<24.0.0", "types-pyOpenSSL<24.0.0", "cffi~=1.14"]
tdms = ["npTDMS~=1.9"]
rosbags = ["rosbags~=0.0"]
docs = ["mkdocs", "mkdocs-material", "mkdocstrings[python]", "mkdocs-include-markdown-plugin"]

[build-system]
requires = ["setuptools"]
Expand Down
Loading