WhakerPy 0.8

https://sourceforge.net/projects/whakerpy/

Module whakerpy.htmlmaker

Class Doctype

Description

Represent the HTML doctype of an HTML-5 page.

Example
 >>> d = Doctype()
 >>> d.serialize()
 >>> '<!DOCTYPE html>'

All HTML documents must start with a <!DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect.

Contrariwise to previous versions, HTML5 does not require any other information. Then this class does not accept any attribute or value.

Constructor

Create a doctype node with no defined parent.

View Source
def __init__(self):
    """Create a doctype node with no defined parent."""
    super(Doctype, self).__init__(None, str(uuid.uuid1()))
    self._value = '<!DOCTYPE html>'

Public functions

serialize

Override. Serialize the doctype.

Parameters
  • nbs: (int) Number of spaces for the indentation. Un-used.
Returns
  • (str) Doctype in HTML5.
View Source
def serialize(self, nbs: int=4) -> str:
    """Override. Serialize the doctype.

        :param nbs: (int) Number of spaces for the indentation. Un-used.
        :return: (str) Doctype in HTML5.

        """
    return self._value + '\n\n'