# Path: htmlgen/attribute.py
# class html_attribute:
#     """Add an attribute to an HTML element.
# 
#         >>> from htmlgen import Element
#         >>> class MyElement(Element):
#         ...     url = html_attribute("data-url")
#         >>> element = MyElement("div")
#         >>> element.url
#         >>> str(element)
#         '<div></div>'
#         >>> element.url = "http://www.example.com/"
#         >>> str(element)
#         '<div data-url="http://www.example.com/"></div>'
# 
#     If the optional default argument is given, the attribute will not be
#     included if the value matches it.
# 
#         >>> class MyElement(Element):
#         ...     value = html_attribute("data-value", default="hello")
#         >>> element = MyElement("div")
#         >>> element.value
#         'hello'
#         >>> str(element)
#         '<div></div>'
# 
#     """
# 
#     def __init__(self, attribute_name, default=None):
#         self._attribute_name = attribute_name
#         self._default = default
# 
#     def __get__(self, obj, _=None):
#         return obj.get_attribute(self._attribute_name, default=self._default)
# 
#     def __set__(self, obj, value):
#         if value is None or value == self._default:
#             obj.remove_attribute(self._attribute_name)
#         else:
#             obj.set_attribute(self._attribute_name, value)
# 
# Path: htmlgen/element.py
# class VoidElement(ElementBase):
# 
#     """Base generator for content-less HTML elements.
# 
#     These are elements like <br> or <link>.
# 
#         >>> link = VoidElement("link")
#         >>> link.set_attribute("rel", "stylesheet")
#         >>> str(link)
#         '<link rel="stylesheet"/>'
# 
#     """
# 
#     def generate(self):
#         yield self.render_start_tag() + "/>"


from .attribute import html_attribute
from .element import VoidElement


class Image(VoidElement):
    """An HTML image (<img>) element.

    Images must have an alternate text description that describes the
    contents of the image, if the image can not be displayed. In some
    cases the alternate text can be empty. For example, if the image just
    displays a company logo next to the company's name or if the image just
    adds an icon next to a textual description of an action.

    Example:

        >>> image = Image("whiteboard.jpg",
        ...               "A whiteboard filled with mathematical formulas.")
        >>> image.title = "Whiteboards are a useful tool"
    """

    def __init__(self, url, alternate_text=""):
        super().__init__("img")
        self.url = url
        self.alternate_text = alternate_text

    url = html_attribute("src")

# Path: htmlgen/attribute.py
# class html_attribute:
#     """Add an attribute to an HTML element.
# 
#         >>> from htmlgen import Element
#         >>> class MyElement(Element):
#         ...     url = html_attribute("data-url")
#         >>> element = MyElement("div")
#         >>> element.url
#         >>> str(element)
#         '<div></div>'
#         >>> element.url = "http://www.example.com/"
#         >>> str(element)
#         '<div data-url="http://www.example.com/"></div>'
# 
#     If the optional default argument is given, the attribute will not be
#     included if the value matches it.
# 
#         >>> class MyElement(Element):
#         ...     value = html_attribute("data-value", default="hello")
#         >>> element = MyElement("div")
#         >>> element.value
#         'hello'
#         >>> str(element)
#         '<div></div>'
# 
#     """
# 
#     def __init__(self, attribute_name, default=None):
#         self._attribute_name = attribute_name
#         self._default = default
# 
#     def __get__(self, obj, _=None):
#         return obj.get_attribute(self._attribute_name, default=self._default)
# 
#     def __set__(self, obj, value):
#         if value is None or value == self._default:
#             obj.remove_attribute(self._attribute_name)
#         else:
#             obj.set_attribute(self._attribute_name, value)
# 
# Path: htmlgen/element.py
# class VoidElement(ElementBase):
# 
#     """Base generator for content-less HTML elements.
# 
#     These are elements like <br> or <link>.
# 
#         >>> link = VoidElement("link")
#         >>> link.set_attribute("rel", "stylesheet")
#         >>> str(link)
#         '<link rel="stylesheet"/>'
# 
#     """
# 
#     def generate(self):
#         yield self.render_start_tag() + "/>"


# Path: htmlgen/image.py
from .attribute import html_attribute
from .element import VoidElement



class Image(VoidElement):
    """An HTML image (<img>) element.

    Images must have an alternate text description that describes the
    contents of the image, if the image can not be displayed. In some
    cases the alternate text can be empty. For example, if the image just
    displays a company logo next to the company's name or if the image just
    adds an icon next to a textual description of an action.

    Example:

        >>> image = Image("whiteboard.jpg",
        ...               "A whiteboard filled with mathematical formulas.")
        >>> image.title = "Whiteboards are a useful tool"
    """

    def __init__(self, url, alternate_text=""):
        super().__init__("img")
        self.url = url
        self.alternate_text = alternate_text

    url = html_attribute("src")

    alternate_text = html_attribute("alt")