From 7b0745211f701f0ea6e9bc94a62c3d2c0c15a5eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:47:35 +0100 Subject: [PATCH] Bump the dependencies group with 11 updates (#672) * Bump the dependencies group with 11 updates Bumps the dependencies group with 11 updates: | Package | From | To | | --- | --- | --- | | [cachetools](https://github.com/tkem/cachetools) | `5.3.2` | `5.3.3` | | [coverage[toml]](https://github.com/nedbat/coveragepy) | `7.4.1` | `7.4.3` | | [hypothesis](https://github.com/HypothesisWorks/hypothesis) | `6.97.4` | `6.98.15` | | [markupsafe](https://github.com/pallets/markupsafe) | `2.1.4` | `2.1.5` | | [pytest](https://github.com/pytest-dev/pytest) | `8.0.0` | `8.0.2` | | [ruff](https://github.com/astral-sh/ruff) | `0.1.15` | `0.3.0` | | [tox](https://github.com/tox-dev/tox) | `4.12.1` | `4.13.0` | | [types-docutils](https://github.com/python/typeshed) | `0.20.0.20240201` | `0.20.0.20240227` | | [types-setuptools](https://github.com/python/typeshed) | `69.0.0.20240125` | `69.1.0.20240301` | | [typing-extensions](https://github.com/python/typing_extensions) | `4.9.0` | `4.10.0` | | [virtualenv](https://github.com/pypa/virtualenv) | `20.25.0` | `20.25.1` | Updates `cachetools` from 5.3.2 to 5.3.3 - [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst) - [Commits](https://github.com/tkem/cachetools/compare/v5.3.2...v5.3.3) Updates `coverage[toml]` from 7.4.1 to 7.4.3 - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.4.1...7.4.3) Updates `hypothesis` from 6.97.4 to 6.98.15 - [Release notes](https://github.com/HypothesisWorks/hypothesis/releases) - [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.97.4...hypothesis-python-6.98.15) Updates `markupsafe` from 2.1.4 to 2.1.5 - [Release notes](https://github.com/pallets/markupsafe/releases) - [Changelog](https://github.com/pallets/markupsafe/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/markupsafe/compare/2.1.4...2.1.5) Updates `pytest` from 8.0.0 to 8.0.2 - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.0.0...8.0.2) Updates `ruff` from 0.1.15 to 0.3.0 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.1.15...v0.3.0) Updates `tox` from 4.12.1 to 4.13.0 - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/4.12.1...4.13.0) Updates `types-docutils` from 0.20.0.20240201 to 0.20.0.20240227 - [Commits](https://github.com/python/typeshed/commits) Updates `types-setuptools` from 69.0.0.20240125 to 69.1.0.20240301 - [Commits](https://github.com/python/typeshed/commits) Updates `typing-extensions` from 4.9.0 to 4.10.0 - [Release notes](https://github.com/python/typing_extensions/releases) - [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md) - [Commits](https://github.com/python/typing_extensions/compare/4.9.0...4.10.0) Updates `virtualenv` from 20.25.0 to 20.25.1 - [Release notes](https://github.com/pypa/virtualenv/releases) - [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst) - [Commits](https://github.com/pypa/virtualenv/compare/20.25.0...20.25.1) --- updated-dependencies: - dependency-name: cachetools dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: coverage[toml] dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: hypothesis dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: markupsafe dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: pytest dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: tox dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: types-docutils dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: types-setuptools dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: typing-extensions dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: virtualenv dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dependencies ... Signed-off-by: dependabot[bot] * [autofix.ci] apply automated fixes --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- examples/library-usage/foo.py | 1 + pdoc/__init__.py | 1 + pdoc/doc.py | 5 +- pdoc/doc_ast.py | 10 +- pdoc/doc_types.py | 1 + pdoc/docstrings.py | 1 + pdoc/extract.py | 1 + pdoc/search.py | 1 + pdoc/web.py | 1 + requirements-dev.txt | 22 +- test/testdata/demo_long.html | 957 +++++++++--------- test/testdata/demo_long.py | 1 + test/testdata/demopackage.html | 79 +- test/testdata/demopackage/__init__.py | 1 + test/testdata/demopackage/child_b.py | 1 + test/testdata/demopackage/child_c.py | 1 + test/testdata/demopackage2.py | 1 + test/testdata/demopackage_dir.html | 180 ++-- test/testdata/math_demo.html | 115 +-- test/testdata/math_demo.py | 1 + test/testdata/misc_py312.html | 125 +-- test/testdata/misc_py312.py | 1 + test/testdata/misc_py39.html | 135 +-- test/testdata/misc_py39.py | 1 + test/testdata/top_level_reimports.html | 11 +- test/testdata/top_level_reimports/__init__.py | 1 + test/testdata/visibility.html | 2 +- test/testdata/visibility.py | 2 +- 28 files changed, 843 insertions(+), 816 deletions(-) diff --git a/examples/library-usage/foo.py b/examples/library-usage/foo.py index df10fcc7..f03c0971 100644 --- a/examples/library-usage/foo.py +++ b/examples/library-usage/foo.py @@ -1,6 +1,7 @@ """ Example module. We use pure Python here, but this could also be a compiled native module. """ + import enum diff --git a/pdoc/__init__.py b/pdoc/__init__.py index 5b85dc6d..914db125 100644 --- a/pdoc/__init__.py +++ b/pdoc/__init__.py @@ -462,6 +462,7 @@ def bark(self, loud: bool) -> None: It is also possible to create `pdoc.doc.Module` objects directly and modify them before rendering. You can find an example in [`examples/library-usage`](https://github.com/mitmproxy/pdoc/tree/main/examples/library-usage). ''' + from __future__ import annotations __docformat__ = "markdown" # explicitly disable rST processing in the examples above. diff --git a/pdoc/doc.py b/pdoc/doc.py index a415c841..921e88de 100644 --- a/pdoc/doc.py +++ b/pdoc/doc.py @@ -15,6 +15,7 @@ This means they have a large set of attributes that are lazily computed on first access. By convention, all attributes are read-only, although this is not enforced at runtime. """ + from __future__ import annotations from abc import ABCMeta @@ -1030,7 +1031,9 @@ class Variable(Doc[None]): kind = "variable" - default_value: Any | empty # technically Any includes empty, but this conveys intent. + default_value: ( + Any | empty + ) # technically Any includes empty, but this conveys intent. """ The variable's default value. diff --git a/pdoc/doc_ast.py b/pdoc/doc_ast.py index c04bf56b..ff86e8fa 100644 --- a/pdoc/doc_ast.py +++ b/pdoc/doc_ast.py @@ -3,6 +3,7 @@ Parsing the AST is done to extract docstrings, type annotations, and variable declarations from `__init__`. """ + from __future__ import annotations import ast @@ -51,18 +52,15 @@ def _get_source(obj: Any) -> str: @overload -def parse(obj: types.ModuleType) -> ast.Module: - ... +def parse(obj: types.ModuleType) -> ast.Module: ... @overload -def parse(obj: types.FunctionType) -> ast.FunctionDef | ast.AsyncFunctionDef: - ... +def parse(obj: types.FunctionType) -> ast.FunctionDef | ast.AsyncFunctionDef: ... @overload -def parse(obj: type) -> ast.ClassDef: - ... +def parse(obj: type) -> ast.ClassDef: ... def parse(obj): diff --git a/pdoc/doc_types.py b/pdoc/doc_types.py index 7b2520f6..67d2c44b 100644 --- a/pdoc/doc_types.py +++ b/pdoc/doc_types.py @@ -5,6 +5,7 @@ [typing.ForwardRef](https://docs.python.org/3/library/typing.html#typing.ForwardRef) objects without raising an exception. """ + from __future__ import annotations import functools diff --git a/pdoc/docstrings.py b/pdoc/docstrings.py index ff0fa95a..db604bb6 100644 --- a/pdoc/docstrings.py +++ b/pdoc/docstrings.py @@ -10,6 +10,7 @@ That being said, please keep the complexity low and make sure that changes are accompanied by matching snapshot tests in `test/testdata/`. """ + from __future__ import annotations import base64 diff --git a/pdoc/extract.py b/pdoc/extract.py index d79e53e2..a8ca1ca1 100644 --- a/pdoc/extract.py +++ b/pdoc/extract.py @@ -3,6 +3,7 @@ that is it loads the correct module based on whatever the user specified, and provides the rest of pdoc with some additional module metadata. """ + from __future__ import annotations from collections.abc import Iterable diff --git a/pdoc/search.py b/pdoc/search.py index f4b5bf61..63fcff7c 100644 --- a/pdoc/search.py +++ b/pdoc/search.py @@ -41,6 +41,7 @@ If you wish to disable the search functionality, you can pass `--no-search` when invoking pdoc. """ + from __future__ import annotations from collections.abc import Callable diff --git a/pdoc/web.py b/pdoc/web.py index c3512e24..9679852a 100644 --- a/pdoc/web.py +++ b/pdoc/web.py @@ -5,6 +5,7 @@ so we are content with the builtin `http.server` module. It is a bit unergonomic compared to let's say flask, but good enough for our purposes. """ + from __future__ import annotations from collections.abc import Iterable diff --git a/requirements-dev.txt b/requirements-dev.txt index 5065878f..f6182ada 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,13 +6,13 @@ # attrs==23.2.0 # via hypothesis -cachetools==5.3.2 +cachetools==5.3.3 # via tox chardet==5.2.0 # via tox colorama==0.4.6 # via tox -coverage[toml]==7.4.1 +coverage[toml]==7.4.3 # via pytest-cov distlib==0.3.8 # via virtualenv @@ -20,13 +20,13 @@ filelock==3.13.1 # via # tox # virtualenv -hypothesis==6.97.4 +hypothesis==6.98.15 # via pdoc (pyproject.toml) iniconfig==2.0.0 # via pytest jinja2==3.1.3 # via pdoc (pyproject.toml) -markupsafe==2.1.4 +markupsafe==2.1.5 # via # jinja2 # pdoc (pyproject.toml) @@ -53,7 +53,7 @@ pygments==2.17.2 # via pdoc (pyproject.toml) pyproject-api==1.6.1 # via tox -pytest==8.0.0 +pytest==8.0.2 # via # pdoc (pyproject.toml) # pytest-cov @@ -62,19 +62,19 @@ pytest-cov==4.1.0 # via pdoc (pyproject.toml) pytest-timeout==2.2.0 # via pdoc (pyproject.toml) -ruff==0.1.15 +ruff==0.3.0 # via pdoc (pyproject.toml) sortedcontainers==2.4.0 # via hypothesis -tox==4.12.1 +tox==4.13.0 # via pdoc (pyproject.toml) -types-docutils==0.20.0.20240201 +types-docutils==0.20.0.20240227 # via types-pygments types-pygments==2.17.0.20240106 # via pdoc (pyproject.toml) -types-setuptools==69.0.0.20240125 +types-setuptools==69.1.0.20240301 # via types-pygments -typing-extensions==4.9.0 +typing-extensions==4.10.0 # via mypy -virtualenv==20.25.0 +virtualenv==20.25.1 # via tox diff --git a/test/testdata/demo_long.html b/test/testdata/demo_long.html index dd015e49..6fded176 100644 --- a/test/testdata/demo_long.html +++ b/test/testdata/demo_long.html @@ -251,263 +251,264 @@

A Second Section

20You can have multiple sections in your module docstring, 21which will also show up in the navigation. 22""" - 23from __future__ import annotations - 24 - 25import abc - 26from dataclasses import dataclass - 27from dataclasses import field - 28import enum - 29from functools import cached_property - 30import os - 31from typing import ClassVar - 32from typing import List - 33from typing import Optional - 34from typing import Sequence - 35from typing import TypeVar - 36from typing import Union - 37 - 38from pdoc._compat import cache - 39 - 40FOO_CONSTANT: int = 42 - 41""" - 42A happy constant. ✨ - 43pdoc documents constants with their type annotation and default value. - 44""" - 45 - 46FOO_SINGLETON: "Foo" - 47""" - 48This variable is annotated with a type only, but not assigned to a value. - 49We also haven't defined the associated type (`Foo`) yet, - 50so the type annotation in the code in the source code is actually a string literal: - 51 - 52```python - 53FOO_SINGLETON: "Foo" - 54``` - 55 - 56Similar to mypy, pdoc resolves - 57[string forward references](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references) - 58automatically. - 59""" - 60 - 61NO_DOCSTRING: int - 62# this variable has a type annotation but not docstring. - 63 + 23 + 24from __future__ import annotations + 25 + 26import abc + 27from dataclasses import dataclass + 28from dataclasses import field + 29import enum + 30from functools import cached_property + 31import os + 32from typing import ClassVar + 33from typing import List + 34from typing import Optional + 35from typing import Sequence + 36from typing import TypeVar + 37from typing import Union + 38 + 39from pdoc._compat import cache + 40 + 41FOO_CONSTANT: int = 42 + 42""" + 43A happy constant. ✨ + 44pdoc documents constants with their type annotation and default value. + 45""" + 46 + 47FOO_SINGLETON: "Foo" + 48""" + 49This variable is annotated with a type only, but not assigned to a value. + 50We also haven't defined the associated type (`Foo`) yet, + 51so the type annotation in the code in the source code is actually a string literal: + 52 + 53```python + 54FOO_SINGLETON: "Foo" + 55``` + 56 + 57Similar to mypy, pdoc resolves + 58[string forward references](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references) + 59automatically. + 60""" + 61 + 62NO_DOCSTRING: int + 63# this variable has a type annotation but not docstring. 64 - 65def a_simple_function(a: str) -> str: - 66 """ - 67 This is a basic module-level function. - 68 - 69 For a more complex example, take a look at `a_complex_function`! - 70 """ - 71 return a.upper() - 72 + 65 + 66def a_simple_function(a: str) -> str: + 67 """ + 68 This is a basic module-level function. + 69 + 70 For a more complex example, take a look at `a_complex_function`! + 71 """ + 72 return a.upper() 73 - 74T = TypeVar("T") - 75 + 74 + 75T = TypeVar("T") 76 - 77def a_complex_function( - 78 a: str, b: Union["Foo", str], *, c: Optional[T] = None - 79) -> Optional[T]: - 80 """ - 81 This is a function with a fairly complex signature, - 82 involving type annotations with `typing.Union`, a `typing.TypeVar` (~T), - 83 as well as a keyword-only arguments (*). - 84 """ - 85 return None - 86 + 77 + 78def a_complex_function( + 79 a: str, b: Union["Foo", str], *, c: Optional[T] = None + 80) -> Optional[T]: + 81 """ + 82 This is a function with a fairly complex signature, + 83 involving type annotations with `typing.Union`, a `typing.TypeVar` (~T), + 84 as well as a keyword-only arguments (*). + 85 """ + 86 return None 87 - 88class Foo: - 89 """ - 90 `Foo` is a basic class without any parent classes (except for the implicit `object` class). - 91 - 92 You will see in the definition of `Bar` that docstrings are inherited by default. - 93 - 94 Functions in the current scope can be referenced without prefix: `a_regular_function()`. - 95 """ - 96 - 97 an_attribute: Union[str, List["int"]] - 98 """A regular attribute with type annotations""" - 99 -100 a_class_attribute: ClassVar[str] = "lots of foo!" -101 """An attribute with a ClassVar annotation.""" -102 -103 def __init__(self) -> None: -104 """ -105 The constructor is currently always listed first as this feels most natural.""" -106 self.a_constructor_only_attribute: int = 42 -107 """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal.""" -108 -109 self.undocumented_constructor_attribute = 42 -110 a_complex_function("a", "Foo") -111 -112 def a_regular_function(self) -> "Foo": -113 """This is a regular method, returning the object itself.""" -114 return self -115 -116 @property -117 def a_property(self) -> str: -118 """This is a `@property` attribute. pdoc will display it as a variable.""" -119 return "true foo" -120 -121 @cached_property -122 def a_cached_property(self) -> str: -123 """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well.""" -124 return "true foo" -125 -126 @cache -127 def a_cached_function(self) -> str: -128 """This is method with `@cache` decoration.""" -129 return "true foo" -130 -131 @classmethod -132 def a_class_method(cls) -> int: -133 """This is what a `@classmethod` looks like.""" -134 return 24 -135 -136 @classmethod # type: ignore -137 @property -138 def a_class_property(cls) -> int: -139 """This is what a `@classmethod @property` looks like.""" -140 return 24 -141 -142 @staticmethod -143 def a_static_method(): -144 """This is what a `@staticmethod` looks like.""" -145 print("Hello World") -146 + 88 + 89class Foo: + 90 """ + 91 `Foo` is a basic class without any parent classes (except for the implicit `object` class). + 92 + 93 You will see in the definition of `Bar` that docstrings are inherited by default. + 94 + 95 Functions in the current scope can be referenced without prefix: `a_regular_function()`. + 96 """ + 97 + 98 an_attribute: Union[str, List["int"]] + 99 """A regular attribute with type annotations""" +100 +101 a_class_attribute: ClassVar[str] = "lots of foo!" +102 """An attribute with a ClassVar annotation.""" +103 +104 def __init__(self) -> None: +105 """ +106 The constructor is currently always listed first as this feels most natural.""" +107 self.a_constructor_only_attribute: int = 42 +108 """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal.""" +109 +110 self.undocumented_constructor_attribute = 42 +111 a_complex_function("a", "Foo") +112 +113 def a_regular_function(self) -> "Foo": +114 """This is a regular method, returning the object itself.""" +115 return self +116 +117 @property +118 def a_property(self) -> str: +119 """This is a `@property` attribute. pdoc will display it as a variable.""" +120 return "true foo" +121 +122 @cached_property +123 def a_cached_property(self) -> str: +124 """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well.""" +125 return "true foo" +126 +127 @cache +128 def a_cached_function(self) -> str: +129 """This is method with `@cache` decoration.""" +130 return "true foo" +131 +132 @classmethod +133 def a_class_method(cls) -> int: +134 """This is what a `@classmethod` looks like.""" +135 return 24 +136 +137 @classmethod # type: ignore +138 @property +139 def a_class_property(cls) -> int: +140 """This is what a `@classmethod @property` looks like.""" +141 return 24 +142 +143 @staticmethod +144 def a_static_method(): +145 """This is what a `@staticmethod` looks like.""" +146 print("Hello World") 147 -148class Bar(Foo): -149 bar: str -150 """A new attribute defined on this subclass.""" -151 -152 class Baz: -153 """ -154 This class is an attribute of `Bar`. -155 To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation -156 (but not in the navigation). -157 -158 It should be noted that inner classes are a pattern you most often want to avoid in Python. -159 Think about moving stuff in a new package instead! -160 -161 This class has no __init__ method defined, so pdoc will not show a constructor. -162 """ -163 -164 def wat(self): -165 """A regular method. Above, you see what happens if a class has no constructor defined and -166 no constructor docstring.""" -167 +148 +149class Bar(Foo): +150 bar: str +151 """A new attribute defined on this subclass.""" +152 +153 class Baz: +154 """ +155 This class is an attribute of `Bar`. +156 To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation +157 (but not in the navigation). +158 +159 It should be noted that inner classes are a pattern you most often want to avoid in Python. +160 Think about moving stuff in a new package instead! +161 +162 This class has no __init__ method defined, so pdoc will not show a constructor. +163 """ +164 +165 def wat(self): +166 """A regular method. Above, you see what happens if a class has no constructor defined and +167 no constructor docstring.""" 168 -169async def i_am_async(self) -> int: -170 """ -171 This is an example of an async function. -172 -173 - Knock, knock -174 - An async function -175 - Who's there? -176 """ -177 raise NotImplementedError -178 +169 +170async def i_am_async(self) -> int: +171 """ +172 This is an example of an async function. +173 +174 - Knock, knock +175 - An async function +176 - Who's there? +177 """ +178 raise NotImplementedError 179 -180@cache -181def fib(n): -182 """ -183 This is an example of decorated function. Decorators are included in the documentation as well. -184 This is often useful when documenting web APIs, for example. -185 """ -186 if n < 2: -187 return n -188 return fib(n - 1) + fib(n - 2) -189 +180 +181@cache +182def fib(n): +183 """ +184 This is an example of decorated function. Decorators are included in the documentation as well. +185 This is often useful when documenting web APIs, for example. +186 """ +187 if n < 2: +188 return n +189 return fib(n - 1) + fib(n - 2) 190 -191def security(test=os.environ): -192 """ -193 Default values are generally rendered using repr(), -194 but some special cases -- like os.environ -- are overridden to avoid leaking sensitive data. -195 """ -196 return False -197 +191 +192def security(test=os.environ): +193 """ +194 Default values are generally rendered using repr(), +195 but some special cases -- like os.environ -- are overridden to avoid leaking sensitive data. +196 """ +197 return False 198 -199class DoubleInherit(Foo, Bar.Baz, abc.ABC): -200 """This is an example of a class that inherits from multiple parent classes.""" -201 +199 +200class DoubleInherit(Foo, Bar.Baz, abc.ABC): +201 """This is an example of a class that inherits from multiple parent classes.""" 202 -203CONST_B = "yes" -204"""A constant without type annotation""" -205 -206CONST_NO_DOC = "SHOULD NOT APPEAR" -207 +203 +204CONST_B = "yes" +205"""A constant without type annotation""" +206 +207CONST_NO_DOC = "SHOULD NOT APPEAR" 208 -209@dataclass -210class DataDemo: -211 """ -212 This is an example for a dataclass. -213 -214 As usual, you can link to individual properties: `DataDemo.a`. -215 """ -216 -217 a: int -218 """Again, we can document individual properties with docstrings.""" -219 a2: Sequence[str] -220 # This property has a type annotation but is not documented. -221 a3 = "a3" -222 # This property has a default value but is not documented. -223 a4: str = "a4" -224 # This property has a type annotation and a default value but is not documented. -225 b: bool = field(repr=False, default=True) -226 """This property is assigned to `dataclasses.field()`, which works just as well.""" -227 +209 +210@dataclass +211class DataDemo: +212 """ +213 This is an example for a dataclass. +214 +215 As usual, you can link to individual properties: `DataDemo.a`. +216 """ +217 +218 a: int +219 """Again, we can document individual properties with docstrings.""" +220 a2: Sequence[str] +221 # This property has a type annotation but is not documented. +222 a3 = "a3" +223 # This property has a default value but is not documented. +224 a4: str = "a4" +225 # This property has a type annotation and a default value but is not documented. +226 b: bool = field(repr=False, default=True) +227 """This property is assigned to `dataclasses.field()`, which works just as well.""" 228 -229@dataclass -230class DataDemoExtended(DataDemo): -231 c: str = "42" -232 """A new attribute.""" -233 +229 +230@dataclass +231class DataDemoExtended(DataDemo): +232 c: str = "42" +233 """A new attribute.""" 234 -235class EnumDemo(enum.Enum): -236 """ -237 This is an example of an Enum. -238 -239 As usual, you can link to individual properties: `GREEN`. -240 """ -241 -242 RED = 1 -243 """I am the red.""" -244 GREEN = 2 -245 """I am green.""" -246 BLUE = enum.auto() -247 +235 +236class EnumDemo(enum.Enum): +237 """ +238 This is an example of an Enum. +239 +240 As usual, you can link to individual properties: `GREEN`. +241 """ +242 +243 RED = 1 +244 """I am the red.""" +245 GREEN = 2 +246 """I am green.""" +247 BLUE = enum.auto() 248 -249def embed_image(): -250 """ -251 This docstring includes an embedded image: -252 -253 ``` -254 ![pdoc logo](../docs/logo.png) -255 ``` -256 -257 ![pdoc logo](../../docs/logo.png) -258 """ -259 +249 +250def embed_image(): +251 """ +252 This docstring includes an embedded image: +253 +254 ``` +255 ![pdoc logo](../docs/logo.png) +256 ``` +257 +258 ![pdoc logo](../../docs/logo.png) +259 """ 260 -261def admonitions(): -262 """ -263 pdoc also supports basic reStructuredText admonitions: -264 -265 ``` -266 .. note/warning/danger:: Optional title -267 Body text -268 ``` -269 -270 .. note:: -271 Hi there! -272 -273 .. warning:: Be Careful! -274 This warning has both a title and content. -275 -276 .. danger:: -277 Danger ahead. -278 -279 """ +261 +262def admonitions(): +263 """ +264 pdoc also supports basic reStructuredText admonitions: +265 +266 ``` +267 .. note/warning/danger:: Optional title +268 Body text +269 ``` +270 +271 .. note:: +272 Hi there! +273 +274 .. warning:: Be Careful! +275 This warning has both a title and content. +276 +277 .. danger:: +278 Danger ahead. +279 +280 """ @@ -573,13 +574,13 @@

A Second Section

-
66def a_simple_function(a: str) -> str:
-67    """
-68    This is a basic module-level function.
-69
-70    For a more complex example, take a look at `a_complex_function`!
-71    """
-72    return a.upper()
+            
67def a_simple_function(a: str) -> str:
+68    """
+69    This is a basic module-level function.
+70
+71    For a more complex example, take a look at `a_complex_function`!
+72    """
+73    return a.upper()
 
@@ -601,15 +602,15 @@

A Second Section

-
78def a_complex_function(
-79    a: str, b: Union["Foo", str], *, c: Optional[T] = None
-80) -> Optional[T]:
-81    """
-82    This is a function with a fairly complex signature,
-83    involving type annotations with `typing.Union`, a `typing.TypeVar` (~T),
-84    as well as a keyword-only arguments (*).
-85    """
-86    return None
+            
79def a_complex_function(
+80    a: str, b: Union["Foo", str], *, c: Optional[T] = None
+81) -> Optional[T]:
+82    """
+83    This is a function with a fairly complex signature,
+84    involving type annotations with `typing.Union`, a `typing.TypeVar` (~T),
+85    as well as a keyword-only arguments (*).
+86    """
+87    return None
 
@@ -631,64 +632,64 @@

A Second Section

-
 89class Foo:
- 90    """
- 91    `Foo` is a basic class without any parent classes (except for the implicit `object` class).
- 92
- 93    You will see in the definition of `Bar` that docstrings are inherited by default.
- 94
- 95    Functions in the current scope can be referenced without prefix: `a_regular_function()`.
- 96    """
- 97
- 98    an_attribute: Union[str, List["int"]]
- 99    """A regular attribute with type annotations"""
-100
-101    a_class_attribute: ClassVar[str] = "lots of foo!"
-102    """An attribute with a ClassVar annotation."""
-103
-104    def __init__(self) -> None:
-105        """
-106        The constructor is currently always listed first as this feels most natural."""
-107        self.a_constructor_only_attribute: int = 42
-108        """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal."""
-109
-110        self.undocumented_constructor_attribute = 42
-111        a_complex_function("a", "Foo")
-112
-113    def a_regular_function(self) -> "Foo":
-114        """This is a regular method, returning the object itself."""
-115        return self
-116
-117    @property
-118    def a_property(self) -> str:
-119        """This is a `@property` attribute. pdoc will display it as a variable."""
-120        return "true foo"
-121
-122    @cached_property
-123    def a_cached_property(self) -> str:
-124        """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well."""
-125        return "true foo"
-126
-127    @cache
-128    def a_cached_function(self) -> str:
-129        """This is method with `@cache` decoration."""
-130        return "true foo"
-131
-132    @classmethod
-133    def a_class_method(cls) -> int:
-134        """This is what a `@classmethod` looks like."""
-135        return 24
-136
-137    @classmethod  # type: ignore
-138    @property
-139    def a_class_property(cls) -> int:
-140        """This is what a `@classmethod @property` looks like."""
-141        return 24
-142
-143    @staticmethod
-144    def a_static_method():
-145        """This is what a `@staticmethod` looks like."""
-146        print("Hello World")
+            
 90class Foo:
+ 91    """
+ 92    `Foo` is a basic class without any parent classes (except for the implicit `object` class).
+ 93
+ 94    You will see in the definition of `Bar` that docstrings are inherited by default.
+ 95
+ 96    Functions in the current scope can be referenced without prefix: `a_regular_function()`.
+ 97    """
+ 98
+ 99    an_attribute: Union[str, List["int"]]
+100    """A regular attribute with type annotations"""
+101
+102    a_class_attribute: ClassVar[str] = "lots of foo!"
+103    """An attribute with a ClassVar annotation."""
+104
+105    def __init__(self) -> None:
+106        """
+107        The constructor is currently always listed first as this feels most natural."""
+108        self.a_constructor_only_attribute: int = 42
+109        """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal."""
+110
+111        self.undocumented_constructor_attribute = 42
+112        a_complex_function("a", "Foo")
+113
+114    def a_regular_function(self) -> "Foo":
+115        """This is a regular method, returning the object itself."""
+116        return self
+117
+118    @property
+119    def a_property(self) -> str:
+120        """This is a `@property` attribute. pdoc will display it as a variable."""
+121        return "true foo"
+122
+123    @cached_property
+124    def a_cached_property(self) -> str:
+125        """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well."""
+126        return "true foo"
+127
+128    @cache
+129    def a_cached_function(self) -> str:
+130        """This is method with `@cache` decoration."""
+131        return "true foo"
+132
+133    @classmethod
+134    def a_class_method(cls) -> int:
+135        """This is what a `@classmethod` looks like."""
+136        return 24
+137
+138    @classmethod  # type: ignore
+139    @property
+140    def a_class_property(cls) -> int:
+141        """This is what a `@classmethod @property` looks like."""
+142        return 24
+143
+144    @staticmethod
+145    def a_static_method():
+146        """This is what a `@staticmethod` looks like."""
+147        print("Hello World")
 
@@ -710,14 +711,14 @@

A Second Section

-
104    def __init__(self) -> None:
-105        """
-106        The constructor is currently always listed first as this feels most natural."""
-107        self.a_constructor_only_attribute: int = 42
-108        """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal."""
-109
-110        self.undocumented_constructor_attribute = 42
-111        a_complex_function("a", "Foo")
+            
105    def __init__(self) -> None:
+106        """
+107        The constructor is currently always listed first as this feels most natural."""
+108        self.a_constructor_only_attribute: int = 42
+109        """This attribute is defined in the constructor only, but still picked up by pdoc's AST traversal."""
+110
+111        self.undocumented_constructor_attribute = 42
+112        a_complex_function("a", "Foo")
 
@@ -788,9 +789,9 @@

A Second Section

-
113    def a_regular_function(self) -> "Foo":
-114        """This is a regular method, returning the object itself."""
-115        return self
+            
114    def a_regular_function(self) -> "Foo":
+115        """This is a regular method, returning the object itself."""
+116        return self
 
@@ -808,10 +809,10 @@

A Second Section

-
117    @property
-118    def a_property(self) -> str:
-119        """This is a `@property` attribute. pdoc will display it as a variable."""
-120        return "true foo"
+            
118    @property
+119    def a_property(self) -> str:
+120        """This is a `@property` attribute. pdoc will display it as a variable."""
+121        return "true foo"
 
@@ -829,10 +830,10 @@

A Second Section

-
122    @cached_property
-123    def a_cached_property(self) -> str:
-124        """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well."""
-125        return "true foo"
+            
123    @cached_property
+124    def a_cached_property(self) -> str:
+125        """This is a `@functools.cached_property` attribute. pdoc will display it as a variable as well."""
+126        return "true foo"
 
@@ -853,10 +854,10 @@

A Second Section

-
127    @cache
-128    def a_cached_function(self) -> str:
-129        """This is method with `@cache` decoration."""
-130        return "true foo"
+            
128    @cache
+129    def a_cached_function(self) -> str:
+130        """This is method with `@cache` decoration."""
+131        return "true foo"
 
@@ -877,10 +878,10 @@

A Second Section

-
132    @classmethod
-133    def a_class_method(cls) -> int:
-134        """This is what a `@classmethod` looks like."""
-135        return 24
+            
133    @classmethod
+134    def a_class_method(cls) -> int:
+135        """This is what a `@classmethod` looks like."""
+136        return 24
 
@@ -898,11 +899,11 @@

A Second Section

-
137    @classmethod  # type: ignore
-138    @property
-139    def a_class_property(cls) -> int:
-140        """This is what a `@classmethod @property` looks like."""
-141        return 24
+            
138    @classmethod  # type: ignore
+139    @property
+140    def a_class_property(cls) -> int:
+141        """This is what a `@classmethod @property` looks like."""
+142        return 24
 
@@ -923,10 +924,10 @@

A Second Section

-
143    @staticmethod
-144    def a_static_method():
-145        """This is what a `@staticmethod` looks like."""
-146        print("Hello World")
+            
144    @staticmethod
+145    def a_static_method():
+146        """This is what a `@staticmethod` looks like."""
+147        print("Hello World")
 
@@ -947,25 +948,25 @@

A Second Section

-
149class Bar(Foo):
-150    bar: str
-151    """A new attribute defined on this subclass."""
-152
-153    class Baz:
-154        """
-155        This class is an attribute of `Bar`.
-156        To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation
-157        (but not in the navigation).
-158
-159        It should be noted that inner classes are a pattern you most often want to avoid in Python.
-160        Think about moving stuff in a new package instead!
-161
-162        This class has no __init__ method defined, so pdoc will not show a constructor.
-163        """
-164
-165        def wat(self):
-166            """A regular method. Above, you see what happens if a class has no constructor defined and
-167            no constructor docstring."""
+            
150class Bar(Foo):
+151    bar: str
+152    """A new attribute defined on this subclass."""
+153
+154    class Baz:
+155        """
+156        This class is an attribute of `Bar`.
+157        To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation
+158        (but not in the navigation).
+159
+160        It should be noted that inner classes are a pattern you most often want to avoid in Python.
+161        Think about moving stuff in a new package instead!
+162
+163        This class has no __init__ method defined, so pdoc will not show a constructor.
+164        """
+165
+166        def wat(self):
+167            """A regular method. Above, you see what happens if a class has no constructor defined and
+168            no constructor docstring."""
 
@@ -1022,21 +1023,21 @@
Inherited Members
-
153    class Baz:
-154        """
-155        This class is an attribute of `Bar`.
-156        To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation
-157        (but not in the navigation).
-158
-159        It should be noted that inner classes are a pattern you most often want to avoid in Python.
-160        Think about moving stuff in a new package instead!
-161
-162        This class has no __init__ method defined, so pdoc will not show a constructor.
-163        """
-164
-165        def wat(self):
-166            """A regular method. Above, you see what happens if a class has no constructor defined and
-167            no constructor docstring."""
+            
154    class Baz:
+155        """
+156        This class is an attribute of `Bar`.
+157        To not create overwhelmingly complex trees, pdoc flattens the class hierarchy in the documentation
+158        (but not in the navigation).
+159
+160        It should be noted that inner classes are a pattern you most often want to avoid in Python.
+161        Think about moving stuff in a new package instead!
+162
+163        This class has no __init__ method defined, so pdoc will not show a constructor.
+164        """
+165
+166        def wat(self):
+167            """A regular method. Above, you see what happens if a class has no constructor defined and
+168            no constructor docstring."""
 
@@ -1062,9 +1063,9 @@
Inherited Members
-
165        def wat(self):
-166            """A regular method. Above, you see what happens if a class has no constructor defined and
-167            no constructor docstring."""
+            
166        def wat(self):
+167            """A regular method. Above, you see what happens if a class has no constructor defined and
+168            no constructor docstring."""
 
@@ -1086,15 +1087,15 @@
Inherited Members
-
170async def i_am_async(self) -> int:
-171    """
-172    This is an example of an async function.
-173
-174    - Knock, knock
-175    - An async function
-176    - Who's there?
-177    """
-178    raise NotImplementedError
+            
171async def i_am_async(self) -> int:
+172    """
+173    This is an example of an async function.
+174
+175    - Knock, knock
+176    - An async function
+177    - Who's there?
+178    """
+179    raise NotImplementedError
 
@@ -1121,15 +1122,15 @@
Inherited Members
-
181@cache
-182def fib(n):
-183    """
-184    This is an example of decorated function. Decorators are included in the documentation as well.
-185    This is often useful when documenting web APIs, for example.
-186    """
-187    if n < 2:
-188        return n
-189    return fib(n - 1) + fib(n - 2)
+            
182@cache
+183def fib(n):
+184    """
+185    This is an example of decorated function. Decorators are included in the documentation as well.
+186    This is often useful when documenting web APIs, for example.
+187    """
+188    if n < 2:
+189        return n
+190    return fib(n - 1) + fib(n - 2)
 
@@ -1150,12 +1151,12 @@
Inherited Members
-
192def security(test=os.environ):
-193    """
-194    Default values are generally rendered using repr(),
-195    but some special cases -- like os.environ -- are overridden to avoid leaking sensitive data.
-196    """
-197    return False
+            
193def security(test=os.environ):
+194    """
+195    Default values are generally rendered using repr(),
+196    but some special cases -- like os.environ -- are overridden to avoid leaking sensitive data.
+197    """
+198    return False
 
@@ -1176,8 +1177,8 @@
Inherited Members
-
200class DoubleInherit(Foo, Bar.Baz, abc.ABC):
-201    """This is an example of a class that inherits from multiple parent classes."""
+            
201class DoubleInherit(Foo, Bar.Baz, abc.ABC):
+202    """This is an example of a class that inherits from multiple parent classes."""
 
@@ -1248,24 +1249,24 @@
Inherited Members
-
210@dataclass
-211class DataDemo:
-212    """
-213    This is an example for a dataclass.
-214
-215    As usual, you can link to individual properties: `DataDemo.a`.
-216    """
-217
-218    a: int
-219    """Again, we can document individual properties with docstrings."""
-220    a2: Sequence[str]
-221    # This property has a type annotation but is not documented.
-222    a3 = "a3"
-223    # This property has a default value but is not documented.
-224    a4: str = "a4"
-225    # This property has a type annotation and a default value but is not documented.
-226    b: bool = field(repr=False, default=True)
-227    """This property is assigned to `dataclasses.field()`, which works just as well."""
+            
211@dataclass
+212class DataDemo:
+213    """
+214    This is an example for a dataclass.
+215
+216    As usual, you can link to individual properties: `DataDemo.a`.
+217    """
+218
+219    a: int
+220    """Again, we can document individual properties with docstrings."""
+221    a2: Sequence[str]
+222    # This property has a type annotation but is not documented.
+223    a3 = "a3"
+224    # This property has a default value but is not documented.
+225    a4: str = "a4"
+226    # This property has a type annotation and a default value but is not documented.
+227    b: bool = field(repr=False, default=True)
+228    """This property is assigned to `dataclasses.field()`, which works just as well."""
 
@@ -1362,10 +1363,10 @@
Inherited Members
-
230@dataclass
-231class DataDemoExtended(DataDemo):
-232    c: str = "42"
-233    """A new attribute."""
+            
231@dataclass
+232class DataDemoExtended(DataDemo):
+233    c: str = "42"
+234    """A new attribute."""
 
@@ -1422,18 +1423,18 @@
Inherited Members
-
236class EnumDemo(enum.Enum):
-237    """
-238    This is an example of an Enum.
-239
-240    As usual, you can link to individual properties: `GREEN`.
-241    """
-242
-243    RED = 1
-244    """I am the red."""
-245    GREEN = 2
-246    """I am green."""
-247    BLUE = enum.auto()
+            
237class EnumDemo(enum.Enum):
+238    """
+239    This is an example of an Enum.
+240
+241    As usual, you can link to individual properties: `GREEN`.
+242    """
+243
+244    RED = 1
+245    """I am the red."""
+246    GREEN = 2
+247    """I am green."""
+248    BLUE = enum.auto()
 
@@ -1505,16 +1506,16 @@
Inherited Members
-
250def embed_image():
-251    """
-252    This docstring includes an embedded image:
-253
-254    ```
-255    ![pdoc logo](../docs/logo.png)
-256    ```
-257
-258    ![pdoc logo](../../docs/logo.png)
-259    """
+            
251def embed_image():
+252    """
+253    This docstring includes an embedded image:
+254
+255    ```
+256    ![pdoc logo](../docs/logo.png)
+257    ```
+258
+259    ![pdoc logo](../../docs/logo.png)
+260    """
 
@@ -1539,25 +1540,25 @@
Inherited Members
-
262def admonitions():
-263    """
-264    pdoc also supports basic reStructuredText admonitions:
-265
-266    ```
-267    .. note/warning/danger:: Optional title
-268       Body text
-269    ```
-270
-271    .. note::
-272       Hi there!
-273
-274    .. warning:: Be Careful!
-275       This warning has both a title and content.
-276
-277    .. danger::
-278       Danger ahead.
-279
-280    """
+            
263def admonitions():
+264    """
+265    pdoc also supports basic reStructuredText admonitions:
+266
+267    ```
+268    .. note/warning/danger:: Optional title
+269       Body text
+270    ```
+271
+272    .. note::
+273       Hi there!
+274
+275    .. warning:: Be Careful!
+276       This warning has both a title and content.
+277
+278    .. danger::
+279       Danger ahead.
+280
+281    """
 
diff --git a/test/testdata/demo_long.py b/test/testdata/demo_long.py index 742184a2..febf18c2 100644 --- a/test/testdata/demo_long.py +++ b/test/testdata/demo_long.py @@ -20,6 +20,7 @@ You can have multiple sections in your module docstring, which will also show up in the navigation. """ + from __future__ import annotations import abc diff --git a/test/testdata/demopackage.html b/test/testdata/demopackage.html index 5f10979a..0eb69abf 100644 --- a/test/testdata/demopackage.html +++ b/test/testdata/demopackage.html @@ -86,28 +86,29 @@

 1"""A test package with a sub-package at `.subpackage`."""
- 2import demopackage2
- 3
- 4from . import _child_e
- 5from . import child_b
- 6from ._child_d import Test
- 7from .child_b import B
- 8from .child_c import C
- 9
-10if demopackage2:
-11    pass
-12
-13__all__ = [
-14    "Test",
-15    "B",
-16    "C",
-17    "child_b",
-18    "child_c",
-19    "demopackage2",
-20    "_child_e",
-21    "child_excluded",
-22    "subpackage",
-23]
+ 2
+ 3import demopackage2
+ 4
+ 5from . import _child_e
+ 6from . import child_b
+ 7from ._child_d import Test
+ 8from .child_b import B
+ 9from .child_c import C
+10
+11if demopackage2:
+12    pass
+13
+14__all__ = [
+15    "Test",
+16    "B",
+17    "C",
+18    "child_b",
+19    "child_c",
+20    "demopackage2",
+21    "_child_e",
+22    "child_excluded",
+23    "subpackage",
+24]
 
@@ -168,14 +169,14 @@

-
 8class B:
- 9    """This class is defined in .child_b. It has a B.b method."""
-10
-11    b_type: typing.Type[B]
-12    """we have a self-referential attribute here"""
-13
-14    def b(self):
-15        return 1
+            
 9class B:
+10    """This class is defined in .child_b. It has a B.b method."""
+11
+12    b_type: typing.Type[B]
+13    """we have a self-referential attribute here"""
+14
+15    def b(self):
+16        return 1
 
@@ -207,8 +208,8 @@

-
14    def b(self):
-15        return 1
+            
15    def b(self):
+16        return 1
 
@@ -227,11 +228,11 @@

-
 6class C(child_b.B):
- 7    """This class is defined in .child_c and inherits from .child_b.B"""
- 8
- 9    def c(self):
-10        return 2
+            
 7class C(child_b.B):
+ 8    """This class is defined in .child_c and inherits from .child_b.B"""
+ 9
+10    def c(self):
+11        return 2
 
@@ -250,8 +251,8 @@

-
 9    def c(self):
-10        return 2
+            
10    def c(self):
+11        return 2
 
diff --git a/test/testdata/demopackage/__init__.py b/test/testdata/demopackage/__init__.py index 2e90044c..872fef07 100644 --- a/test/testdata/demopackage/__init__.py +++ b/test/testdata/demopackage/__init__.py @@ -1,4 +1,5 @@ """A test package with a sub-package at `.subpackage`.""" + import demopackage2 from . import _child_e diff --git a/test/testdata/demopackage/child_b.py b/test/testdata/demopackage/child_b.py index f143e121..a4bae2b0 100644 --- a/test/testdata/demopackage/child_b.py +++ b/test/testdata/demopackage/child_b.py @@ -1,4 +1,5 @@ """child_b docstr""" + from __future__ import annotations import typing diff --git a/test/testdata/demopackage/child_c.py b/test/testdata/demopackage/child_c.py index b0ccce51..08c3b9de 100644 --- a/test/testdata/demopackage/child_c.py +++ b/test/testdata/demopackage/child_c.py @@ -1,4 +1,5 @@ """child_c docstr""" + from . import child_b diff --git a/test/testdata/demopackage2.py b/test/testdata/demopackage2.py index 9142aeeb..b781a14b 100644 --- a/test/testdata/demopackage2.py +++ b/test/testdata/demopackage2.py @@ -1,2 +1,3 @@ """I'm a different package, but I'm in demopackage.__all__!""" + x = 42 diff --git a/test/testdata/demopackage_dir.html b/test/testdata/demopackage_dir.html index c84f2229..90a2bf5c 100644 --- a/test/testdata/demopackage_dir.html +++ b/test/testdata/demopackage_dir.html @@ -336,7 +336,8 @@

1&quot;&quot;&quot;I&#39;m a different package, but I&#39;m in demopackage.__all__!&quot;&quot;&quot;
-2x = 42
+2
+3x = 42
 
@@ -637,28 +638,29 @@

 1&quot;&quot;&quot;A test package with a sub-package at `.subpackage`.&quot;&quot;&quot;
- 2import demopackage2
- 3
- 4from . import _child_e
- 5from . import child_b
- 6from ._child_d import Test
- 7from .child_b import B
- 8from .child_c import C
- 9
-10if demopackage2:
-11    pass
-12
-13__all__ = [
-14    &quot;Test&quot;,
-15    &quot;B&quot;,
-16    &quot;C&quot;,
-17    &quot;child_b&quot;,
-18    &quot;child_c&quot;,
-19    &quot;demopackage2&quot;,
-20    &quot;_child_e&quot;,
-21    &quot;child_excluded&quot;,
-22    &quot;subpackage&quot;,
-23]
+ 2
+ 3import demopackage2
+ 4
+ 5from . import _child_e
+ 6from . import child_b
+ 7from ._child_d import Test
+ 8from .child_b import B
+ 9from .child_c import C
+10
+11if demopackage2:
+12    pass
+13
+14__all__ = [
+15    &quot;Test&quot;,
+16    &quot;B&quot;,
+17    &quot;C&quot;,
+18    &quot;child_b&quot;,
+19    &quot;child_c&quot;,
+20    &quot;demopackage2&quot;,
+21    &quot;_child_e&quot;,
+22    &quot;child_excluded&quot;,
+23    &quot;subpackage&quot;,
+24]
 
@@ -719,14 +721,14 @@

-
 8class B:
- 9    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
-10
-11    b_type: typing.Type[B]
-12    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
-13
-14    def b(self):
-15        return 1
+            
 9class B:
+10    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
+11
+12    b_type: typing.Type[B]
+13    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
+14
+15    def b(self):
+16        return 1
 
@@ -758,8 +760,8 @@

-
14    def b(self):
-15        return 1
+            
15    def b(self):
+16        return 1
 
@@ -778,11 +780,11 @@

-
 6class C(child_b.B):
- 7    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
- 8
- 9    def c(self):
-10        return 2
+            
 7class C(child_b.B):
+ 8    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
+ 9
+10    def c(self):
+11        return 2
 
@@ -801,8 +803,8 @@

-
 9    def c(self):
-10        return 2
+            
10    def c(self):
+11        return 2
 
@@ -1102,14 +1104,14 @@

-
 8class B:
- 9    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
-10
-11    b_type: typing.Type[B]
-12    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
-13
-14    def b(self):
-15        return 1
+            
 9class B:
+10    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
+11
+12    b_type: typing.Type[B]
+13    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
+14
+15    def b(self):
+16        return 1
 
@@ -1141,8 +1143,8 @@

-
14    def b(self):
-15        return 1
+            
15    def b(self):
+16        return 1
 
@@ -1403,15 +1405,16 @@

-
1&quot;&quot;&quot;child_c docstr&quot;&quot;&quot;
-2from . import child_b
-3
-4
-5class C(child_b.B):
-6    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
-7
-8    def c(self):
-9        return 2
+                        
 1&quot;&quot;&quot;child_c docstr&quot;&quot;&quot;
+ 2
+ 3from . import child_b
+ 4
+ 5
+ 6class C(child_b.B):
+ 7    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
+ 8
+ 9    def c(self):
+10        return 2
 
@@ -1427,11 +1430,11 @@

-
 6class C(child_b.B):
- 7    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
- 8
- 9    def c(self):
-10        return 2
+            
 7class C(child_b.B):
+ 8    &quot;&quot;&quot;This class is defined in .child_c and inherits from .child_b.B&quot;&quot;&quot;
+ 9
+10    def c(self):
+11        return 2
 
@@ -1450,8 +1453,8 @@

-
 9    def c(self):
-10        return 2
+            
10    def c(self):
+11        return 2
 
@@ -1726,19 +1729,20 @@

 1&quot;&quot;&quot;child_b docstr&quot;&quot;&quot;
- 2from __future__ import annotations
- 3
- 4import typing
- 5
+ 2
+ 3from __future__ import annotations
+ 4
+ 5import typing
  6
- 7class B:
- 8    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
- 9
-10    b_type: typing.Type[B]
-11    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
-12
-13    def b(self):
-14        return 1
+ 7
+ 8class B:
+ 9    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
+10
+11    b_type: typing.Type[B]
+12    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
+13
+14    def b(self):
+15        return 1
 
@@ -1754,14 +1758,14 @@

-
 8class B:
- 9    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
-10
-11    b_type: typing.Type[B]
-12    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
-13
-14    def b(self):
-15        return 1
+            
 9class B:
+10    &quot;&quot;&quot;This class is defined in .child_b. It has a B.b method.&quot;&quot;&quot;
+11
+12    b_type: typing.Type[B]
+13    &quot;&quot;&quot;we have a self-referential attribute here&quot;&quot;&quot;
+14
+15    def b(self):
+16        return 1
 
@@ -1793,8 +1797,8 @@

-
14    def b(self):
-15        return 1
+            
15    def b(self):
+16        return 1
 
diff --git a/test/testdata/math_demo.html b/test/testdata/math_demo.html index f067364b..fe10a0a2 100644 --- a/test/testdata/math_demo.html +++ b/test/testdata/math_demo.html @@ -144,38 +144,39 @@

Example

31 32# Example 33''' -34import math -35 +34 +35import math 36 -37def binom_coef(n: int, k: int) -> int: -38 """ -39 Return the number of ways to choose $k$ items from $n$ items without repetition and without order. -40 -41 Evaluates to $n! / (k! * (n - k)!)$ when $k <= n$ and evaluates to zero when $k > n$. -42 """ -43 return math.comb(n, k) -44 +37 +38def binom_coef(n: int, k: int) -> int: +39 """ +40 Return the number of ways to choose $k$ items from $n$ items without repetition and without order. +41 +42 Evaluates to $n! / (k! * (n - k)!)$ when $k <= n$ and evaluates to zero when $k > n$. +43 """ +44 return math.comb(n, k) 45 -46def long_formula(): -47 r""" -48 $$ -49 \Delta = -50 \Delta_\text{this} + -51 \Delta_\text{is} + -52 \Delta_\text{a} + -53 \Delta_\text{very} + -54 \Delta_\text{long} + -55 \Delta_\text{formula} + -56 \Delta_\text{that} + -57 \Delta_\text{does} + -58 \Delta_\text{not} + -59 \Delta_\text{fully} + -60 \Delta_\text{fit} + -61 \Delta_\text{on} + -62 \Delta_\text{the} + -63 \Delta_\text{screen} -64 $$ -65 """ +46 +47def long_formula(): +48 r""" +49 $$ +50 \Delta = +51 \Delta_\text{this} + +52 \Delta_\text{is} + +53 \Delta_\text{a} + +54 \Delta_\text{very} + +55 \Delta_\text{long} + +56 \Delta_\text{formula} + +57 \Delta_\text{that} + +58 \Delta_\text{does} + +59 \Delta_\text{not} + +60 \Delta_\text{fully} + +61 \Delta_\text{fit} + +62 \Delta_\text{on} + +63 \Delta_\text{the} + +64 \Delta_\text{screen} +65 $$ +66 """
@@ -191,13 +192,13 @@

Example

-
38def binom_coef(n: int, k: int) -> int:
-39    """
-40    Return the number of ways to choose $k$ items from $n$ items without repetition and without order.
-41
-42    Evaluates to $n! / (k! * (n - k)!)$ when $k <= n$ and evaluates to zero when $k > n$.
-43    """
-44    return math.comb(n, k)
+            
39def binom_coef(n: int, k: int) -> int:
+40    """
+41    Return the number of ways to choose $k$ items from $n$ items without repetition and without order.
+42
+43    Evaluates to $n! / (k! * (n - k)!)$ when $k <= n$ and evaluates to zero when $k > n$.
+44    """
+45    return math.comb(n, k)
 
@@ -219,26 +220,26 @@

Example

-
47def long_formula():
-48    r"""
-49    $$
-50        \Delta =
-51        \Delta_\text{this} +
-52        \Delta_\text{is} +
-53        \Delta_\text{a} +
-54        \Delta_\text{very} +
-55        \Delta_\text{long} +
-56        \Delta_\text{formula} +
-57        \Delta_\text{that} +
-58        \Delta_\text{does} +
-59        \Delta_\text{not} +
-60        \Delta_\text{fully} +
-61        \Delta_\text{fit} +
-62        \Delta_\text{on} +
-63        \Delta_\text{the} +
-64        \Delta_\text{screen}
-65    $$
-66    """
+            
48def long_formula():
+49    r"""
+50    $$
+51        \Delta =
+52        \Delta_\text{this} +
+53        \Delta_\text{is} +
+54        \Delta_\text{a} +
+55        \Delta_\text{very} +
+56        \Delta_\text{long} +
+57        \Delta_\text{formula} +
+58        \Delta_\text{that} +
+59        \Delta_\text{does} +
+60        \Delta_\text{not} +
+61        \Delta_\text{fully} +
+62        \Delta_\text{fit} +
+63        \Delta_\text{on} +
+64        \Delta_\text{the} +
+65        \Delta_\text{screen}
+66    $$
+67    """
 
diff --git a/test/testdata/math_demo.py b/test/testdata/math_demo.py index e985da0a..2059f5b5 100644 --- a/test/testdata/math_demo.py +++ b/test/testdata/math_demo.py @@ -31,6 +31,7 @@ def foo(): # Example ''' + import math diff --git a/test/testdata/misc_py312.html b/test/testdata/misc_py312.html index 7f2bc5ff..c6aaa9f1 100755 --- a/test/testdata/misc_py312.html +++ b/test/testdata/misc_py312.html @@ -99,54 +99,55 @@

3""" 4Testing features that either are 3.12+ only or render slightly different on 3.12. 5""" - 6from __future__ import annotations - 7 - 8import typing - 9from typing import NamedTuple -10from typing import Optional -11from typing import TypedDict -12 -13# Testing the new Python 3.12 `type` statement. -14type MyType = int -15"""A custom Python 3.12 type.""" -16 -17foo: MyType -18"""A custom type instance.""" -19 + 6 + 7from __future__ import annotations + 8 + 9import typing +10from typing import NamedTuple +11from typing import Optional +12from typing import TypedDict +13 +14# Testing the new Python 3.12 `type` statement. +15type MyType = int +16"""A custom Python 3.12 type.""" +17 +18foo: MyType +19"""A custom type instance.""" 20 -21type MyTypeWithoutDocstring = int -22 -23MyTypeClassic: typing.TypeAlias = int -24"""A "classic" typing.TypeAlias.""" -25 -26# Testing a typing.NamedTuple -27# we do not care very much about collections.namedtuple, -28# the typing version is superior for documentation and a drop-in replacement. -29 +21 +22type MyTypeWithoutDocstring = int +23 +24MyTypeClassic: typing.TypeAlias = int +25"""A "classic" typing.TypeAlias.""" +26 +27# Testing a typing.NamedTuple +28# we do not care very much about collections.namedtuple, +29# the typing version is superior for documentation and a drop-in replacement. 30 -31class NamedTupleExample(NamedTuple): -32 """ -33 An example for a typing.NamedTuple. -34 """ -35 -36 name: str -37 """Name of our example tuple.""" -38 id: int = 3 -39 +31 +32class NamedTupleExample(NamedTuple): +33 """ +34 An example for a typing.NamedTuple. +35 """ +36 +37 name: str +38 """Name of our example tuple.""" +39 id: int = 3 40 -41# Testing some edge cases in our inlined implementation of ForwardRef._evaluate in _eval_type. -42class Foo(TypedDict): -43 a: Optional[int] -44 """First attribute.""" -45 +41 +42# Testing some edge cases in our inlined implementation of ForwardRef._evaluate in _eval_type. +43class Foo(TypedDict): +44 a: Optional[int] +45 """First attribute.""" 46 -47class Bar(Foo, total=False): -48 """A TypedDict subclass. Before 3.12, TypedDict botches __mro__.""" -49 -50 b: int -51 """Second attribute.""" -52 c: str -53 # undocumented attribute +47 +48class Bar(Foo, total=False): +49 """A TypedDict subclass. Before 3.12, TypedDict botches __mro__.""" +50 +51 b: int +52 """Second attribute.""" +53 c: str +54 # undocumented attribute

@@ -215,14 +216,14 @@

-
32class NamedTupleExample(NamedTuple):
-33    """
-34    An example for a typing.NamedTuple.
-35    """
-36
-37    name: str
-38    """Name of our example tuple."""
-39    id: int = 3
+            
33class NamedTupleExample(NamedTuple):
+34    """
+35    An example for a typing.NamedTuple.
+36    """
+37
+38    name: str
+39    """Name of our example tuple."""
+40    id: int = 3
 
@@ -292,9 +293,9 @@
Inherited Members
-
43class Foo(TypedDict):
-44    a: Optional[int]
-45    """First attribute."""
+            
44class Foo(TypedDict):
+45    a: Optional[int]
+46    """First attribute."""
 
@@ -344,13 +345,13 @@
Inherited Members
-
48class Bar(Foo, total=False):
-49    """A TypedDict subclass. Before 3.12, TypedDict botches __mro__."""
-50
-51    b: int
-52    """Second attribute."""
-53    c: str
-54    # undocumented attribute
+            
49class Bar(Foo, total=False):
+50    """A TypedDict subclass. Before 3.12, TypedDict botches __mro__."""
+51
+52    b: int
+53    """Second attribute."""
+54    c: str
+55    # undocumented attribute
 
diff --git a/test/testdata/misc_py312.py b/test/testdata/misc_py312.py index f9d9f9fd..2d7db3fc 100755 --- a/test/testdata/misc_py312.py +++ b/test/testdata/misc_py312.py @@ -3,6 +3,7 @@ """ Testing features that either are 3.12+ only or render slightly different on 3.12. """ + from __future__ import annotations import typing diff --git a/test/testdata/misc_py39.html b/test/testdata/misc_py39.html index 43eda579..e6e5a2cf 100644 --- a/test/testdata/misc_py39.html +++ b/test/testdata/misc_py39.html @@ -61,36 +61,37 @@

 1"""
  2Testing features that either are 3.9+ only or render slightly different on 3.9.
  3"""
- 4from __future__ import annotations
- 5
- 6import functools
- 7from typing import Union
- 8
+ 4
+ 5from __future__ import annotations
+ 6
+ 7import functools
+ 8from typing import Union
  9
-10class SingleDispatchMethodExample:
-11    @functools.singledispatchmethod
-12    def fancymethod(self, str_or_int: Union[str, int]):
-13        """A fancy method which is capable of handling either `str` or `int`.
-14
-15        :param str_or_int: string or integer to handle
-16        """
-17        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
-18
-19    @fancymethod.register
-20    def fancymethod_handle_str(self, str_to_handle: str):
-21        """Fancy method handles a string.
-22
-23        :param str_to_handle: string which will be handled
-24        """
-25        print(f"{type(str_to_handle)} = '{str_to_handle}")
-26
-27    @fancymethod.register
-28    def _fancymethod_handle_int(self, int_to_handle: int):
-29        """Fancy method handles int (not shown in doc).
-30
-31        :param int_to_handle: int which will be handled
-32        """
-33        print(f"{type(int_to_handle)} = '{int_to_handle:x}'")
+10
+11class SingleDispatchMethodExample:
+12    @functools.singledispatchmethod
+13    def fancymethod(self, str_or_int: Union[str, int]):
+14        """A fancy method which is capable of handling either `str` or `int`.
+15
+16        :param str_or_int: string or integer to handle
+17        """
+18        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
+19
+20    @fancymethod.register
+21    def fancymethod_handle_str(self, str_to_handle: str):
+22        """Fancy method handles a string.
+23
+24        :param str_to_handle: string which will be handled
+25        """
+26        print(f"{type(str_to_handle)} = '{str_to_handle}")
+27
+28    @fancymethod.register
+29    def _fancymethod_handle_int(self, int_to_handle: int):
+30        """Fancy method handles int (not shown in doc).
+31
+32        :param int_to_handle: int which will be handled
+33        """
+34        print(f"{type(int_to_handle)} = '{int_to_handle:x}'")
 
@@ -106,30 +107,30 @@

-
11class SingleDispatchMethodExample:
-12    @functools.singledispatchmethod
-13    def fancymethod(self, str_or_int: Union[str, int]):
-14        """A fancy method which is capable of handling either `str` or `int`.
-15
-16        :param str_or_int: string or integer to handle
-17        """
-18        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
-19
-20    @fancymethod.register
-21    def fancymethod_handle_str(self, str_to_handle: str):
-22        """Fancy method handles a string.
-23
-24        :param str_to_handle: string which will be handled
-25        """
-26        print(f"{type(str_to_handle)} = '{str_to_handle}")
-27
-28    @fancymethod.register
-29    def _fancymethod_handle_int(self, int_to_handle: int):
-30        """Fancy method handles int (not shown in doc).
-31
-32        :param int_to_handle: int which will be handled
-33        """
-34        print(f"{type(int_to_handle)} = '{int_to_handle:x}'")
+            
12class SingleDispatchMethodExample:
+13    @functools.singledispatchmethod
+14    def fancymethod(self, str_or_int: Union[str, int]):
+15        """A fancy method which is capable of handling either `str` or `int`.
+16
+17        :param str_or_int: string or integer to handle
+18        """
+19        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
+20
+21    @fancymethod.register
+22    def fancymethod_handle_str(self, str_to_handle: str):
+23        """Fancy method handles a string.
+24
+25        :param str_to_handle: string which will be handled
+26        """
+27        print(f"{type(str_to_handle)} = '{str_to_handle}")
+28
+29    @fancymethod.register
+30    def _fancymethod_handle_int(self, int_to_handle: int):
+31        """Fancy method handles int (not shown in doc).
+32
+33        :param int_to_handle: int which will be handled
+34        """
+35        print(f"{type(int_to_handle)} = '{int_to_handle:x}'")
 
@@ -147,13 +148,13 @@

-
12    @functools.singledispatchmethod
-13    def fancymethod(self, str_or_int: Union[str, int]):
-14        """A fancy method which is capable of handling either `str` or `int`.
-15
-16        :param str_or_int: string or integer to handle
-17        """
-18        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
+            
13    @functools.singledispatchmethod
+14    def fancymethod(self, str_or_int: Union[str, int]):
+15        """A fancy method which is capable of handling either `str` or `int`.
+16
+17        :param str_or_int: string or integer to handle
+18        """
+19        raise NotImplementedError(f"{type(str_or_int)=} not implemented!")
 
@@ -180,13 +181,13 @@
Parameters
-
20    @fancymethod.register
-21    def fancymethod_handle_str(self, str_to_handle: str):
-22        """Fancy method handles a string.
-23
-24        :param str_to_handle: string which will be handled
-25        """
-26        print(f"{type(str_to_handle)} = '{str_to_handle}")
+            
21    @fancymethod.register
+22    def fancymethod_handle_str(self, str_to_handle: str):
+23        """Fancy method handles a string.
+24
+25        :param str_to_handle: string which will be handled
+26        """
+27        print(f"{type(str_to_handle)} = '{str_to_handle}")
 
diff --git a/test/testdata/misc_py39.py b/test/testdata/misc_py39.py index c7acd514..65f60e33 100644 --- a/test/testdata/misc_py39.py +++ b/test/testdata/misc_py39.py @@ -1,6 +1,7 @@ """ Testing features that either are 3.9+ only or render slightly different on 3.9. """ + from __future__ import annotations import functools diff --git a/test/testdata/top_level_reimports.html b/test/testdata/top_level_reimports.html index a4d468c5..7b7a9e19 100644 --- a/test/testdata/top_level_reimports.html +++ b/test/testdata/top_level_reimports.html @@ -82,11 +82,12 @@

6 - `top_level_reimports._internal.baz` 7 - `top_level_reimports._internal.baz()` 8""" - 9from ._internal import Bar -10from ._internal import Foo -11from ._internal import baz -12 -13__all__ = ["Foo", "Bar", "baz"] + 9 +10from ._internal import Bar +11from ._internal import Foo +12from ._internal import baz +13 +14__all__ = ["Foo", "Bar", "baz"]

diff --git a/test/testdata/top_level_reimports/__init__.py b/test/testdata/top_level_reimports/__init__.py index c3c058b7..c4a8d065 100644 --- a/test/testdata/top_level_reimports/__init__.py +++ b/test/testdata/top_level_reimports/__init__.py @@ -6,6 +6,7 @@ - `top_level_reimports._internal.baz` - `top_level_reimports._internal.baz()` """ + from ._internal import Bar from ._internal import Foo from ._internal import baz diff --git a/test/testdata/visibility.html b/test/testdata/visibility.html index 8cec99ce..219c557c 100644 --- a/test/testdata/visibility.html +++ b/test/testdata/visibility.html @@ -60,7 +60,7 @@

 1"""
  2Example where only the these children should be rendered:
  3 * `__private_func_explicitly_public` and
- 4 * `public_func` 
+ 4 * `public_func`
  5"""
  6
  7
diff --git a/test/testdata/visibility.py b/test/testdata/visibility.py
index 6641dc6b..f63f2bf0 100755
--- a/test/testdata/visibility.py
+++ b/test/testdata/visibility.py
@@ -1,7 +1,7 @@
 """
 Example where only the these children should be rendered:
  * `__private_func_explicitly_public` and
- * `public_func` 
+ * `public_func`
 """