class_docstr: Render a layout.Doc object
class_docstr_tok: ["Render","a","layout.Doc","object"]
docstr: Render an annotation
  
  This can be used to renderer the annotation of:
  
      1. self - if it is an Attribute & annotation is None
      2. annotation - annotation of a parameter in the signature
         of self
docstr_tok: ["Render","an","annotation","This","can","be","used","to","renderer","the","annotation","of",":","1.","self","-","if","it","is","an","Attribute","&","annotation","is","None","2.","annotation","-","annotation","of","a","parameter","in","the","signature","of","self"]
code: def render_annotation(
      self, annotation: Optional[Annotation] = None
  ) -> Inline | str:
      """
      Render an annotation
  
      This can be used to renderer the annotation of:
  
          1. self - if it is an Attribute & annotation is None
          2. annotation - annotation of a parameter in the signature
             of self
      """
      if annotation is None:
          if not isinstance(self.obj, dc.Attribute):
              msg = (
                  f"Cannot render annotation for type {type(self.obj)}."
              )
              raise TypeError(msg)
  
          self.obj = cast(dc.Attribute, self.obj)
          annotation = self.obj.annotation
  
      def _render(ann):
          # Recursively render annotation
          if ann is None:
              return ""
          elif isinstance(ann, str):
              return repr_obj(ann)
          elif isinstance(ann, expr.ExprName):
              return InterLink(
                  markdown_escape(ann.name), ann.canonical_path
              )
          elif isinstance(ann, expr.Expr):
              # A type annotation with ~ removes the qualname prefix
              path_str = ann.canonical_path
              if path_str[0] == "~":
                  return InterLink(ann.canonical_name, path_str[1:])
              return "".join(str(_render(a)) for a in ann)
          else:
              msg = f"Cannot render annotation for type {type(ann)}."
              raise TypeError(msg)
  
      return _render(annotation)
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from functools import cached_property, singledispatchmethod
  from typing import TYPE_CHECKING, cast
  import griffe.expressions
  from griffe import dataclasses
  from griffe.docstrings import dataclasses
  from quartodoc import ast
  from quartodoc import layout
  from quartodoc.pandoc.blocks import Block, BlockContent, Blocks, CodeBlock, Div, Header
  from quartodoc.pandoc.components import Attr
  from quartodoc.pandoc.inlines import Code, Inline, Inlines, Link, Span
  from ..format import markdown_escape, pretty_code, repr_obj
  from ..typing import DocObjectKind
  from ..utils import InterLink, is_protocol, is_typealias, is_typevar, no_init
  from .base import RenderBase
label_desc: Use image node_id 9 for calling the __RenderDoc obj's underlying member method code with example usage: obj.render_annotation(annotation) and returns: _render, str, repr_obj, InterLink, str, InterLink