Skip to content

Commit

Permalink
Merge pull request #304 from has2k1/upgrade-griffe
Browse files Browse the repository at this point in the history
chore: bump griffe to >=0.33
  • Loading branch information
machow authored Nov 16, 2023
2 parents 1f4f9f3 + 3fcafc8 commit 540d29c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
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

0 comments on commit 540d29c

Please sign in to comment.