Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump griffe to >=0.33, <=0.38 #304

Merged
merged 2 commits into from
Nov 16, 2023
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dynamic = ["version"]
requires-python = ">=3.9"
dependencies = [
"click",
"griffe <= 0.32.3",
"griffe >= 0.33",
"sphobjinv >= 2.3.1",
"tabulate >= 0.9.0",
"importlib-metadata >= 5.1.0",
Expand Down
16 changes: 5 additions & 11 deletions quartodoc/renderers/md_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import wraps
from griffe.docstrings import dataclasses as ds
from griffe import dataclasses as dc
from griffe import expressions as expr
from tabulate import tabulate
from plum import dispatch
from typing import Tuple, Union, Optional
Expand All @@ -14,13 +15,6 @@
from .base import Renderer, escape, sanitize, convert_rst_link_to_md


try:
# Name and Expression were moved to expressions in v0.28
from griffe import expressions as expr
except ImportError:
from griffe import dataclasses as expr


def _has_attr_section(el: dc.Docstring | None):
if el is None:
return False
Expand Down Expand Up @@ -130,16 +124,16 @@ def render_annotation(self, el: None) -> str:
return ""

@dispatch
def render_annotation(self, el: expr.Name) -> str:
def render_annotation(self, el: expr.ExprName) -> str:
# TODO: maybe there is a way to get tabulate to handle this?
# unescaped pipes screw up table formatting
if self.render_interlinks:
return f"[{sanitize(el.source)}](`{el.full}`)"
return f"[{sanitize(el.name)}](`{el.canonical_path}`)"

return sanitize(el.source)
return sanitize(el.canonical_path)

@dispatch
def render_annotation(self, el: expr.Expression) -> str:
def render_annotation(self, el: expr.Expr) -> str:
return "".join(map(self.render_annotation, el))

# signature method --------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion quartodoc/tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_render_doc_attribute(renderer):
attr = ds.DocstringAttribute(
name="abc",
description="xyz",
annotation=exp.Expression(exp.Name("Optional", full="Optional"), "[", "]"),
annotation=exp.ExprSubscript(exp.ExprName("Optional"), ""),
value=1,
)

Expand Down
Loading