git @ Cat's Eye Technologies The-Glosscubator / master script / build_readmes / types.py
master

Tree @master (Download .tar.gz)

types.py @master — raw · history · blame

# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense


from typing import Callable, Literal, TypeAlias, TypedDict


# should really be a part of Feedmark I think
class SectionJSON(TypedDict):
    anchor: str
    body: str
    images: list[str]
    properties: dict[str, str | list[str]]
    title: str


class ResourceCollection(TypedDict):
    webpages: list[SectionJSON]
    repos: list[SectionJSON]
    books: list[SectionJSON]
    papers: list[SectionJSON]


Entry: TypeAlias = SectionJSON
ResourceType: TypeAlias = Literal[
    "webpages",
    "repos",
    "books",
    "papers",
]
Topic: TypeAlias = str
TopicIndex: TypeAlias = dict[Topic, list[Entry]]
MultiLevelIndex: TypeAlias = dict[str, TopicIndex]

EntryFormatter: TypeAlias = Callable[[Entry], str]