Skip to content

Commit

Permalink
fix: docs more than one target found for cross-reference YContextTree
Browse files Browse the repository at this point in the history
  • Loading branch information
HK-SHAO committed May 12, 2024
1 parent 1390806 commit 3ea72f1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
"imported-members",
]

autoapi_member_order = "bysource"
autoapi_own_page_level = "module"
autoapi_python_use_implicit_namespaces = True

napoleon_google_docstring = True
napoleon_numpy_docstring = False
Expand All @@ -103,7 +105,10 @@
# Tell myst-parser to assign header anchors for h1-h3.
myst_heading_anchors = 3

suppress_warnings = ["myst.header"]
suppress_warnings = [
"myst.header",
# "ref.python",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
2 changes: 1 addition & 1 deletion yieldlang/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .generator import TextGenerator, YContextTree, YGenerator
from .generator import TextGenerator, YGenerator
from .sampler import BaseSampler, RandomSampler
from .tree import YMiniTree, minify_ctx_tree
4 changes: 2 additions & 2 deletions yieldlang/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, sampler: BaseSampler | None = None) -> None:
"""Initialize the generator with a sampler."""
self._sampler: BaseSampler = sampler or BaseSampler.default()
"""The sampler to use for sampling symbols."""
self._top_ctx = YContextTree(max_depth=-1, cur_depth=0)
self._top_ctx: YContextTree = YContextTree(max_depth=-1, cur_depth=0)
"""The root context for flattening symbols."""
self._generator: YGenerator = self._iter_symbol(self.top)
"""The generator for the text."""
Expand Down Expand Up @@ -101,7 +101,7 @@ def _flatten(self, symbol: Symbol, ctx: YContextTree) -> IteratorSymbol:
Args:
symbol (Symbol): The symbol to flatten.
ctx (FlattenContext): The context for flattening.
ctx (YContextTree): The context for flattening.
"""
ctx = self._new_child_ctx(ctx)
if ctx.max_depth > -1 and ctx.cur_depth > ctx.max_depth:
Expand Down
5 changes: 4 additions & 1 deletion yieldlang/tree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from dataclasses import dataclass, field
from typing import Generator, Optional, TypeAlias, TypedDict

from typing_extensions import NotRequired
try:
from typing import NotRequired
except ImportError:
from typing_extensions import NotRequired

from yieldlang.types import Symbol, is_empty

Expand Down
10 changes: 9 additions & 1 deletion yieldlang/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from enum import Enum
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Expand All @@ -9,7 +10,14 @@
TypeAlias,
)

from typing_extensions import TypeIs
if not TYPE_CHECKING:
try:
from typing import TypeIs
except ImportError:
from typing_extensions import TypeIs
else:
from typing_extensions import TypeIs


EmptyString: Literal[""] = ""
"""Empty string constant."""
Expand Down

0 comments on commit 3ea72f1

Please sign in to comment.