Skip to content

Commit

Permalink
Merge branch 'main' into lesser-qualified-links.
Browse files Browse the repository at this point in the history
Merge main to keep PR up to date
  • Loading branch information
Crozzers committed Jun 10, 2023
2 parents 649f622 + f2e2639 commit 3f4157a
Show file tree
Hide file tree
Showing 39 changed files with 946 additions and 972 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ updates:
interval: "monthly"
- package-ecosystem: pip
directory: "/"
open-pull-requests-limit: 9
schedule:
interval: "monthly"
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
py: 3.9.16
- os: ubuntu-latest
py: 3.8.16
- os: ubuntu-latest
py: 3.7.15
uses: mhils/workflows/.github/workflows/python-tox.yml@main
with:
cmd: tox -e py -- -vvv ${{ matrix.args }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

<!-- ✨ You do not need to add a pull request reference or an author, this will be added automatically by CI. ✨ -->

- Remove support for Python 3.7, which has reached end-of-life on 2023-06-27.
([#569](https://github.com/mitmproxy/pdoc/pull/569), @mhils)


## 2023-04-24: pdoc 13.1.1

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ API Documentation for Python Projects.
pip install pdoc
```

pdoc is compatible with Python 3.7 and newer.
pdoc is compatible with Python 3.8 and newer.


# Usage
Expand Down
6 changes: 3 additions & 3 deletions docs/make.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
from pathlib import Path
import shutil
import textwrap
from pathlib import Path

import pygments.formatters.html
import pygments.lexers.python
from jinja2 import Environment
from jinja2 import FileSystemLoader
from markupsafe import Markup
import pygments.formatters.html
import pygments.lexers.python

import pdoc.render

Expand Down
2 changes: 1 addition & 1 deletion examples/mkdocs/make.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import shutil
from pathlib import Path
import shutil

from pdoc import pdoc
from pdoc import render
Expand Down
6 changes: 4 additions & 2 deletions pdoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class GoldenRetriever(Dog):
You can find an example at
[`examples/custom-template/module.html.jinja2`](https://github.com/mitmproxy/pdoc/blob/main/examples/custom-template/module.html.jinja2).
### ...exclude submodules from being documented?
## ...exclude submodules from being documented?
If you would like to exclude specific submodules from the documentation, the recommended way is to specify `__all__` as
shown in the previous section. Alternatively, you can pass negative regular expression `!patterns` as part of the
Expand Down Expand Up @@ -466,7 +466,9 @@ def bark(self, loud: bool) -> None:
from pathlib import Path
from typing import overload

from pdoc import doc, extract, render
from pdoc import doc
from pdoc import extract
from pdoc import render


@overload
Expand Down
4 changes: 2 additions & 2 deletions pdoc/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from __future__ import annotations

import argparse
from pathlib import Path
import platform
import subprocess
import sys
import warnings
from pathlib import Path

from pdoc._compat import BooleanOptionalAction
import pdoc.doc
import pdoc.extract
import pdoc.render
import pdoc.web
from pdoc._compat import BooleanOptionalAction

if sys.stdout.isatty(): # pragma: no cover
red = "\x1b[31m"
Expand Down
28 changes: 3 additions & 25 deletions pdoc/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,6 @@ def __get__(self, instance, owner=None):
__class_getitem__ = classmethod(GenericAlias)
# ✂ end ✂

if sys.version_info >= (3, 8):
from typing import Literal, get_origin
else: # pragma: no cover
from typing import Generic

# There is no Literal on 3.7, so we just make one up. It should not be used anyways!

try:
from typing_extensions import Literal
except ImportError:
class Literal:
pass

# get_origin is adapted from
# https://github.com/python/cpython/blob/863eb7170b3017399fb2b786a1e3feb6457e54c2/Lib/typing.py#L1474-L1515
# with Annotations removed (not present in 3.7)
def get_origin(tp): # type: ignore
if isinstance(tp, GenericAlias):
return tp.__origin__
if tp is Generic:
return Generic
return None

if (3, 9) <= sys.version_info < (3, 9, 8) or (3, 10) <= sys.version_info < (3, 10, 1): # pragma: no cover
import inspect
Expand All @@ -145,7 +123,9 @@ def formatannotation(annotation) -> str:
class singledispatchmethod:
pass # pragma: no cover

if True:
if sys.version_info >= (3, 9):
from argparse import BooleanOptionalAction
else: # pragma: no cover
# https://github.com/python/cpython/pull/27672
from argparse import Action

Expand Down Expand Up @@ -197,8 +177,6 @@ def format_usage(self):
"UnionType",
"removesuffix",
"cached_property",
"get_origin",
"Literal",
"formatannotation",
"singledispatchmethod",
"BooleanOptionalAction",
Expand Down
25 changes: 13 additions & 12 deletions pdoc/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,43 @@
"""
from __future__ import annotations

from abc import ABCMeta
from abc import abstractmethod
from collections.abc import Callable
import dataclasses
import enum
from functools import wraps
import inspect
import os
from pathlib import Path
import pkgutil
import re
import sys
import textwrap
import traceback
import types
import warnings
from abc import ABCMeta
from abc import abstractmethod
from collections.abc import Callable
from functools import wraps
from pathlib import Path
from typing import Any
from typing import ClassVar
from typing import Generic
from typing import TypeVar
from typing import Union
from typing import get_origin
import warnings

from ._compat import cache
from ._compat import cached_property
from ._compat import formatannotation
from ._compat import get_origin
from ._compat import singledispatchmethod
from pdoc import doc_ast
from pdoc import doc_pyi
from pdoc import extract
from pdoc.doc_types import empty
from pdoc.doc_types import GenericAlias
from pdoc.doc_types import NonUserDefinedCallables
from pdoc.doc_types import empty
from pdoc.doc_types import resolve_annotations
from pdoc.doc_types import safe_eval_type

from ._compat import cache
from ._compat import cached_property
from ._compat import formatannotation
from ._compat import singledispatchmethod


def _include_fullname_in_traceback(f):
"""
Expand Down
22 changes: 6 additions & 16 deletions pdoc/doc_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
from __future__ import annotations

import ast
import inspect
import types
import warnings
from collections.abc import Iterable
from collections.abc import Iterator
from dataclasses import dataclass
import inspect
from itertools import tee
from itertools import zip_longest
import types
from typing import Any
from typing import overload
from typing import TypeVar
from typing import overload
import warnings

import pdoc

from ._compat import ast_unparse
from ._compat import cache

Expand Down Expand Up @@ -135,11 +136,6 @@ def _walk_tree(
and isinstance(b.value.value, str)
):
var_docstrings[name] = inspect.cleandoc(b.value.value).strip()
elif isinstance(b, ast.Expr) and isinstance(
b.value, ast.Str
): # pragma: no cover
# Python <= 3.7
var_docstrings[name] = inspect.cleandoc(b.value.s).strip()
return AstInfo(
var_docstrings,
func_docstrings,
Expand Down Expand Up @@ -339,20 +335,14 @@ def _init_nodes(tree: ast.FunctionDef) -> Iterator[ast.AST]:
yield ast.Assign(
[ast.Name(a.targets[0].attr)],
value=a.value,
# not available on Python 3.7
type_comment=getattr(a, "type_comment", None),
type_comment=a.type_comment,
)
elif (
isinstance(a, ast.Expr)
and isinstance(a.value, ast.Constant)
and isinstance(a.value.value, str)
):
yield a
elif isinstance(a, ast.Expr) and isinstance(
a.value, ast.Str
): # pragma: no cover
# Python <= 3.7
yield a
else:
yield ast.Pass()

Expand Down
7 changes: 4 additions & 3 deletions pdoc/doc_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"""
from __future__ import annotations

from pathlib import Path
import sys
import traceback
import types
import warnings
from pathlib import Path
from unittest import mock
import warnings

from ._compat import cache
from pdoc import doc

from ._compat import cache


@cache
def find_stub_file(module_name: str) -> Path | None:
Expand Down
12 changes: 6 additions & 6 deletions pdoc/doc_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
import operator
import sys
import types
import typing
import warnings
from types import BuiltinFunctionType
from types import ModuleType
from typing import _GenericAlias # type: ignore
from typing import Any
import typing
from typing import TYPE_CHECKING
from typing import Any
from typing import Literal
from typing import _GenericAlias # type: ignore
from typing import get_origin
import warnings

from . import extract
from ._compat import GenericAlias
from ._compat import get_origin
from ._compat import Literal
from ._compat import UnionType
from .doc_ast import type_checking_sections

Expand Down
4 changes: 2 additions & 2 deletions pdoc/docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import inspect
import mimetypes
import os
import re
import warnings
from pathlib import Path
import re
from textwrap import dedent
from textwrap import indent
import warnings

from ._compat import cache

Expand Down
12 changes: 6 additions & 6 deletions pdoc/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
"""
from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from contextlib import contextmanager
import importlib.util
import io
import linecache
import os
from pathlib import Path
import pkgutil
import platform
import re
Expand All @@ -17,13 +22,8 @@
import sys
import traceback
import types
import warnings
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from contextlib import contextmanager
from pathlib import Path
from unittest.mock import patch
import warnings

import pdoc.doc_ast
import pdoc.docstrings
Expand Down
6 changes: 3 additions & 3 deletions pdoc/render.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from __future__ import annotations

import os
import types
import warnings
from pathlib import Path
import types
from typing import Literal
from typing import Mapping
from typing import cast
import warnings

import jinja2
from jinja2 import Environment
from jinja2 import FileSystemLoader

import pdoc.doc
import pdoc.docstrings
from pdoc._compat import Literal
from pdoc.render_helpers import DefaultMacroExtension
from pdoc.render_helpers import defuse_unsafe_reprs
from pdoc.render_helpers import edit_url
Expand Down
Loading

0 comments on commit 3f4157a

Please sign in to comment.