Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: daizutabi/mkapi
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.0.22
Choose a base ref
...
head repository: daizutabi/mkapi
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.0.23
Choose a head ref
  • 9 commits
  • 8 files changed
  • 1 contributor

Commits on Oct 14, 2024

  1. Use Python 3.13

    daizutabi committed Oct 14, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    0473c15 View commit details
  2. Update postCreate.sh

    daizutabi committed Oct 14, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    8c03c98 View commit details

Commits on Oct 15, 2024

  1. Update postCreate.sh

    daizutabi committed Oct 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    5976f46 View commit details

Commits on Nov 17, 2024

  1. Update pyproject.toml

    daizutabi committed Nov 17, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    8cf2e91 View commit details

Commits on Jan 14, 2025

  1. Update devcontainer

    daizutabi committed Jan 14, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    4d89a94 View commit details
  2. Update CI

    daizutabi committed Jan 14, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    eps1lon Sebastian "Sebbie" Silbermann
    Copy the full SHA
    d6be9e4 View commit details

Commits on Jan 17, 2025

  1. Don't skip the first constructor argument.

    daizutabi committed Jan 17, 2025
    Copy the full SHA
    39b7cfa View commit details
  2. Merge pull request #214 from daizutabi/213-first-constructor-argument

    Don't skip the first constructor argument.
    daizutabi authored Jan 17, 2025
    Copy the full SHA
    b7567a9 View commit details
  3. Update pyproject.toml

    daizutabi authored Jan 17, 2025
    Copy the full SHA
    761a1a7 View commit details
Showing with 43 additions and 18 deletions.
  1. +5 −4 .devcontainer/devcontainer.json
  2. +8 −2 .devcontainer/postCreate.sh
  3. +3 −3 .github/workflows/ci.yml
  4. +8 −1 example/mod_a.py
  5. +3 −3 pyproject.toml
  6. +1 −1 src/mkapi/parser.py
  7. +5 −4 src/mkapi/renderer.py
  8. +10 −0 tests/parser/test_signature.py
9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.12",
"image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu24.04",
"features": {
"ghcr.io/devcontainers-contrib/features/starship:1": {},
"ghcr.io/va-h/devcontainers-features/uv:1": {}
"ghcr.io/devcontainers-contrib/features/starship:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"fill-labs.dependi",
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"tamasfe.even-better-toml"
]
}
},
10 changes: 8 additions & 2 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh
#!/bin/bash

echo 'eval "$(starship init bash)"' >> ~/.bashrc
echo "alias ll='ls -alF'" >> ~/.bashrc
mkdir -p ~/.config
cp .devcontainer/starship.toml ~/.config
cp .devcontainer/starship.toml ~/.config

curl -LsSf https://astral.sh/uv/install.sh | sh
curl -LsSf https://astral.sh/ruff/install.sh | sh
source $HOME/.cargo/env
echo 'eval "$(uv generate-shell-completion bash)"' >> ~/.bashrc
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -30,12 +30,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install uv
run: pip install uv
- name: Install uv and ruff
run: pip install uv ruff
- name: Install the project
run: uv sync
- name: Ruff check
run: uv run ruff check .
run: ruff check
- name: Run test
run: uv run pytest -n 8 --junitxml=junit.xml
- name: Upload Codecov Results
9 changes: 8 additions & 1 deletion example/mod_a.py
Original file line number Diff line number Diff line change
@@ -11,11 +11,18 @@


class ClassA:
"""Class A."""

attr_a: str = "string"
"""Attribute A."""

def __init__(self, a: str):
"""Class A.
Args:
a: A string.
"""
self.attr_a = a

def method_a(self, x: Iterable[str], y: ClassB) -> ClassA:
"""Method A. Return `ClassA`.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"

[project]
name = "mkapi"
version = "3.0.22"
version = "3.0.23"
authors = [{ name = "daizutabi", email = "daizutabi@gmail.com" }]
description = "A plugin for MkDocs to generate API documentation"
readme = "README.md"
license = "MIT"
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: MkDocs",
@@ -43,7 +43,6 @@ dev-dependencies = [
"pytest-cov",
"pytest-randomly",
"pytest-xdist",
"ruff",
]

[tool.hatch.build.targets.sdist]
@@ -79,6 +78,7 @@ exclude = ["tests/examples/*.py", "example/*.py"]
select = ["ALL"]
unfixable = ["F401"]
ignore = [
"A005",
"ANN002",
"ANN003",
"ARG001",
2 changes: 1 addition & 1 deletion src/mkapi/parser.py
Original file line number Diff line number Diff line change
@@ -619,7 +619,7 @@ def _iter_signature(
prev_kind = None

for k, param in enumerate(obj.parameters):
if k == 0 and obj.kind in ["class", "method", "classmethod"]:
if k == 0 and obj.kind in ["method", "classmethod"]:
continue

yield from _iter_sep(param.kind, prev_kind)
9 changes: 5 additions & 4 deletions src/mkapi/renderer.py
Original file line number Diff line number Diff line change
@@ -246,12 +246,13 @@ def _get_source(
continue

if (
skip_self
and child is obj
(skip_self and child is obj)
or isinstance(obj, Attribute)
or not child.node
or child != obj
and (not is_child(child, obj) or child.module is not module)
or (
child != obj
and (not is_child(child, obj) or child.module is not module)
)
):
continue

10 changes: 10 additions & 0 deletions tests/parser/test_signature.py
Original file line number Diff line number Diff line change
@@ -103,3 +103,13 @@ def test_get_signature_skip_self():
s = get_signature(obj) # type: ignore
assert s[0].name == "(" # no self
assert s[1].name == ")"


def test_get_signature_dont_skip_self_class():
from mkapi.object import get_object
from mkapi.parser import get_signature

obj = get_object("example.sub.ClassA")
s = get_signature(obj) # type: ignore
assert s[0].name == "("
assert s[1].name == "a"