from __future__ import annotations

from abc import abstractmethod
from types import TracebackType
from typing import Self

from pygitweb.api.plugin import Plugin


class Subpage(Plugin):
	"""
	Subpage: A per-project subpage provided by a plugin.
	"""

	@abstractmethod
	def __enter__(self) -> Self: ...

	@abstractmethod
	def __exit__(
		self,
		exc_type: type[BaseException] | None,
		exc_value: BaseException | None,
		traceback: TracebackType | None,
	) -> bool | None: ...

	@abstractmethod
	def subpage_name(self) -> str: ...

	@abstractmethod
	def link_name(self, project: str) -> str | None: ...

	@abstractmethod
	def subpage_html(self, project: str) -> str | None: ...

	@abstractmethod
	def summary_value_suffix_html(self, project: str, project_enc: str) -> str | None:
		"""Optional HTML appended after the subpage \"view\" link on the project summary table."""