Skip to content
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
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
workflow_dispatch:

jobs:
build-docs:
name: Build Sphinx Documentation
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"

- name: Build documentation
run: |
cd docs
sphinx-build -b html source build/html

- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: documentation
path: docs/build/html/
retention-days: 7
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Read the Docs configuration file for python-introspect
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- docs
9 changes: 9 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sphinx build outputs
build/
_build/

# Generated API documentation
source/api/generated/

# Sphinx cache
.doctrees/
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/source/_static/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file ensures the _static directory is tracked by git
# Sphinx needs this directory to exist for html_static_path
2 changes: 2 additions & 0 deletions docs/source/_templates/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file ensures the _templates directory is tracked by git
# Sphinx needs this directory to exist for templates_path
42 changes: 42 additions & 0 deletions docs/source/api/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
API Reference
=============

This section contains the complete API reference for python-introspect.

python_introspect package
=========================

.. automodule:: python_introspect
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

python_introspect.signature_analyzer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: python_introspect.signature_analyzer
:members:
:undoc-members:
:show-inheritance:
:no-index:

python_introspect.unified_parameter_analyzer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: python_introspect.unified_parameter_analyzer
:members:
:undoc-members:
:show-inheritance:
:no-index:

python_introspect.exceptions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: python_introspect.exceptions
:members:
:undoc-members:
:show-inheritance:
:no-index:
86 changes: 86 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys

# Add the project root to the path so Sphinx can find the package
sys.path.insert(0, os.path.abspath("../.."))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "python-introspect"
copyright = "2025, Tristan Simas"
author = "Tristan Simas"
release = "0.1.0"
version = "0.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.doctest",
"sphinx_rtd_theme",
]

# Napoleon settings for Google/NumPy style docstrings
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = True
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_ivar = True
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_preprocess_types = True
napoleon_type_aliases = None
napoleon_attr_annotations = True

# Autodoc settings
autodoc_default_options = {
"members": True,
"member-order": "bysource",
"special-members": "__init__",
"undoc-members": True,
"exclude-members": "__weakref__",
}

# Autosummary settings
autosummary_generate = True

# Intersphinx mapping for linking to other projects' documentation
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}

templates_path = ["_templates"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

# Theme options
html_theme_options = {
"navigation_depth": 4,
"collapse_navigation": False,
"sticky_navigation": True,
"includehidden": True,
"titles_only": False,
}

# Syntax highlighting
pygments_style = "sphinx"
55 changes: 55 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.. python-introspect documentation master file

Welcome to python-introspect's documentation!
==============================================

**python-introspect** is a pure Python introspection toolkit for function signatures,
dataclasses, and type hints. It provides powerful utilities for analyzing Python code
structures at runtime.

Features
--------

* **Function Signature Analysis**: Deep inspection of function parameters, return types, and annotations
* **Dataclass Introspection**: Extract and analyze dataclass fields and metadata
* **Type Hint Processing**: Work with Python's type hints and annotations
* **Pure Python**: No external dependencies required
* **Comprehensive**: Handles complex signatures including kwargs, varargs, and nested types

Quick Start
-----------

Install the package:

.. code-block:: bash

pip install python-introspect

Basic usage:

.. code-block:: python

from python_introspect import SignatureAnalyzer

def example_function(a: int, b: str = "default") -> bool:
"""Example function."""
return True

analyzer = SignatureAnalyzer(example_function)
print(analyzer.get_parameter_info())

Contents
--------

.. toctree::
:maxdepth: 2
:caption: Contents:

api/modules

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ dev = [
"mypy>=1.0",
]
docs = [
"mkdocs>=1.5.0",
"mkdocs-material>=9.0.0",
"sphinx>=7.0.0",
"sphinx-rtd-theme>=2.0.0",
"sphinx-autodoc-typehints>=1.24.0",
]

[project.urls]
Expand Down
Loading