from __future__ import annotations

from typing import Literal, TypeAlias

import griffe as gf

from ._docstring_sections import (
    DCDocstringSection,
    DCDocstringSectionInitParameters,
    DCDocstringSectionParameterAttributes,
)
from ._render.api_page import RenderAPIPage
from ._render.doc import RenderDoc
from ._render.docattribute import RenderDocAttribute
from ._render.docclass import RenderDocClass
from ._render.docfunction import RenderDocFunction
from ._render.docmodule import RenderDocModule
from ._render.doctypealias import RenderDocTypeAlias
from ._render.reference_page import RenderReferencePage
from ._render.reference_section import RenderReferenceSection
from .content import (
    Doc,
    DocAttribute,
    DocClass,
    DocFunction,
    DocModule,
    DocTypeAlias,
    MemberPage,
    Page,
    Section,
)

Annotation: TypeAlias = str | gf.Expr
DisplayNameFormat: TypeAlias = Literal["doc", "full", "name", "short", "relative", "canonical"]
DocObjectKind: TypeAlias = Literal[
    "module",
    "class",
    "method",
    "property",
    "function",
    "attribute",
    "alias",
    "type",
    "typevar",
    "type alias",
]

DocstringSectionWithDefinitions: TypeAlias = (
    gf.DocstringSectionParameters
    | gf.DocstringSectionOtherParameters
    | gf.DocstringSectionTypeParameters
    | gf.DocstringSectionReturns
    | gf.DocstringSectionYields
    | gf.DocstringSectionReceives
    | gf.DocstringSectionRaises
    | gf.DocstringSectionWarns
    | gf.DocstringSectionAttributes
    | DCDocstringSectionParameterAttributes
    | DCDocstringSectionInitParameters
)

DocstringDefinitionType: TypeAlias = (
    gf.DocstringParameter
    | gf.DocstringTypeParameter
    | gf.DocstringAttribute
    | gf.DocstringReturn
    | gf.DocstringYield
    | gf.DocstringReceive
    | gf.DocstringRaise
    | gf.DocstringWarn
)

Documentable: TypeAlias = (
    DocClass | DocFunction | DocAttribute | DocTypeAlias | DocModule | Page | Section
)

RenderObjType: TypeAlias = (
    RenderDoc
    | RenderDocClass
    | RenderDocFunction
    | RenderDocAttribute
    | RenderDocTypeAlias
    | RenderDocModule
    | RenderReferencePage
    | RenderAPIPage
    | RenderReferenceSection
)

AnyDocstringSection: TypeAlias = gf.DocstringSection | DCDocstringSection

DocType: TypeAlias = DocClass | DocFunction | DocAttribute | DocTypeAlias | DocModule

DocMemberType: TypeAlias = MemberPage | Doc
